]> source.dussan.org Git - jquery.git/commitdiff
reduce impact of requestAnimationFrame on incompatible browsers by minimizing number...
authorlouisremi <louisremi@louisremi-laptop.(none)>
Wed, 2 Feb 2011 09:26:04 +0000 (10:26 +0100)
committertimmywil <tim.willison@thisismedium.com>
Mon, 4 Apr 2011 19:46:37 +0000 (15:46 -0400)
src/effects.js

index 6a72a88fd0ec72e737c9389fc16a8b2d50e8b4e2..12b87bd4eb2bc27a5c87db5c4343309a9aa2ae52 100644 (file)
@@ -363,9 +363,17 @@ jQuery.fx.prototype = {
                t.elem = this.elem;
 
                if ( t() && jQuery.timers.push(t) && !timerId ) {
-                       timerId = jQuery.support.requestAnimationFrame ?
-                               !window[jQuery.support.requestAnimationFrame](fx.tick):
-                               setInterval(fx.tick, fx.interval);
+                       if ( jQuery.support.requestAnimationFrame ) {
+                               timerId = true;
+                               (function raf() {
+                                       if (timerId) {
+                                               window[jQuery.support.requestAnimationFrame](raf);
+                                       }
+                                       fx.tick();
+                               })();
+                       } else {
+                               timerId = setInterval(fx.tick, fx.interval);
+                       }
                }
        },
 
@@ -470,8 +478,6 @@ jQuery.extend( jQuery.fx, {
 
                if ( !timers.length ) {
                        jQuery.fx.stop();
-               } else if ( jQuery.support.requestAnimationFrame && timerId) {
-                       window[jQuery.support.requestAnimationFrame](jQuery.fx.tick);
                }
        },