Added support for comma-separated .is(), touched up the test cases. Resolves #977.
[jquery.git] / src / fx / fx.js
index f67747f..59cdcea 100644 (file)
@@ -143,7 +143,7 @@ jQuery.fn.extend({
         * @see slideToggle(String|Number,Function)
         */
        slideDown: function(speed,callback){
-               return this.animate({height: "show"}, speed, callback);
+               return this.filter(":hidden").animate({height: "show"}, speed, callback).end();
        },
        
        /**
@@ -168,7 +168,7 @@ jQuery.fn.extend({
         * @see slideToggle(String|Number,Function)
         */
        slideUp: function(speed,callback){
-               return this.animate({height: "hide"}, speed, callback);
+               return this.filter(":visible").animate({height: "hide"}, speed, callback).end();
        },
 
        /**
@@ -222,7 +222,7 @@ jQuery.fn.extend({
         * @see fadeTo(String|Number,Number,Function)
         */
        fadeIn: function(speed, callback){
-               return this.animate({opacity: "show"}, speed, callback);
+               return this.filter(":hidden").animate({opacity: "show"}, speed, callback).end();
        },
        
        /**
@@ -248,7 +248,7 @@ jQuery.fn.extend({
         * @see fadeTo(String|Number,Number,Function)
         */
        fadeOut: function(speed, callback){
-               return this.animate({opacity: "hide"}, speed, callback);
+               return this.filter(":visible").animate({opacity: "hide"}, speed, callback).end();
        },
        
        /**
@@ -400,6 +400,8 @@ jQuery.extend({
                }
        },
 
+       timers: [],
+
        /*
         * I originally wrote fx() as a clone of moo.fx and in the process
         * of making it small in size the code became illegible to sane
@@ -452,9 +454,20 @@ jQuery.extend({
                        z.now = from;
                        z.a();
 
-                       z.timer = setInterval(function(){
-                               z.step(from, to);
-                       }, 13);
+                       jQuery.timers.push(function(){
+                               return z.step(from, to);
+                       });
+
+                       if ( jQuery.timers.length == 1 ) {
+                               var timer = setInterval(function(){
+                                       jQuery.timers = jQuery.grep( jQuery.timers, function(fn){
+                                               return fn();
+                                       });
+
+                                       if ( !jQuery.timers.length )
+                                               clearInterval( timer );
+                               }, 13);
+                       }
                };
 
                // Simple 'show' function
@@ -462,7 +475,7 @@ jQuery.extend({
                        if ( !elem.orig ) elem.orig = {};
 
                        // Remember where we started, so that we can go back to it later
-                       elem.orig[prop] = elem.style[prop];
+                       elem.orig[prop] = jQuery.attr( elem.style, prop );
 
                        options.show = true;
 
@@ -479,7 +492,7 @@ jQuery.extend({
                        if ( !elem.orig ) elem.orig = {};
 
                        // Remember where we started, so that we can go back to it later
-                       elem.orig[prop] = elem.style[prop];
+                       elem.orig[prop] = jQuery.attr( elem.style, prop );
 
                        options.hide = true;
 
@@ -492,7 +505,7 @@ jQuery.extend({
                        if ( !elem.orig ) elem.orig = {};
 
                        // Remember where we started, so that we can go back to it later
-                       elem.orig[prop] = this.style[prop];
+                       elem.orig[prop] = jQuery.attr( elem.style, prop );
 
                        if(oldDisplay == "none")  {
                                options.show = true;
@@ -516,10 +529,6 @@ jQuery.extend({
                        var t = (new Date()).getTime();
 
                        if (t > options.duration + z.startTime) {
-                               // Stop the timer
-                               clearInterval(z.timer);
-                               z.timer = null;
-
                                z.now = lastNum;
                                z.a();
 
@@ -555,6 +564,8 @@ jQuery.extend({
                                if ( done && jQuery.isFunction( options.complete ) )
                                        // Execute the complete function
                                        options.complete.apply( elem );
+
+                               return false;
                        } else {
                                var n = t - this.startTime;
                                // Figure out where in the animation we are and set the number
@@ -569,6 +580,8 @@ jQuery.extend({
                                // Perform the next step of the animation
                                z.a();
                        }
+
+                       return true;
                };
        
        }