X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Ffx%2Ffx.js;h=a16b0a51b1d95663045cebd5e063622f47fa6220;hb=0d9920083bb2ed441bfbedd35107abf58216d9ff;hp=d83bf0dd431075fcdbe5428ca76ec3ba4e756819;hpb=6de5275687cabf1016649899407c9cfb26d4ed70;p=jquery.git diff --git a/src/fx/fx.js b/src/fx/fx.js index d83bf0d..a16b0a5 100644 --- a/src/fx/fx.js +++ b/src/fx/fx.js @@ -112,11 +112,12 @@ jQuery.fn.extend({ * @cat Effects */ toggle: function( fn, fn2 ){ - return fn ? + var args = arguments; + return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? this._toggle( fn, fn2 ) : this.each(function(){ jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ] - .apply( jQuery(this), arguments ); + .apply( jQuery(this), args ); }); }, @@ -278,15 +279,18 @@ jQuery.fn.extend({ }, /** - * A function for making your own, custom, animations. The key aspect of + * A function for making your own, custom animations. The key aspect of * this function is the object of style properties that will be animated, * and to what end. Each key within the object represents a style property * that will also be animated (for example: "height", "top", or "opacity"). * + * Note that properties should be specified using camel case + * eg. marginLeft instead of margin-left. + * * The value associated with the key represents to what end the property * will be animated. If a number is provided as the value, then the style * property will be transitioned from its current state to that new number. - * Oterwise if the string "hide", "show", or "toggle" is provided, a default + * Otherwise if the string "hide", "show", or "toggle" is provided, a default * animation will be constructed for that property. * * @example $("p").animate({ @@ -358,7 +362,7 @@ jQuery.extend({ speed: function(speed, easing, fn) { var opt = speed && speed.constructor == Object ? speed : { complete: fn || !fn && easing || - speed && speed.constructor == Function && speed, + jQuery.isFunction( speed ) && speed, duration: speed, easing: fn && easing || easing && easing.constructor != Function && easing }; @@ -368,11 +372,11 @@ jQuery.extend({ { slow: 600, fast: 200 }[opt.duration]) || 400; // Queueing - opt.oldComplete = opt.complete; + opt.old = opt.complete; opt.complete = function(){ jQuery.dequeue(this, "fx"); - if ( opt.oldComplete && opt.oldComplete.constructor == Function ) - opt.oldComplete.apply( this ); + if ( jQuery.isFunction( opt.old ) ) + opt.old.apply( this ); }; return opt; @@ -410,9 +414,8 @@ jQuery.extend({ var y = elem.style; // Store display property - var oldDisplay = jQuery.css(elem, 'display'); - // Set display property to block for animation - y.display = "block"; + var oldDisplay = jQuery.css(elem, "display"); + // Make sure that nothing sneaks out y.overflow = "hidden"; @@ -425,6 +428,8 @@ jQuery.extend({ jQuery.attr(y, "opacity", z.now); // Let attr handle opacity else if ( parseInt(z.now) ) // My hate for IE will never die y[prop] = parseInt(z.now) + "px"; + + y.display = "block"; // Set display property to block for animation }; // Figure out the maximum number to run to @@ -486,7 +491,7 @@ jQuery.extend({ // Remember where we started, so that we can go back to it later elem.orig[prop] = this.cur(); - if(oldDisplay == 'none') { + if(oldDisplay == "none") { options.show = true; // Stupid IE, look what you made me do @@ -524,16 +529,16 @@ jQuery.extend({ if ( done ) { // Reset the overflow - y.overflow = ''; + y.overflow = ""; // Reset the display y.display = oldDisplay; - if (jQuery.css(elem, 'display') == 'none') - y.display = 'block'; + if (jQuery.css(elem, "display") == "none") + y.display = "block"; // Hide the element if the "hide" operation was done if ( options.hide ) - y.display = 'none'; + y.display = "none"; // Reset the properties, if the item has been hidden or shown if ( options.hide || options.show ) @@ -541,11 +546,11 @@ jQuery.extend({ if (p == "opacity") jQuery.attr(y, p, elem.orig[p]); else - y[p] = ''; + y[p] = ""; } // If a callback was provided, execute it - if ( done && options.complete && options.complete.constructor == Function ) + if ( done && jQuery.isFunction( options.complete ) ) // Execute the complete function options.complete.apply( elem ); } else {