* left: 50, opacity: 'show'
* }, 500);
*
- * @test stop();
- * var hash = {opacity: 'show'};
- * var hashCopy = $.extend({}, hash);
- * $('#foo').animate(hash, 'fast', function() {
- * ok( hash.opacity == hashCopy.opacity, 'Check if animate changed the hash parameter' );
- * start();
- * });
- *
* @name animate
* @type jQuery
* @param Hash params A set of style attributes that you wish to animate, and to what end.
// The styles
var y = z.el.style;
+
+ // Store display property
+ var oldDisplay = jQuery.css(z.el, 'display');
+ // Set display property to block for animation
+ y.display = "block";
+ // Make sure that nothing sneaks out
+ y.overflow = "hidden";
// Simple function for setting a style value
z.a = function(){
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";
};
// Figure out the maximum number to run to
// Begin the animation
z.custom(z.el.orig[prop], 0);
};
+
+ //Simple 'toggle' function
+ z.toggle = function() {
+ if ( !z.el.orig ) z.el.orig = {};
- // Make sure that nothing sneaks out
- y.overflow = "hidden";
+ // Remember where we started, so that we can go back to it later
+ z.el.orig[prop] = this.cur();
+
+ if(oldDisplay == 'none') {
+ z.o.show = true;
+
+ // Stupid IE, look what you made me do
+ if ( prop != "opacity" )
+ y[prop] = "1px";
+
+ // Begin the animation
+ z.custom(0, z.el.orig[prop]); \r
+ } else {
+ z.o.hide = true;
+
+ // Begin the animation
+ z.custom(z.el.orig[prop], 0);\r
+ } \r
+ };
// Each step of an animation
z.step = function(firstNum, lastNum){
if ( done ) {
// Reset the overflow
y.overflow = '';
+
+ // Reset the display
+ y.display = oldDisplay;
+ if (jQuery.css(z.el, 'display') == 'none')
+ y.display = 'block';
// Hide the element if the "hide" operation was done
if ( z.o.hide )
y.display = 'none';
- // Otherwise reset the display property
- else if ( z.o.show )
- y.display = '';
// Reset the properties, if the item has been hidden or shown
if ( z.o.hide || z.o.show )