X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Ffx%2Ffx.js;h=f53b2b29e5ed243c53f64af41c8b5e97c419316c;hb=8b683b891f2cfd299c1d0708bb41ea26393ea417;hp=ceeb6d13f5b6d7288325cb935ee961d87ab0824e;hpb=9b5363b9eb197515e31589894c945dfd70b8b93b;p=jquery.git diff --git a/src/fx/fx.js b/src/fx/fx.js index ceeb6d1..f53b2b2 100644 --- a/src/fx/fx.js +++ b/src/fx/fx.js @@ -110,9 +110,13 @@ jQuery.fn.extend({ toggle: function( fn, fn2 ){ return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? this._toggle( fn, fn2 ) : - this.animate({ - height: "toggle", width: "toggle", opacity: "toggle" - }, fn, fn2); + fn ? + this.animate({ + height: "toggle", width: "toggle", opacity: "toggle" + }, fn, fn2) : + this.each(function(){ + jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ](); + }); }, /** @@ -295,28 +299,27 @@ jQuery.fn.extend({ * @example $("p").animate({ * opacity: 'show' * }, "slow", "easein"); - * @desc An example of using an 'easing' function to provide a different style of animation. This will only work if you have a plugin that provides this easing function (Only 'linear' is provided by default, with jQuery). + * @desc An example of using an 'easing' function to provide a different style of animation. This will only work if you have a plugin that provides this easing function (Only "swing" and "linear" are provided by default, with jQuery). * * @name animate * @type jQuery * @param Hash params A set of style attributes that you wish to animate, and to what end. * @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). - * @param String easing (optional) The name of the easing effect that you want to use (e.g. swing or linear). Defaults to "swing". + * @param String easing (optional) The name of the easing effect that you want to use (e.g. "swing" or "linear"). Defaults to "swing". * @param Function callback (optional) A function to be executed whenever the animation completes. * @cat Effects */ 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 +561,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();