X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Ffx%2Ffx.js;h=69885e8900c555303f27962f0cb38a648fd83bb9;hb=1ce8006d480ebd64350983a17be1cc2e3f043958;hp=ca861b6bdc2e766e3dedba1328216c80649501a6;hpb=e06b7447c2e8887549338b3b5f4fa9ed65fe9dcd;p=jquery.git diff --git a/src/fx/fx.js b/src/fx/fx.js index ca861b6..69885e8 100644 --- a/src/fx/fx.js +++ b/src/fx/fx.js @@ -368,6 +368,16 @@ jQuery.fn.extend({ if ( this.queue[type].length == 1 ) fn.apply(this); }); + }, + + stop: function(){ + var timers = jQuery.timers; + + return this.each(function(){ + for ( var i = 0; i < timers.length; i++ ) + if ( timers[i].elem == this ) + timers.splice(i--, 1); + }); } }); @@ -424,18 +434,10 @@ jQuery.extend({ timers: [], - /* - * I originally wrote fx() as a clone of moo.fx and in the process - * of making it small in size the code became illegible to sane - * people. You've been warned. - */ - fx: function( elem, options, prop ){ - var z = this; - - // The styles - var y = elem.style; + var z = this, y = elem.style, + isprop = elem[prop] != null && y[prop] == null; // Simple function for setting a style value z.a = function(){ @@ -445,7 +447,10 @@ jQuery.extend({ if ( prop == "opacity" ) jQuery.attr(y, "opacity", z.now); // Let attr handle opacity else { - y[prop] = parseInt(z.now) + "px"; + if ( isprop ) + elem[prop] = parseInt(z.now); + else + y[prop] = parseInt(z.now) + "px"; // Set display property to block for height/width animations if ( prop == "height" || prop == "width" ) @@ -460,6 +465,7 @@ jQuery.extend({ // Get the current size z.cur = function(){ + if ( isprop ) return elem[prop]; var r = parseFloat( jQuery.curCSS(elem, prop) ); return r && r > -10000 ? r : z.max(); }; @@ -470,9 +476,13 @@ jQuery.extend({ z.now = from; z.a(); - jQuery.timers.push(function(){ + function t(){ return z.step(from, to); - }); + } + + t.elem = elem; + + jQuery.timers.push(t); if ( jQuery.timers.length == 1 ) { var timer = setInterval(function(){