Skip to content

Instantly share code, notes, and snippets.

@qzm
Last active April 27, 2016 11:31
Show Gist options
  • Save qzm/a72688ab772ae8c50a80d728fc7417cb to your computer and use it in GitHub Desktop.
Save qzm/a72688ab772ae8c50a80d728fc7417cb to your computer and use it in GitHub Desktop.
requestAnimationFrame and cancelAnimationFrame
// requestAnimationFrame
window.requestAnimationFrame =
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback) {
setTimeout(callback, 1000 / 60);
};
//cancelAnimationFrame
window.cancelAnimationFrame =
window.cancelAnimationFrame ||
window.webkitCancelAnimationFrame ||
window.mozCancelAnimationFrame ||
window.oCancelAnimationFrame ||
window.msCancelAnimationFrame ||
window.clearTimeout;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment