Makes sure each animation tick has the same timestamp for all animations in the batch.

This commit is contained in:
jaubourg 2011-04-07 05:07:20 +02:00
parent b7dd8404c5
commit 75a4bc4a4e

17
src/effects.js vendored
View file

@ -11,7 +11,17 @@ var elemdisplay = {},
[ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ], [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
// opacity animations // opacity animations
[ "opacity" ] [ "opacity" ]
]; ],
fxNow;
function clearFxNow() {
fxNow = undefined;
}
function createFxNow() {
setTimeout( clearFxNow, 0 );
return ( fxNow = jQuery.now() );
}
jQuery.fn.extend({ jQuery.fn.extend({
show: function( speed, easing, callback ) { show: function( speed, easing, callback ) {
@ -349,7 +359,7 @@ jQuery.fx.prototype = {
var self = this, var self = this,
fx = jQuery.fx; fx = jQuery.fx;
this.startTime = jQuery.now(); this.startTime = fxNow || createFxNow();
this.start = from; this.start = from;
this.end = to; this.end = to;
this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" ); this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
@ -394,7 +404,8 @@ jQuery.fx.prototype = {
// Each step of an animation // Each step of an animation
step: function( gotoEnd ) { step: function( gotoEnd ) {
var t = jQuery.now(), done = true; var t = fxNow || createFxNow(),
done = true;
if ( gotoEnd || t >= this.options.duration + this.startTime ) { if ( gotoEnd || t >= this.options.duration + this.startTime ) {
this.now = this.end; this.now = this.end;