X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Ffx.js;h=3404ddbcd95cd8df7e72f58be4dcc557eee65b93;hb=20a7bff4019a93fd7cee04897effd49af8be4de4;hp=64cfbc62525123464d6c570772d27d9887375169;hpb=d36382e9a3fa604597d400d1084a2424f0d3eb80;p=jquery.git diff --git a/src/fx.js b/src/fx.js index 64cfbc6..3404ddb 100644 --- a/src/fx.js +++ b/src/fx.js @@ -35,7 +35,7 @@ jQuery.fn.extend({ toggle: function( fn, fn2 ){ return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? - this._toggle( fn, fn2 ) : + this._toggle.apply( this, arguments ) : fn ? this.animate({ height: "toggle", width: "toggle", opacity: "toggle" @@ -76,12 +76,12 @@ jQuery.fn.extend({ if ( this.nodeType != 1) return false; - var opt = jQuery.extend({}, optall); - var hidden = jQuery(this).is(":hidden"), self = this; + var opt = jQuery.extend({}, optall), p, + hidden = jQuery(this).is(":hidden"), self = this; - for ( var p in prop ) { + for ( p in prop ) { if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) - return jQuery.isFunction(opt.complete) && opt.complete.apply(this); + return jQuery.isFunction(opt.complete) && opt.complete.call(this); if ( p == "height" || p == "width" ) { // Store display property @@ -148,7 +148,7 @@ jQuery.fn.extend({ queue(this, type).push( fn ); if ( queue(this, type).length == 1 ) - fn.apply(this); + fn.call(this); } }); }, @@ -180,17 +180,16 @@ jQuery.fn.extend({ }); var queue = function( elem, type, array ) { - if ( !elem ) - return undefined; - - type = type || "fx"; - - var q = jQuery.data( elem, type + "queue" ); - - if ( !q || array ) - q = jQuery.data( elem, type + "queue", - array ? jQuery.makeArray(array) : [] ); + if ( elem ){ + + type = type || "fx"; + + var q = jQuery.data( elem, type + "queue" ); + + if ( !q || array ) + q = jQuery.data( elem, type + "queue", jQuery.makeArray(array) ); + } return q; }; @@ -203,7 +202,7 @@ jQuery.fn.dequeue = function(type){ q.shift(); if ( q.length ) - q[0].apply( this ); + q[0].call( this ); }); }; @@ -219,7 +218,7 @@ jQuery.extend({ opt.duration = (opt.duration && opt.duration.constructor == Number ? opt.duration : - { slow: 600, fast: 200 }[opt.duration]) || 400; + jQuery.fx.speeds[opt.duration]) || jQuery.fx.speeds.def; // Queueing opt.old = opt.complete; @@ -227,7 +226,7 @@ jQuery.extend({ if ( opt.queue !== false ) jQuery(this).dequeue(); if ( jQuery.isFunction( opt.old ) ) - opt.old.apply( this ); + opt.old.call( this ); }; return opt; @@ -261,7 +260,7 @@ jQuery.fx.prototype = { // Simple function for setting a style value update: function(){ if ( this.options.step ) - this.options.step.apply( this.elem, [ this.now, this ] ); + this.options.step.call( this.elem, this.now, this ); (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); @@ -281,7 +280,7 @@ jQuery.fx.prototype = { // Start an animation from one number to another custom: function(from, to, unit){ - this.startTime = (new Date()).getTime(); + this.startTime = now(); this.start = from; this.end = to; this.unit = unit || this.unit || "px"; @@ -344,7 +343,7 @@ jQuery.fx.prototype = { // Each step of an animation step: function(gotoEnd){ - var t = (new Date()).getTime(); + var t = now(); if ( gotoEnd || t > this.options.duration + this.startTime ) { this.now = this.end; @@ -382,7 +381,7 @@ jQuery.fx.prototype = { // If a callback was provided, execute it if ( done && jQuery.isFunction( this.options.complete ) ) // Execute the complete function - this.options.complete.apply( this.elem ); + this.options.complete.call( this.elem ); return false; } else { @@ -402,20 +401,28 @@ jQuery.fx.prototype = { }; -jQuery.fx.step = { - scrollLeft: function(fx){ - fx.elem.scrollLeft = fx.now; - }, - - scrollTop: function(fx){ - fx.elem.scrollTop = fx.now; - }, - - opacity: function(fx){ - jQuery.attr(fx.elem.style, "opacity", fx.now); +jQuery.extend( jQuery.fx, { + speeds:{ + slow: 600, + fast: 200, + // Default speed + def: 400 }, - - _default: function(fx){ - fx.elem.style[ fx.prop ] = fx.now + fx.unit; + step: { + scrollLeft: function(fx){ + fx.elem.scrollLeft = fx.now; + }, + + scrollTop: function(fx){ + fx.elem.scrollTop = fx.now; + }, + + opacity: function(fx){ + jQuery.attr(fx.elem.style, "opacity", fx.now); + }, + + _default: function(fx){ + fx.elem.style[ fx.prop ] = fx.now + fx.unit; + } } -}; +});