Created
August 6, 2011 05:26
-
-
Save iamntz/1129043 to your computer and use it in GitHub Desktop.
jquery request animation frame example
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
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