Separate raf function definition from passing it to requestAnimationFrame

This commit is contained in:
timmywil 2011-04-10 17:17:34 -04:00
parent 9db18ddd84
commit 791402b453
2 changed files with 6 additions and 4 deletions

8
src/effects.js vendored
View file

@ -350,7 +350,8 @@ jQuery.fx.prototype = {
// Start an animation from one number to another // Start an animation from one number to another
custom: function( from, to, unit ) { custom: function( from, to, unit ) {
var self = this, var self = this,
fx = jQuery.fx; fx = jQuery.fx,
raf;
this.startTime = jQuery.now(); this.startTime = jQuery.now();
this.start = from; this.start = from;
@ -369,13 +370,14 @@ jQuery.fx.prototype = {
// Use requestAnimationFrame instead of setInterval if available // Use requestAnimationFrame instead of setInterval if available
if ( requestAnimationFrame ) { if ( requestAnimationFrame ) {
timerId = 1; timerId = 1;
requestAnimationFrame(function raf() { raf = function() {
// When timerId gets set to null at any point, this stops // When timerId gets set to null at any point, this stops
if ( timerId ) { if ( timerId ) {
requestAnimationFrame( raf ); requestAnimationFrame( raf );
fx.tick(); fx.tick();
} }
}); };
requestAnimationFrame( raf );
} else { } else {
timerId = setInterval( fx.tick, fx.interval ); timerId = setInterval( fx.tick, fx.interval );
} }

@ -1 +1 @@
Subproject commit f12b9309269ba7e705a99efe099f86ed1fe98d58 Subproject commit 80f2b81d1fbc13d62afb91cb87e1452fbbec1ef4