Improved the categories of a bunch of docs, upped the version to 1.1.
[jquery.git] / src / fx / fx.js
index 1dfd31e..6f7f9d1 100644 (file)
@@ -4,33 +4,25 @@ jQuery.fn.extend({
        _show: jQuery.fn.show,\r
        \r
        /**\r
-        * Show all matched elements using a graceful animation.\r
+        * Show all matched elements using a graceful animation and firing an\r
+        * optional callback after completion.\r
+        *\r
         * The height, width, and opacity of each of the matched elements \r
         * are changed dynamically according to the specified speed.\r
         *\r
         * @example $("p").show("slow");\r
         *\r
-        * @name show\r
-        * @type jQuery\r
-        * @param Object speed 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).\r
-        * @cat Effects/Animations\r
-        */\r
-        \r
-       /**\r
-        * Show all matched elements using a graceful animation and firing a callback\r
-        * function after completion.\r
-        * The height, width, and opacity of each of the matched elements \r
-        * are changed dynamically according to the specified speed.\r
-        *\r
         * @example $("p").show("slow",function(){\r
         *   alert("Animation Done.");\r
         * });\r
         *\r
         * @name show\r
         * @type jQuery\r
-        * @param Object speed 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).\r
-        * @param Function callback A function to be executed whenever the animation completes.\r
-        * @cat Effects/Animations\r
+        * @param String|Number speed 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).\r
+        * @param Function callback (optional) A function to be executed whenever the animation completes.\r
+        * @param String easing (optional) easing effect\r
+        * @cat Effects\r
+        * @see hide(String|Number,Function)\r
         */\r
        show: function(speed,callback){\r
                return speed ? this.animate({\r
@@ -42,33 +34,25 @@ jQuery.fn.extend({
        _hide: jQuery.fn.hide,\r
        \r
        /**\r
-        * Hide all matched elements using a graceful animation.\r
+        * Hide all matched elements using a graceful animation and firing an\r
+        * optional callback after completion.\r
+        *\r
         * The height, width, and opacity of each of the matched elements \r
         * are changed dynamically according to the specified speed.\r
         *\r
         * @example $("p").hide("slow");\r
         *\r
-        * @name hide\r
-        * @type jQuery\r
-        * @param Object speed 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).\r
-        * @cat Effects/Animations\r
-        */\r
-        \r
-       /**\r
-        * Hide all matched elements using a graceful animation and firing a callback\r
-        * function after completion.\r
-        * The height, width, and opacity of each of the matched elements \r
-        * are changed dynamically according to the specified speed.\r
-        *\r
         * @example $("p").hide("slow",function(){\r
         *   alert("Animation Done.");\r
         * });\r
         *\r
         * @name hide\r
         * @type jQuery\r
-        * @param Object speed 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).\r
-        * @param Function callback A function to be executed whenever the animation completes.\r
-        * @cat Effects/Animations\r
+        * @param String|Number speed 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).\r
+        * @param Function callback (optional) A function to be executed whenever the animation completes.\r
+        * @param String easing (optional) easing effect\r
+        * @cat Effects\r
+        * @see show(String|Number,Function)\r
         */\r
        hide: function(speed,callback){\r
                return speed ? this.animate({\r
@@ -77,101 +61,80 @@ jQuery.fn.extend({
        },\r
        \r
        /**\r
-        * Reveal all matched elements by adjusting their height.\r
+        * Reveal all matched elements by adjusting their height and firing an\r
+        * optional callback after completion.\r
+        *\r
         * Only the height is adjusted for this animation, causing all matched\r
         * elements to be revealed in a "sliding" manner.\r
         *\r
         * @example $("p").slideDown("slow");\r
         *\r
-        * @name slideDown\r
-        * @type jQuery\r
-        * @param Object speed 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).\r
-        * @cat Effects/Animations\r
-        */\r
-        \r
-       /**\r
-        * Reveal all matched elements by adjusting their height and firing a callback\r
-        * function after completion.\r
-        * Only the height is adjusted for this animation, causing all matched\r
-        * elements to be revealed in a "sliding" manner.\r
-        *\r
         * @example $("p").slideDown("slow",function(){\r
         *   alert("Animation Done.");\r
         * });\r
         *\r
         * @name slideDown\r
         * @type jQuery\r
-        * @param Object speed 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).\r
-        * @param Function callback A function to be executed whenever the animation completes.\r
-        * @cat Effects/Animations\r
+        * @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).\r
+        * @param Function callback (optional) A function to be executed whenever the animation completes.\r
+        * @param String easing (optional) easing effect\r
+        * @cat Effects\r
+        * @see slideUp(String|Number,Function)\r
+        * @see slideToggle(String|Number,Function)\r
         */\r
        slideDown: function(speed,callback){\r
                return this.animate({height: "show"}, speed, callback);\r
        },\r
        \r
        /**\r
-        * Hide all matched elements by adjusting their height.\r
+        * Hide all matched elements by adjusting their height and firing an\r
+        * optional callback after completion.\r
+        *\r
         * Only the height is adjusted for this animation, causing all matched\r
         * elements to be hidden in a "sliding" manner.\r
         *\r
         * @example $("p").slideUp("slow");\r
         *\r
-        * @name slideUp\r
-        * @type jQuery\r
-        * @param Object speed 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).\r
-        * @cat Effects/Animations\r
-        */\r
-        \r
-       /**\r
-        * Hide all matched elements by adjusting their height and firing a callback\r
-        * function after completion.\r
-        * Only the height is adjusted for this animation, causing all matched\r
-        * elements to be hidden in a "sliding" manner.\r
-        *\r
         * @example $("p").slideUp("slow",function(){\r
         *   alert("Animation Done.");\r
         * });\r
         *\r
         * @name slideUp\r
         * @type jQuery\r
-        * @param Object speed 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).\r
-        * @param Function callback A function to be executed whenever the animation completes.\r
-        * @cat Effects/Animations\r
+        * @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).\r
+        * @param Function callback (optional) A function to be executed whenever the animation completes.\r
+        * @param String easing (optional) easing effect\r
+        * @cat Effects\r
+        * @see slideDown(String|Number,Function)\r
+        * @see slideToggle(String|Number,Function)\r
         */\r
        slideUp: function(speed,callback){\r
                return this.animate({height: "hide"}, speed, callback);\r
        },\r
 \r
        /**\r
-        * Toggle the visibility of all matched elements by adjusting their height.\r
+        * Toggle the visibility of all matched elements by adjusting their height and firing an\r
+        * optional callback after completion.\r
+        *\r
         * Only the height is adjusted for this animation, causing all matched\r
         * elements to be hidden in a "sliding" manner.\r
         *\r
         * @example $("p").slideToggle("slow");\r
         *\r
-        * @name slideToggle\r
-        * @type jQuery\r
-        * @param Object speed 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).\r
-        * @cat Effects/Animations\r
-        */\r
-        \r
-       /**\r
-        * Toggle the visibility of all matched elements by adjusting their height\r
-        * and firing a callback function after completion.\r
-        * Only the height is adjusted for this animation, causing all matched\r
-        * elements to be hidden in a "sliding" manner.\r
-        *\r
         * @example $("p").slideToggle("slow",function(){\r
         *   alert("Animation Done.");\r
         * });\r
         *\r
         * @name slideToggle\r
         * @type jQuery\r
-        * @param Object speed 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).\r
-        * @param Function callback A function to be executed whenever the animation completes.\r
-        * @cat Effects/Animations\r
+        * @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).\r
+        * @param Function callback (optional) A function to be executed whenever the animation completes.\r
+        * @param String easing (optional) easing effect\r
+        * @cat Effects\r
+        * @see slideDown(String|Number,Function)\r
+        * @see slideUp(String|Number,Function)\r
         */\r
-       slideToggle: function(speed,callback){\r
+       slideToggle: function(speed, callback){\r
                return this.each(function(){\r
                        var state = jQuery(this).is(":hidden") ? "show" : "hide";\r
                        jQuery(this).animate({height: state}, speed, callback);\r
@@ -179,107 +142,82 @@ jQuery.fn.extend({
        },\r
        \r
        /**\r
-        * Fade in all matched elements by adjusting their opacity.\r
+        * Fade in all matched elements by adjusting their opacity and firing an\r
+        * optional callback after completion.\r
+        *\r
         * Only the opacity is adjusted for this animation, meaning that\r
         * all of the matched elements should already have some form of height\r
         * and width associated with them.\r
         *\r
         * @example $("p").fadeIn("slow");\r
         *\r
-        * @name fadeIn\r
-        * @type jQuery\r
-        * @param Object speed 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).\r
-        * @cat Effects/Animations\r
-        */\r
-        \r
-       /**\r
-        * Fade in all matched elements by adjusting their opacity and firing a \r
-        * callback function after completion.\r
-        * Only the opacity is adjusted for this animation, meaning that\r
-        * all of the matched elements should already have some form of height\r
-        * and width associated with them.\r
-        *\r
         * @example $("p").fadeIn("slow",function(){\r
         *   alert("Animation Done.");\r
         * });\r
         *\r
         * @name fadeIn\r
         * @type jQuery\r
-        * @param Object speed 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).\r
-        * @param Function callback A function to be executed whenever the animation completes.\r
-        * @cat Effects/Animations\r
+        * @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).\r
+        * @param Function callback (optional) A function to be executed whenever the animation completes.\r
+        * @param String easing (optional) easing effect\r
+        * @cat Effects\r
+        * @see fadeOut(String|Number,Function)\r
+        * @see fadeTo(String|Number,Number,Function)\r
         */\r
-       fadeIn: function(speed,callback){\r
+       fadeIn: function(speed, callback){\r
                return this.animate({opacity: "show"}, speed, callback);\r
        },\r
        \r
        /**\r
-        * Fade out all matched elements by adjusting their opacity.\r
+        * Fade out all matched elements by adjusting their opacity and firing an\r
+        * optional callback after completion.\r
+        *\r
         * Only the opacity is adjusted for this animation, meaning that\r
         * all of the matched elements should already have some form of height\r
         * and width associated with them.\r
         *\r
         * @example $("p").fadeOut("slow");\r
         *\r
-        * @name fadeOut\r
-        * @type jQuery\r
-        * @param Object speed 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).\r
-        * @cat Effects/Animations\r
-        */\r
-        \r
-       /**\r
-        * Fade out all matched elements by adjusting their opacity and firing a \r
-        * callback function after completion.\r
-        * Only the opacity is adjusted for this animation, meaning that\r
-        * all of the matched elements should already have some form of height\r
-        * and width associated with them.\r
-        *\r
         * @example $("p").fadeOut("slow",function(){\r
         *   alert("Animation Done.");\r
         * });\r
         *\r
         * @name fadeOut\r
         * @type jQuery\r
-        * @param Object speed 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).\r
-        * @param Function callback A function to be executed whenever the animation completes.\r
-        * @cat Effects/Animations\r
+        * @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).\r
+        * @param Function callback (optional) A function to be executed whenever the animation completes.\r
+        * @param String easing (optional) easing effect\r
+        * @cat Effects\r
+        * @see fadeIn(String|Number,Function)\r
+        * @see fadeTo(String|Number,Number,Function)\r
         */\r
-       fadeOut: function(speed,callback){\r
+       fadeOut: function(speed, callback){\r
                return this.animate({opacity: "hide"}, speed, callback);\r
        },\r
        \r
        /**\r
-        * Fade the opacity of all matched elements to a specified opacity.\r
+        * Fade the opacity of all matched elements to a specified opacity and firing an\r
+        * optional callback after completion.\r
+        *\r
         * Only the opacity is adjusted for this animation, meaning that\r
         * all of the matched elements should already have some form of height\r
         * and width associated with them.\r
         *\r
         * @example $("p").fadeTo("slow", 0.5);\r
         *\r
-        * @name fadeTo\r
-        * @type jQuery\r
-        * @param Object speed 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).\r
-        * @param Number opacity The opacity to fade to (a number from 0 to 1).\r
-        * @cat Effects/Animations\r
-        */\r
-        \r
-       /**\r
-        * Fade the opacity of all matched elements to a specified opacity and \r
-        * firing a callback function after completion.\r
-        * Only the opacity is adjusted for this animation, meaning that\r
-        * all of the matched elements should already have some form of height\r
-        * and width associated with them.\r
-        *\r
         * @example $("p").fadeTo("slow", 0.5, function(){\r
         *   alert("Animation Done.");\r
         * });\r
         *\r
         * @name fadeTo\r
         * @type jQuery\r
-        * @param Object speed 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).\r
+        * @param String|Number speed 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).\r
         * @param Number opacity The opacity to fade to (a number from 0 to 1).\r
-        * @param Function callback A function to be executed whenever the animation completes.\r
-        * @cat Effects/Animations\r
+        * @param Function callback (optional) A function to be executed whenever the animation completes.\r
+        * @param String easing (optional) easing effect\r
+        * @cat Effects\r
+        * @see fadeIn(String|Number,Function)\r
+        * @see fadeOut(String|Number,Function)\r
         */\r
        fadeTo: function(speed,to,callback){\r
                return this.animate({opacity: to}, speed, callback);\r
@@ -308,17 +246,19 @@ jQuery.fn.extend({
         * @name animate\r
         * @type jQuery\r
         * @param Hash params A set of style attributes that you wish to animate, and to what end.\r
-        * @param Object speed 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).\r
-        * @param Function callback A function to be executed whenever the animation completes.\r
-        * @cat Effects/Animations\r
+        * @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).\r
+        * @param Function callback (optional) A function to be executed whenever the animation completes.\r
+        * @param String easing (optional) easing effect\r
+        * @cat Effects\r
         */\r
-       animate: function(prop,speed,callback) {\r
+       animate: function( prop, speed, easing, callback ) {\r
                return this.queue(function(){\r
                \r
-                       this.curAnim = prop;\r
+                       this.curAnim = jQuery.extend({}, prop);
+                       var opt = jQuery.speed(speed, easing, callback);\r
                        \r
                        for ( var p in prop ) {\r
-                               var e = new jQuery.fx( this, jQuery.speed(speed,callback), p );\r
+                               var e = new jQuery.fx( this, opt, p );\r
                                if ( prop[p].constructor == Number )\r
                                        e.custom( e.cur(), prop[p] );\r
                                else\r
@@ -355,54 +295,31 @@ jQuery.fn.extend({
 });\r
 \r
 jQuery.extend({\r
-\r
-       setAuto: function(e,p) {\r
-               if ( e.notAuto ) return;\r
-\r
-               if ( p == "height" && e.scrollHeight != parseInt(jQuery.curCSS(e,p)) ) return;\r
-               if ( p == "width" && e.scrollWidth != parseInt(jQuery.curCSS(e,p)) ) return;\r
-\r
-               // Remember the original height\r
-               var a = e.style[p];\r
-\r
-               // Figure out the size of the height right now\r
-               var o = jQuery.curCSS(e,p,1);\r
-\r
-               if ( p == "height" && e.scrollHeight != o ||\r
-                       p == "width" && e.scrollWidth != o ) return;\r
-\r
-               // Set the height to auto\r
-               e.style[p] = e.currentStyle ? "" : "auto";\r
-\r
-               // See what the size of "auto" is\r
-               var n = jQuery.curCSS(e,p,1);\r
-\r
-               // Revert back to the original size\r
-               if ( o != n && n != "auto" ) {\r
-                       e.style[p] = a;\r
-                       e.notAuto = true;\r
-               }\r
-       },\r
        \r
-       speed: function(s,o) {\r
-               o = o || {};\r
-               \r
-               if ( o.constructor == Function )\r
-                       o = { complete: o };\r
-               \r
-               var ss = { slow: 600, fast: 200 };\r
-               o.duration = (s && s.constructor == Number ? s : ss[s]) || 400;\r
+       speed: function(speed, easing, fn) {\r
+               var opt = speed.constructor == Object ? speed : {
+                       complete: fn || !fn && easing || 
+                               speed.constructor == Function && speed,
+                       duration: speed,
+                       easing: fn && easing || easing && easing.constructor != Function && easing
+               };
+\r
+               opt.duration = (opt.duration.constructor == Number ? 
+                       opt.duration : 
+                       { slow: 600, fast: 200 }[opt.duration]) || 400;\r
        \r
                // Queueing\r
-               o.oldComplete = o.complete;\r
-               o.complete = function(){\r
+               opt.oldComplete = opt.complete;\r
+               opt.complete = function(){\r
                        jQuery.dequeue(this, "fx");\r
-                       if ( o.oldComplete && o.oldComplete.constructor == Function )\r
-                               o.oldComplete.apply( this );\r
+                       if ( opt.oldComplete && opt.oldComplete.constructor == Function )\r
+                               opt.oldComplete.apply( this );\r
                };\r
        \r
-               return o;\r
-       },\r
+               return opt;\r
+       },
+       
+       easing: {},\r
        \r
        queue: {},\r
        \r
@@ -427,106 +344,111 @@ jQuery.extend({
         */\r
        \r
        fx: function( elem, options, prop ){\r
-       \r
+\r
                var z = this;\r
-       \r
-               // The users options\r
-               z.o = {\r
-                       duration: options.duration || 400,\r
-                       complete: options.complete,\r
-                       step: options.step\r
-               };\r
-       \r
-               // The element\r
-               z.el = elem;\r
-       \r
+\r
                // The styles\r
-               var y = z.el.style;\r
-       \r
+               var y = elem.style;\r
+               \r
+               // Store display property\r
+               var oldDisplay = jQuery.css(elem, 'display');\r
+               // Set display property to block for animation\r
+               y.display = "block";\r
+               // Make sure that nothing sneaks out\r
+               y.overflow = "hidden";\r
+\r
                // Simple function for setting a style value\r
                z.a = function(){\r
                        if ( options.step )\r
                                options.step.apply( elem, [ z.now ] );\r
 \r
-                       if ( prop == "opacity" ) {\r
-                               if (jQuery.browser.mozilla && z.now == 1) z.now = 0.9999;\r
-                               if (window.ActiveXObject)\r
-                                       y.filter = "alpha(opacity=" + z.now*100 + ")";\r
-                               else\r
-                                       y.opacity = z.now;\r
-\r
-                       // My hate for IE will never die\r
-                       } else if ( parseInt(z.now) )\r
+                       if ( prop == "opacity" )\r
+                               jQuery.attr(y, "opacity", z.now); // Let attr handle opacity\r
+                       else if ( parseInt(z.now) ) // My hate for IE will never die\r
                                y[prop] = parseInt(z.now) + "px";\r
-                               \r
-                       y.display = "block";\r
                };\r
-       \r
+\r
                // Figure out the maximum number to run to\r
                z.max = function(){\r
-                       return parseFloat( jQuery.css(z.el,prop) );\r
+                       return parseFloat( jQuery.css(elem,prop) );\r
                };\r
-       \r
+\r
                // Get the current size\r
                z.cur = function(){\r
-                       var r = parseFloat( jQuery.curCSS(z.el, prop) );\r
+                       var r = parseFloat( jQuery.curCSS(elem, prop) );\r
                        return r && r > -10000 ? r : z.max();\r
                };\r
-       \r
+\r
                // Start an animation from one number to another\r
                z.custom = function(from,to){\r
                        z.startTime = (new Date()).getTime();\r
                        z.now = from;\r
                        z.a();\r
-       \r
+\r
                        z.timer = setInterval(function(){\r
                                z.step(from, to);\r
                        }, 13);\r
                };\r
-       \r
+\r
                // Simple 'show' function\r
-               z.show = function( p ){\r
-                       if ( !z.el.orig ) z.el.orig = {};\r
+               z.show = function(){\r
+                       if ( !elem.orig ) elem.orig = {};\r
 \r
                        // Remember where we started, so that we can go back to it later\r
-                       z.el.orig[prop] = this.cur();\r
+                       elem.orig[prop] = this.cur();\r
 \r
-                       z.custom( 0, z.el.orig[prop] );\r
+                       options.show = true;\r
+\r
+                       // Begin the animation\r
+                       z.custom(0, elem.orig[prop]);\r
 \r
                        // Stupid IE, look what you made me do\r
                        if ( prop != "opacity" )\r
                                y[prop] = "1px";\r
                };\r
-       \r
+\r
                // Simple 'hide' function\r
                z.hide = function(){\r
-                       if ( !z.el.orig ) z.el.orig = {};\r
+                       if ( !elem.orig ) elem.orig = {};\r
 \r
                        // Remember where we started, so that we can go back to it later\r
-                       z.el.orig[prop] = this.cur();\r
+                       elem.orig[prop] = this.cur();\r
 \r
-                       z.o.hide = true;\r
+                       options.hide = true;\r
 \r
                        // Begin the animation\r
-                       z.custom(z.el.orig[prop], 0);\r
+                       z.custom(elem.orig[prop], 0);\r
                };\r
-       \r
-               // IE has trouble with opacity if it does not have layout\r
-               if ( jQuery.browser.msie && !z.el.currentStyle.hasLayout )\r
-                       y.zoom = "1";\r
-       \r
-               // Remember  the overflow of the element\r
-               if ( !z.el.oldOverlay )\r
-                       z.el.oldOverflow = jQuery.css( z.el, "overflow" );\r
-       \r
-               // Make sure that nothing sneaks out\r
-               y.overflow = "hidden";\r
-       \r
+               \r
+               //Simple 'toggle' function\r
+               z.toggle = function() {\r
+                       if ( !elem.orig ) elem.orig = {};\r
+\r
+                       // Remember where we started, so that we can go back to it later\r
+                       elem.orig[prop] = this.cur();\r
+\r
+                       if(oldDisplay == 'none')  {\r
+                               options.show = true;\r
+                               \r
+                               // Stupid IE, look what you made me do\r
+                               if ( prop != "opacity" )\r
+                                       y[prop] = "1px";\r
+\r
+                               // Begin the animation\r
+                               z.custom(0, elem.orig[prop]);   \r
+                       } else {\r
+                               options.hide = true;\r
+\r
+                               // Begin the animation\r
+                               z.custom(elem.orig[prop], 0);\r
+                       }               \r
+               };\r
+\r
                // Each step of an animation\r
                z.step = function(firstNum, lastNum){\r
                        var t = (new Date()).getTime();\r
-       \r
-                       if (t > z.o.duration + z.startTime) {\r
+\r
+                       if (t > options.duration + z.startTime) {\r
                                // Stop the timer\r
                                clearInterval(z.timer);\r
                                z.timer = null;\r
@@ -534,47 +456,54 @@ jQuery.extend({
                                z.now = lastNum;\r
                                z.a();\r
 \r
-                               z.el.curAnim[ prop ] = true;\r
-                               \r
+                               if (elem.curAnim) elem.curAnim[ prop ] = true;\r
+\r
                                var done = true;\r
-                               for ( var i in z.el.curAnim )\r
-                                       if ( z.el.curAnim[i] !== true )\r
+                               for ( var i in elem.curAnim )\r
+                                       if ( elem.curAnim[i] !== true )\r
                                                done = false;\r
-                                               \r
+\r
                                if ( done ) {\r
                                        // Reset the overflow\r
-                                       y.overflow = z.el.oldOverflow;\r
-                               \r
+                                       y.overflow = '';\r
+                                       \r
+                                       // Reset the display\r
+                                       y.display = oldDisplay;\r
+                                       if (jQuery.css(elem, 'display') == 'none')\r
+                                               y.display = 'block';\r
+\r
                                        // Hide the element if the "hide" operation was done\r
-                                       if ( z.o.hide ) \r
+                                       if ( options.hide ) \r
                                                y.display = 'none';\r
-                                       \r
-                                       // Reset the property, if the item has been hidden\r
-                                       if ( z.o.hide ) {\r
-                                               for ( var p in z.el.curAnim ) {\r
-                                                       y[ p ] = z.el.orig[p] + ( p == "opacity" ? "" : "px" );\r
-       \r
-                                                       // set its height and/or width to auto\r
-                                                       if ( p == 'height' || p == 'width' )\r
-                                                               jQuery.setAuto( z.el, p );\r
-                                               }\r
-                                       }\r
+\r
+                                       // Reset the properties, if the item has been hidden or shown\r
+                                       if ( options.hide || options.show )\r
+                                               for ( var p in elem.curAnim )\r
+                                                       if (p == "opacity")\r
+                                                               jQuery.attr(y, p, elem.orig[p]);\r
+                                                       else\r
+                                                               y[p] = '';\r
                                }\r
 \r
                                // If a callback was provided, execute it\r
-                               if( done && z.o.complete && z.o.complete.constructor == Function )\r
+                               if ( done && options.complete && options.complete.constructor == Function )\r
                                        // Execute the complete function\r
-                                       z.o.complete.apply( z.el );\r
+                                       options.complete.apply( elem );\r
                        } else {\r
+                               var n = t - this.startTime;\r
                                // Figure out where in the animation we are and set the number\r
-                               var p = (t - this.startTime) / z.o.duration;\r
-                               z.now = ((-Math.cos(p*Math.PI)/2) + 0.5) * (lastNum-firstNum) + firstNum;\r
-       \r
+                               var p = n / options.duration;
+                               \r
+                               // If the easing function exists, then use it \r
+                               z.now = options.easing && jQuery.easing[options.easing] ?
+                                       jQuery.easing[options.easing](p, n,  firstNum, (lastNum-firstNum), options.duration) :
+                                       // else use default linear easing
+                                       ((-Math.cos(p*Math.PI)/2) + 0.5) * (lastNum-firstNum) + firstNum;\r
+\r
                                // Perform the next step of the animation\r
                                z.a();\r
                        }\r
                };\r
        \r
        }\r
-\r
-});\r
+});
\ No newline at end of file