loopyJS requestAnimationFrame的polyfill和包装器,为动画和计时循环提供通用功能
NPM: $ npm install loopyjs
构建
确保你安装了grunt-cli:$ npm install
$ grunt build
用法
循环一段代码,1000ms后取消循环
var animation = loopy( function ( deltaTime , timeElapsed ) {
//deltaTime: time since last loop
//timeElapsed: time since looping started
if (timeElapsed >= 1000) {
animation.cancel();
}
//your loop code here
});
暂无评论