Giter VIP home page Giter VIP logo

animation's Introduction

一:常见帧动画存在的问题

1.GIF 和 CSS3 Animation

(1)不能控制动画的暂停和播放
(2)不能捕捉完成事件
(3)不能对帧动画做灵活扩展

二:js帧动画实现的原理

改变background-position位置来实现

三:实现的功能

1.支持功能

(1).图片预加载
(2).2种动画播放方式和自定义每帧动画
(3).单组动画控制循环次数(可无限次循环)
(4).一组动画完成后,进行下一组动画
(5).每个动画完成后有等待时间
(6).动画暂停和播放
(7).动画完成后回调函数

2.编程接口

(1).loadImg(imgList) //预加载图片
(2).changePosition(ele, positions, imgUrl) //改变background-position位置来实现
(3).changeSrc(ele, imgList) //通过改变元素的src
(4).enterFrame(callback) //每一帧动画执行的函数
(5).repeat(times) //空表示无限次
(6).repeatForever() //无限次执行上一次的动画,相当于repeat()
(7).wait(time) //每个动画完成后等待的时间
(8).then(callback) //动画完成后执行的回调
(9).start(interval) //动画开始执行
(10).pause() //动画暂停
(11).restart() //动画恢复(从上一次暂停处从新执行)
(12).dispose() //释放资源

3.调用方式

支持链式调用,调用方式如下
    var animation = require("animation");
    var demoAnimation = animation().loadImg(images).changePosition(ele,positions).repeat(2).then(
            function(){}
        );
    demoAnimation.start(80)

animation's People

Watchers

 avatar  avatar

Forkers

rkweb

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.