From 783f134aaa333b9e8795c701d8fd741de387cb0e Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 10 May 2011 16:25:08 -0500 Subject: effects: Updating bounce/pulsate/shake to fire callbacks before the next anim starts --- ui/jquery.effects.bounce.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'ui/jquery.effects.bounce.js') diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js index bb386a4f4..9e1117ce9 100644 --- a/ui/jquery.effects.bounce.js +++ b/ui/jquery.effects.bounce.js @@ -79,10 +79,8 @@ $.effects.effect.bounce = function(o) { upAnim = {}; upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; - // add the finish callback to the last animation if we aren't hiding el.animate( upAnim, speed, easing ) - .animate( downAnim, speed, easing, - ( ( i === times - 1 ) && !hide ) ? finish : undefined ); + .animate( downAnim, speed, easing ); distance = hide ? distance * 2 : distance / 2; } @@ -92,24 +90,25 @@ $.effects.effect.bounce = function(o) { upAnim = { opacity: 0 }; upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; - el.animate( upAnim, speed, easing, function(){ - el.hide(); - finish(); - }); + el.animate( upAnim, speed, easing ); } - - function finish() { + + el.queue( function( next ) { + if ( hide ) { + el.hide(); + } $.effects.restore( el, props ); $.effects.removeWrapper( el ); if ( o.complete ) { o.complete.apply( el[ 0 ] ); } - } + next(); + }); // inject all the animations we just queued to be first in line (after "inprogress") if ( queuelen > 1) { queue.splice.apply( queue, - [ 1, 0 ].concat( queue.splice( queuelen, anims ) ) ); + [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); } next(); -- cgit v1.2.3