Fix for #1214, #1216, #1234 (problem with animations). In a nutshell, the callback...
[jquery.git] / src / fx / fx.js
index af89e93..51e8157 100644 (file)
@@ -307,16 +307,15 @@ jQuery.fn.extend({
         */
        animate: function( prop, speed, easing, callback ) {
                return this.queue(function(){
-                       var hidden = jQuery(this).is(":hidden");
+                       var hidden = jQuery(this).is(":hidden"),
+                               opt = jQuery.speed(speed, easing, callback),
+                               self = this;
                        
                        for ( var p in prop )
-                               if ( prop[p] == "hide" && hidden ||
-                                       prop[p] == "show" && !hidden )
-                                               return;
+                               if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
+                                       return jQuery.isFunction(opt.complete) && opt.complete.apply(this);
                
                        this.curAnim = jQuery.extend({}, prop);
-                       var opt = jQuery.speed(speed, easing, callback);
-                       var self = this;
                        
                        jQuery.each( prop, function(name, val){
                                var e = new jQuery.fx( self, opt, name );
@@ -558,7 +557,7 @@ jQuery.extend({
                                var p = n / options.duration;
                                
                                // Perform the easing function, defaults to swing
-                               z.now = jQuery.easing[options.easing](p, n,  firstNum, (lastNum-firstNum), options.duration);
+                               z.now = jQuery.easing[options.easing](p, n, firstNum, (lastNum-firstNum), options.duration);
 
                                // Perform the next step of the animation
                                z.a();