Skip to content

Instantly share code, notes, and snippets.

@kangax
Forked from mrdoob/RequestAnimationFrame.js
Created February 22, 2011 16:38
Show Gist options
  • Save kangax/838935 to your computer and use it in GitHub Desktop.
Save kangax/838935 to your computer and use it in GitHub Desktop.
/**
* Provides requestAnimationFrame in a cross browser way.
* @author greggman / http://greggman.com/
*/
if (!window.requestAnimationFrame) {
window.requestAnimationFrame =
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback, element) { window.setTimeout(callback, 1000 / 60) };
}
@mathiasbynens
Copy link

Some relevant links:

It does seem to work nowadays. What changed? Does this code work fine as long as you bind the polyfilled property to window (since rAF is a member function of window, just like getElementById)?

cc @paulirish @jakearchibald

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment