]> source.dussan.org Git - jquery.git/commitdiff
use requestAnimationFrame instead of setInterval for animations, when available.
authorlouisremi <louisremi@louisremi-laptop.(none)>
Mon, 31 Jan 2011 17:57:23 +0000 (18:57 +0100)
committertimmywil <tim.willison@thisismedium.com>
Mon, 4 Apr 2011 19:46:37 +0000 (15:46 -0400)
src/effects.js
src/support.js

index d9e9a8b3137bfb51b2f065dda34ed2591ba07375..a41efc2824c4b118d2dce06b9cd427b718b6d093 100644 (file)
@@ -363,7 +363,9 @@ jQuery.fx.prototype = {
                t.elem = this.elem;
 
                if ( t() && jQuery.timers.push(t) && !timerId ) {
-                       timerId = setInterval(fx.tick, fx.interval);
+                       jQuery.support.requestAnimationFrame ?
+                               window[jQuery.support.requestAnimationFrame](fx.tick):
+                               timerId = setInterval(fx.tick, fx.interval);
                }
        },
 
@@ -468,6 +470,8 @@ jQuery.extend( jQuery.fx, {
 
                if ( !timers.length ) {
                        jQuery.fx.stop();
+               } else if ( jQuery.support.requestAnimationFrame ) {
+                       window[jQuery.support.requestAnimationFrame](this);
                }
        },
 
index 4c309562f7c17c6a7d17ebfd1c2a5a24af514c5b..6d33186824c874f9e29882439eec07df23c9ff85 100644 (file)
                // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
                optSelected: opt.selected,
 
+               // Verify requestAnimationFrame mechanism existence
+               // use the prefixed name as the value
+               requestAnimationFrame: mozRequestAnimationFrame ?
+                       'mozRequestAnimationFrame' :
+                       webkitRequestAnimationFrame ?
+                               'webkitRequestAnimationFrame' :
+                               false,
+
                // Will be defined later
                deleteExpando: true,
                optDisabled: false,