(function( jQuery ) {
var elemdisplay = {},
- iframe = null,
++ iframe = null,
+ iframeDoc = null,
rfxtypes = /^(?:toggle|show|hide)$/,
rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
timerId,
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame;
- // Animations created synchronously will run synchronously
- function createFxNow() {
- setTimeout( clearFxNow, 0 );
- return ( fxNow = jQuery.now() );
- }
-
--function clearFxNow() {
-- fxNow = undefined;
- }
-
- // Try to restore the default display value of an element
- // fails if a display rule has been set for this element, e.g. div { display: inline; }
- function defaultDisplay( nodeName ) {
- if ( !elemdisplay[ nodeName ] ) {
- var elem = jQuery("<" + nodeName + ">").appendTo("body"),
- display = elem.css("display");
-
- elem.remove();
-
- if ( display === "none" || display === "" ) {
- display = "block";
- }
-
- elemdisplay[ nodeName ] = display;
- }
-
- return elemdisplay[ nodeName ];
--}
-
- // Generate parameters to create a standard animation
- function genFx( type, num ) {
- var obj = {};
-
- jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
- obj[ this ] = type;
- });
--
- return obj;
-function createFxNow() {
- setTimeout( clearFxNow, 0 );
- return ( fxNow = jQuery.now() );
--}
--
jQuery.fn.extend({
show: function( speed, easing, callback ) {
var elem, display;
jQuery._mark( this );
}
- var opt = jQuery.extend({}, optall), p,
+ var opt = jQuery.extend({}, optall),
isElement = this.nodeType === 1,
hidden = isElement && jQuery(this).is(":hidden"),
- self = this,
- self = this;
+ name, val, p,
+ easing, display, e,
+ parts, start, end, unit;
+
+ // will store per property easing and be used to determine when an animation is complete
+ opt.animatedProperties = {};
for ( p in prop ) {
- var name = jQuery.camelCase( p );
+ // property name normalization
+ name = jQuery.camelCase( p );
if ( p !== name ) {
prop[ name ] = prop[ p ];
delete prop[ p ];
p = name;
}
- if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
+ val = prop[p];
+
+ if ( val === "hide" && hidden || val === "show" && !hidden ) {
- return opt.complete.call(self);
- }
-
- if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
return opt.complete.call(this);
}
this.style.overflow = "hidden";
}
- opt.curAnim = jQuery.extend({}, prop);
+ for ( p in prop ) {
- e = new jQuery.fx( self, opt, p );
++ e = new jQuery.fx( this, opt, p );
- jQuery.each( prop, function( name, val ) {
- var e = new jQuery.fx( self, opt, name );
+ val = prop[p];
if ( rfxtypes.test(val) ) {
- e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
+ e[ val === "toggle" ? hidden ? "show" : "hide" : val ]();
} else {
- var parts = rfxnum.exec(val),
- start = e.cur();
+ parts = rfxnum.exec(val);
+ start = e.cur();
if ( parts ) {
- var end = parseFloat( parts[2] ),
- unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
+ end = parseFloat( parts[2] );
+ unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
// We need to compute starting value
if ( unit !== "px" ) {
- jQuery.style( self, p, (end || 1) + unit);
- jQuery.style( self, name, (end || 1) + unit);
++ jQuery.style( this, p, (end || 1) + unit);
start = ((end || 1) / e.cur()) * start;
- jQuery.style( self, p, start + unit);
- jQuery.style( self, name, start + unit);
++ jQuery.style( this, p, start + unit);
}
// If a +=/-= token was provided, we're doing a relative animation
// Each step of an animation
step: function( gotoEnd ) {
var t = fxNow || createFxNow(),
- done = true;
+ done = true,
+ elem = this.elem,
- options = this.options;
++ options = this.options,
++ i, n;
- if ( gotoEnd || t >= this.options.duration + this.startTime ) {
+ if ( gotoEnd || t >= options.duration + this.startTime ) {
this.now = this.end;
this.pos = this.state = 1;
this.update();
- this.options.curAnim[ this.prop ] = true;
+ options.animatedProperties[ this.prop ] = true;
- for ( var i in options.animatedProperties ) {
- for ( var i in this.options.curAnim ) {
- if ( this.options.curAnim[i] !== true ) {
++ for ( i in options.animatedProperties ) {
+ if ( options.animatedProperties[i] !== true ) {
done = false;
}
}
return false;
} else {
- var n = t - this.startTime;
- this.state = n / this.options.duration;
-
- // Perform the easing function, defaults to swing
- var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
- var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
- this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
- this.now = this.start + ((this.end - this.start) * this.pos);
+ // classical easing cannot be used with an Infinity duration
+ if ( options.duration == Infinity ) {
+ this.now = t;
+ } else {
- var n = t - this.startTime;
++ n = t - this.startTime;
+ this.state = n / options.duration;
+ // Perform the easing function, defaults to swing
+ this.pos = jQuery.easing[options.animatedProperties[this.prop]](this.state, n, 0, 1, options.duration);
+ this.now = this.start + ((this.end - this.start) * this.pos);
+ }
// Perform the next step of the animation
this.update();
}
jQuery.extend( jQuery.fx, {
tick: function() {
-- var timers = jQuery.timers;
--
-- for ( var i = 0; i < timers.length; i++ ) {
++ var timers = jQuery.timers,
++ i = timers.length;
++ while ( i-- ) {
if ( !timers[i]() ) {
-- timers.splice(i--, 1);
++ timers.splice(i, 1);
}
}
};
}
-
++// Try to restore the default display value of an element
+ function defaultDisplay( nodeName ) {
+
+ if ( !elemdisplay[ nodeName ] ) {
+
+ var elem = jQuery( "<" + nodeName + ">" ).appendTo( "body" ),
+ display = elem.css( "display" );
+
+ elem.remove();
+
+ if ( display === "none" || display === "" ) {
+
+ // Get element's real default display by attaching it to a temp iframe
+ // Conritbutions from Louis Remi and Julian Aurbourg
+ // based on recommendation by Louis Remi
++
+ // No iframe to use yet, so create it
+ if ( !iframe ) {
+ iframe = document.createElement( "iframe" );
+ iframe.frameBorder = iframe.width = iframe.height = 0;
+ }
+
+ document.body.appendChild( iframe );
+
+ // Create a cacheable copy of the iframe document on first call.
+ // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake html
+ // document to it, Webkit & Firefox won't allow reusing the iframe document
+ if ( !iframeDoc || !iframe.createElement ) {
+ iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
+ iframeDoc.write( "<!doctype><html><body></body></html>" );
+ }
+
+ elem = iframeDoc.createElement( nodeName );
+
+ iframeDoc.body.appendChild( elem );
+
+ display = jQuery.css( elem, "display" );
+
+ document.body.removeChild( iframe );
+ }
+
+ // Store the correct default display
+ elemdisplay[ nodeName ] = display;
+ }
+
+ return elemdisplay[ nodeName ];
+ }
+
++// Animations created synchronously will run synchronously
++function createFxNow() {
++ setTimeout( clearFxNow, 0 );
++ return ( fxNow = jQuery.now() );
++}
++
++function clearFxNow() {
++ fxNow = undefined;
++}
++
++// Generate parameters to create a standard animation
++function genFx( type, num ) {
++ var obj = {};
+
++ jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
++ obj[ this ] = type;
++ });
++
++ return obj;
++}
+
})( jQuery );