Skip to content

Commit

Permalink
added a list that maintains removed animations by .finish and .stop. …
Browse files Browse the repository at this point in the history
…Handled repeated execution of animation in first tick. Fixes #3497.

corrected syntax error

Fixes #3497

Fixed. #3497
  • Loading branch information
preethi26 committed Jan 16, 2017
1 parent efdb8a4 commit ae094b1
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ jQuery.speed = function( speed, easing, fn ) {

return opt;
};

var lis = [];
jQuery.fn.extend( {
fadeTo: function( speed, to, easing, callback ) {

Expand Down Expand Up @@ -552,6 +552,7 @@ jQuery.fn.extend( {

timers[ index ].anim.stop( gotoEnd );
dequeue = false;
lis.push(index);
timers.splice( index, 1 );
}
}
Expand Down Expand Up @@ -590,6 +591,7 @@ jQuery.fn.extend( {
for ( index = timers.length; index--; ) {
if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
timers[ index ].anim.stop( true );
lis.push( index );
timers.splice( index, 1 );
}
}
Expand Down Expand Up @@ -631,15 +633,25 @@ jQuery.each( {
} );

jQuery.timers = [];
var oldLength = 0;
jQuery.fx.tick = function() {
var timer,
i = 0,
timers = jQuery.timers;

fxNow = jQuery.now();
oldLength = timers.length;
for ( ; i < old_length; i++ ) {
var removedTimers = 0;

for ( ; i < timers.length; i++ ) {
timer = timers[ i ];
for (var j = 0; j < lis.length; j++) {
if ( lis[ j ] <= i ) {
removeTimers++;
}
lis.splice( j, 1 );
}
i = i - removedTimers;
timer = timers[ i ];

// Checks the timer has not already been removed
if ( !timer() && timers[ i ] === timer ) {
Expand Down

0 comments on commit ae094b1

Please sign in to comment.