X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=fx%2Ffx.js;h=df59d781c24accabc42fe34eb542141ccfa87d2a;hb=aa5c4d8828bd8956218ccca47ee7a029fe26008e;hp=71764c0a01cb6429f39c2ec0af0059e47ebe9864;hpb=9477c418dbf50f2341dec7c02f60ab3d77da5378;p=jquery.git diff --git a/fx/fx.js b/fx/fx.js index 71764c0..df59d78 100644 --- a/fx/fx.js +++ b/fx/fx.js @@ -20,7 +20,7 @@ jQuery.fn.extend({ }, speed, callback) : this._show(); }, - // We're overwriting the old hide method + // Overwrite the old hide method _hide: jQuery.fn.hide, /** @@ -87,7 +87,7 @@ jQuery.fn.extend({ if ( prop[p].constructor == Number ) e.custom( e.cur(), prop[p] ); else - e[ prop[p] ](); + e[ prop[p] ]( prop ); } }); }, @@ -121,12 +121,31 @@ jQuery.fn.extend({ jQuery.extend({ setAuto: function(e,p) { + if ( e.notAuto ) return; + + if ( p == "height" && e.scrollHeight != parseInt(jQuery.curCSS(e,p)) ) return; + if ( p == "width" && e.scrollWidth != parseInt(jQuery.curCSS(e,p)) ) return; + + // Remember the original height var a = e.style[p]; - var o = jQuery.css(e,p); - e.style[p] = "auto"; - var n = jQuery.css(e,p); - if ( o != n ) + + // Figure out the size of the height right now + var o = jQuery.curCSS(e,p,1); + + if ( p == "height" && e.scrollHeight != o || + p == "width" && e.scrollWidth != o ) return; + + // Set the height to auto + e.style[p] = e.currentStyle ? "" : "auto"; + + // See what the size of "auto" is + var n = jQuery.curCSS(e,p,1); + + // Revert back to the original size + if ( o != n && n != "auto" ) { e.style[p] = a; + e.notAuto = true; + } }, speed: function(s,o,i) { @@ -164,8 +183,7 @@ jQuery.extend({ // Get next function var f = elem.queue[type][0]; - if ( f ) - f.apply( elem ); + if ( f ) f.apply( elem ); } }, @@ -197,19 +215,23 @@ jQuery.extend({ if (z.now == 1) z.now = 0.9999; if (window.ActiveXObject) y.filter = "alpha(opacity=" + z.now*100 + ")"; - y.opacity = z.now; - } else - y[prop] = z.now+"px"; + else + y.opacity = z.now; + + // My hate for IE will never die + } else if ( parseInt(z.now) ) + y[prop] = parseInt(z.now) + "px"; + y.display = "block"; }; // Figure out the maximum number to run to z.max = function(){ - return z.el["orig"+prop] || z.cur(); + return parseFloat( jQuery.css(z.el,prop) ); }; // Get the current size z.cur = function(){ - return parseFloat( jQuery.css(z.el,prop) ); + return parseFloat( jQuery.curCSS(z.el, prop) ) || z.max(); }; // Start an animation from one number to another @@ -224,30 +246,43 @@ jQuery.extend({ }; // Simple 'show' function - z.show = function(){ - y.display = "block"; - z.o.auto = true; - z.custom(0,z.max()); + z.show = function( p ){ + if ( !z.el.orig ) z.el.orig = {}; + + // Remember where we started, so that we can go back to it later + z.el.orig[prop] = this.cur(); + + z.custom( 0, z.el.orig[prop] ); + + // Stupid IE, look what you made me do + if ( prop != "opacity" ) + y[prop] = "1px"; }; // Simple 'hide' function z.hide = function(){ + if ( !z.el.orig ) z.el.orig = {}; + // Remember where we started, so that we can go back to it later - z.el["orig"+prop] = this.cur(); - + z.el.orig[prop] = this.cur(); + + z.o.hide = true; + // Begin the animation z.custom(z.cur(),0); }; - // IE has trouble with opacity if it doesn't have layout + // IE has trouble with opacity if it does not have layout if ( jQuery.browser.msie && !z.el.currentStyle.hasLayout ) - y.zoom = 1; + y.zoom = "1"; // Remember the overflow of the element - z.oldOverflow = y.overflow; + if ( !z.el.oldOverlay ) + z.el.oldOverflow = jQuery.css( z.el, "overflow" ); // Make sure that nothing sneaks out - y.overflow = "hidden"; + if ( z.el.oldOverlay == "visible" ) + y.overflow = "hidden"; // Each step of an animation z.step = function(firstNum, lastNum){ @@ -257,30 +292,28 @@ jQuery.extend({ // Stop the timer clearInterval(z.timer); z.timer = null; - + z.now = lastNum; z.a(); + + // Hide the element if the "hide" operation was done + if ( z.o.hide ) y.display = 'none'; // Reset the overflow - y.overflow = z.oldOverflow; - - // If the element was shown, and not using a custom number, - // set its height and/or width to auto - if ( (prop == "height" || prop == "width") && z.o.auto ) - jQuery.setAuto( z.el, prop ); - + y.overflow = z.el.oldOverflow; + // If a callback was provided, execute it - if( z.o.complete && z.o.complete.constructor == Function ) { - - // Yes, this is a weird place for this, but it needs to be executed - // only once per cluster of effects. - // If the element is, effectively, hidden - hide it - if ( y.height == "0px" || y.width == "0px" ) - y.display = "none"; - + if( z.o.complete && z.o.complete.constructor == Function ) // Execute the complete function z.o.complete.apply( z.el ); - } + + // Reset the property, if the item has been hidden + if ( z.o.hide ) + y[ prop ] = z.el.orig[ prop ].constructor == Number && prop != "opacity" ? + z.el.orig[prop] + "px" : z.el.orig[prop]; + + // set its height and/or width to auto + jQuery.setAuto( z.el, prop ); } else { // Figure out where in the animation we are and set the number var p = (t - this.startTime) / z.o.duration;