Skip to content

Instantly share code, notes, and snippets.

@iamntz
Created August 6, 2011 05:26
Show Gist options
  • Save iamntz/1129043 to your computer and use it in GitHub Desktop.
Save iamntz/1129043 to your computer and use it in GitHub Desktop.
jquery request animation frame example
if ( t() && jQuery.timers.push(t) && !timerId ) {
// Use requestAnimationFrame instead of setInterval if available
if ( requestAnimationFrame ) {
timerId = true;
raf = function() {
// When timerId gets set to null at any point, this stops
if ( timerId ) {
requestAnimationFrame( raf );
fx.tick();
}
};
requestAnimationFrame( raf );
} else {
timerId = setInterval( fx.tick, fx.interval );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment