git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added a new .stop() method which stops all animations running on the matched set...
[jquery.git]
/
src
/
fx
/
fx.js
diff --git
a/src/fx/fx.js
b/src/fx/fx.js
index
3ad3dd5
..
69885e8
100644
(file)
--- a/
src/fx/fx.js
+++ b/
src/fx/fx.js
@@
-336,10
+336,13
@@
jQuery.fn.extend({
jQuery.each( prop, function(name, val){
var e = new jQuery.fx( self, opt, name );
if ( val.constructor == Number )
jQuery.each( prop, function(name, val){
var e = new jQuery.fx( self, opt, name );
if ( val.constructor == Number )
- e.custom( e.cur(), val );
+ e.custom( e.cur() || 0, val );
else
e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
});
else
e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
});
+
+ // For JS strict compliance
+ return true;
});
},
});
},
@@
-365,6
+368,16
@@
jQuery.fn.extend({
if ( this.queue[type].length == 1 )
fn.apply(this);
});
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);
+ });
}
});
}
});
@@
-421,18
+434,10
@@
jQuery.extend({
timers: [],
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 ){
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(){
// Simple function for setting a style value
z.a = function(){
@@
-442,7
+447,10
@@
jQuery.extend({
if ( prop == "opacity" )
jQuery.attr(y, "opacity", z.now); // Let attr handle opacity
else {
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" )
// Set display property to block for height/width animations
if ( prop == "height" || prop == "width" )
@@
-457,6
+465,7
@@
jQuery.extend({
// Get the current size
z.cur = function(){
// 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();
};
var r = parseFloat( jQuery.curCSS(elem, prop) );
return r && r > -10000 ? r : z.max();
};
@@
-467,9
+476,13
@@
jQuery.extend({
z.now = from;
z.a();
z.now = from;
z.a();
- jQuery.timers.push(function(){
+ function t(){
return z.step(from, to);
return z.step(from, to);
- });
+ }
+
+ t.elem = elem;
+
+ jQuery.timers.push(t);
if ( jQuery.timers.length == 1 ) {
var timer = setInterval(function(){
if ( jQuery.timers.length == 1 ) {
var timer = setInterval(function(){