Last active
December 22, 2015 00:18
-
-
Save toruta39/6387908 to your computer and use it in GitHub Desktop.
Normalize requestAnimationFrame
This file contains 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
// Normalize requestAnimationFrame | |
var fps = 30; | |
var requestAnimationFrame = window.requestAnimationFrame || | |
window.mozRequestAnimationFrame || | |
window.webkitRequestAnimationFrame || | |
window.msRequestAnimationFrame || | |
function (callback) { | |
return setTimeout(callback, 1000 / fps); | |
}; | |
var cancelAnimationFrame = window.cancelAnimationFrame || | |
window.mozCancelAnimationFrame || | |
window.webkitCancelAnimationFrame || | |
window.msCancelAnimationFrame || | |
function (timer) { | |
return clearTimeout(timer); | |
}; | |
window.requestAnimationFrame = requestAnimationFrame; | |
window.cancelAnimationFrame = cancelAnimationFrame; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment