]> source.dussan.org Git - jquery.git/commitdiff
first tick should not occur immediatly; no tick should happen after a stop()
authorlouisremi <louisremi@louisremi-laptop.(none)>
Wed, 2 Feb 2011 10:25:09 +0000 (11:25 +0100)
committertimmywil <tim.willison@thisismedium.com>
Mon, 4 Apr 2011 19:46:37 +0000 (15:46 -0400)
+ comments

src/effects.js

index 12b87bd4eb2bc27a5c87db5c4343309a9aa2ae52..e5a10295ca91cea4237fd06ba482c117404157ae 100644 (file)
@@ -363,17 +363,16 @@ jQuery.fx.prototype = {
                t.elem = this.elem;
 
                if ( t() && jQuery.timers.push(t) && !timerId ) {
-                       if ( jQuery.support.requestAnimationFrame ) {
-                               timerId = true;
-                               (function raf() {
+                       // Use requestAnimationFrame instead of setInterval if available
+                       ( timerId = jQuery.support.requestAnimationFrame ) ?
+                               window[timerId](function raf() {
+                                       // timerId will be true as long as the animation hasn't been stopped
                                        if (timerId) {
-                                               window[jQuery.support.requestAnimationFrame](raf);
+                                               window[timerId](raf);
+                                               fx.tick();
                                        }
-                                       fx.tick();
-                               })();
-                       } else {
+                               }):
                                timerId = setInterval(fx.tick, fx.interval);
-                       }
                }
        },