Merge branch '8101_lrbabe_requestAnimationFrame' of https://github.com/timmywil/jquery into timmywil-8101_lrbabe_requestAnimationFrame
Conflicts: src/effects.js
This commit is contained in:
commit
56ffad2dad
23
src/effects.js
vendored
23
src/effects.js
vendored
|
@ -12,7 +12,10 @@ var elemdisplay = {},
|
||||||
// opacity animations
|
// opacity animations
|
||||||
[ "opacity" ]
|
[ "opacity" ]
|
||||||
],
|
],
|
||||||
fxNow;
|
fxNow,
|
||||||
|
requestAnimationFrame = window.webkitRequestAnimationFrame ||
|
||||||
|
window.mozRequestAnimationFrame ||
|
||||||
|
window.oRequestAnimationFrame;
|
||||||
|
|
||||||
function clearFxNow() {
|
function clearFxNow() {
|
||||||
fxNow = undefined;
|
fxNow = undefined;
|
||||||
|
@ -357,7 +360,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 = fxNow || createFxNow();
|
this.startTime = fxNow || createFxNow();
|
||||||
this.start = from;
|
this.start = from;
|
||||||
|
@ -373,7 +377,20 @@ jQuery.fx.prototype = {
|
||||||
t.elem = this.elem;
|
t.elem = this.elem;
|
||||||
|
|
||||||
if ( t() && jQuery.timers.push(t) && !timerId ) {
|
if ( t() && jQuery.timers.push(t) && !timerId ) {
|
||||||
timerId = setInterval(fx.tick, fx.interval);
|
// Use requestAnimationFrame instead of setInterval if available
|
||||||
|
if ( requestAnimationFrame ) {
|
||||||
|
timerId = 1;
|
||||||
|
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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue