Last active
May 23, 2016 02:59
-
-
Save hustcc/17c89c7d54bcfd809a9c to your computer and use it in GitHub Desktop.
AnimationFrame can be used to do tasks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var frame_func = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(func) { | |
window.setTimeout(func, 1000 / 60); | |
}; | |
//帧动画,做定时任务 | |
//动画循环 | |
if (!window.requestAnimationFrame) { | |
window.requestAnimationFrame = (window.webkitRequestAnimationFrame || | |
window.mozRequestAnimationFrame || | |
window.msRequestAnimationFrame || | |
window.oRequestAnimationFrame || | |
function (callback) { | |
return window.setTimeout(callback, 17 /*~ 1000/60*/); | |
}); | |
} | |
//动画循环取消 | |
if (!window.cancelAnimationFrame) { | |
window.cancelAnimationFrame = (window.cancelRequestAnimationFrame || | |
window.webkitCancelAnimationFrame || window.webkitCancelRequestAnimationFrame || | |
window.mozCancelAnimationFrame || window.mozCancelRequestAnimationFrame || | |
window.msCancelAnimationFrame || window.msCancelRequestAnimationFrame || | |
window.oCancelAnimationFrame || window.oCancelRequestAnimationFrame || | |
window.clearTimeout); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment