Giter Site home page Giter Site logo

animation-javascript's Introduction

js实现帧动画

简介

帧动画就是在连续的关键帧中分解动画动作,也就是在时间轴上的每帧上逐帧绘制不同的内容,使其连续播放成动画。常见的帧动画方式有GIF,CSS3 animation和js。使用GIF和CSS3 animation的不足是不能灵活地控制动画的暂停和播放(比如点击暂停),也不能灵活地捕捉到动画完成的事件,另外在动画扩展性上js更好。

原理

  1. 用一个img标签去承载图片,定时改变img的src属性,这样显然不好。因为请求了多张图,影响性能。

  2. 把所有动画关键帧绘制在一张图片里,把图片作为元素的background-image,定时改变元素的background-position(雪碧图)。对于只是位移的动画,可以通过js直接改变元素的left或者top值

本项目主要使用第二种方式

animation-javascript's People

Contributors

liutaochange avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.