]> source.dussan.org Git - jquery-ui.git/commitdiff
effects: Updating bounce/pulsate/shake to fire callbacks before the next anim starts 242/head
authorgnarf <gnarf@gnarf.net>
Tue, 10 May 2011 21:25:08 +0000 (16:25 -0500)
committergnarf <gnarf@gnarf.net>
Tue, 10 May 2011 21:25:08 +0000 (16:25 -0500)
ui/jquery.effects.bounce.js
ui/jquery.effects.pulsate.js
ui/jquery.effects.shake.js

index bb386a4f4da83da4f0a65e7a8910de1f6273f403..9e1117ce982c95a889b8cbd5fc3ee599813ddef3 100644 (file)
@@ -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();
 
index 54c5c10af40b20a6a0df723823aab0b42408ea6d..a0ddf51fd93a57139760c8d6f4da09c26b573631 100644 (file)
@@ -43,19 +43,22 @@ $.effects.effect.pulsate = function( o ) {
 
                elem.animate({
                        opacity: animateTo
-               }, duration, o.easing, function() {
+               }, duration, o.easing);
+
+               elem.queue( function( next ) {
                        if ( hide ) {
                                elem.hide();
                        }
                        if ( o.complete ) {
                                o.complete.apply( this );
                        }
+                       next();
                });
 
                // We just queued up "anims" animations, we need to put them next in the queue
                if ( queuelen > 1) {
                        queue.splice.apply( queue,
-                               [ 1, 0 ].concat( queue.splice( queuelen, anims ) ) );
+                               [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
                }
                next();
        });
index cd26dc5afdcc058caa61e6eeef88123942997ece..550329ca40871992479f68ed13bea57c1adc447c 100644 (file)
@@ -54,20 +54,21 @@ $.effects.effect.shake = function( o ) {
                };
                el
                        .animate( animation1, speed, o.easing )
-                       .animate( animation, speed / 2, o.easing, function() {
+                       .animate( animation, speed / 2, o.easing )
+                       .queue( function( next ) {
                                if ( mode === "hide" ) {
                                        el.hide();
                                }
-                               // Last shake
                                $.effects.restore( el, props );
                                $.effects.removeWrapper( el );
                                $.isFunction( o.complete ) && o.complete.apply( this, arguments );
+                               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 ) ) );
                }
                el.dequeue();
        });