Style edits, code reductions, and optimizations for the effects module
This commit is contained in:
parent
d66c3b6d84
commit
51aa9c5f32
2 changed files with 55 additions and 54 deletions
27
src/effects.js
vendored
27
src/effects.js
vendored
|
@ -140,8 +140,7 @@ jQuery.fn.extend({
|
|||
var opt = jQuery.extend( {}, optall ),
|
||||
isElement = this.nodeType === 1,
|
||||
hidden = isElement && jQuery(this).is(":hidden"),
|
||||
name, val, p,
|
||||
display, e,
|
||||
name, val, p, e,
|
||||
parts, start, end, unit;
|
||||
|
||||
// will store per property easing and be used to determine when an animation is complete
|
||||
|
@ -182,25 +181,18 @@ jQuery.fn.extend({
|
|||
// animated
|
||||
if ( jQuery.css( this, "display" ) === "inline" &&
|
||||
jQuery.css( this, "float" ) === "none" ) {
|
||||
if ( !jQuery.support.inlineBlockNeedsLayout ) {
|
||||
this.style.display = "inline-block";
|
||||
|
||||
} else {
|
||||
display = defaultDisplay( this.nodeName );
|
||||
|
||||
// inline-level elements accept inline-block;
|
||||
// block-level elements need to be inline with layout
|
||||
if ( display === "inline" ) {
|
||||
if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) {
|
||||
this.style.display = "inline-block";
|
||||
|
||||
} else {
|
||||
this.style.display = "inline";
|
||||
this.style.zoom = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( opt.overflow != null ) {
|
||||
this.style.overflow = "hidden";
|
||||
|
@ -396,11 +388,10 @@ jQuery.fx.prototype = {
|
|||
raf;
|
||||
|
||||
this.startTime = fxNow || createFxNow();
|
||||
this.start = from;
|
||||
this.end = to;
|
||||
this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
|
||||
this.now = this.start;
|
||||
this.now = this.start = from;
|
||||
this.pos = this.state = 0;
|
||||
this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
|
||||
|
||||
function t( gotoEnd ) {
|
||||
return self.step( gotoEnd );
|
||||
|
@ -553,7 +544,7 @@ jQuery.extend( jQuery.fx, {
|
|||
|
||||
_default: function( fx ) {
|
||||
if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
|
||||
fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
|
||||
fx.elem.style[ fx.prop ] = fx.now + fx.unit;
|
||||
} else {
|
||||
fx.elem[ fx.prop ] = fx.now;
|
||||
}
|
||||
|
@ -561,6 +552,14 @@ jQuery.extend( jQuery.fx, {
|
|||
}
|
||||
});
|
||||
|
||||
// Adds width/height step functions
|
||||
// Do not set anything below 0
|
||||
jQuery.each([ "width", "height" ], function( i, prop ) {
|
||||
jQuery.fx.step[ prop ] = function( fx ) {
|
||||
jQuery.style( fx.elem, prop, Math.max(0, fx.now) );
|
||||
};
|
||||
});
|
||||
|
||||
if ( jQuery.expr && jQuery.expr.filters ) {
|
||||
jQuery.expr.filters.animated = function( elem ) {
|
||||
return jQuery.grep(jQuery.timers, function( fn ) {
|
||||
|
|
22
src/queue.js
22
src/queue.js
|
@ -4,15 +4,15 @@ function handleQueueMarkDefer( elem, type, src ) {
|
|||
var deferDataKey = type + "defer",
|
||||
queueDataKey = type + "queue",
|
||||
markDataKey = type + "mark",
|
||||
defer = jQuery.data( elem, deferDataKey, undefined, true );
|
||||
defer = jQuery._data( elem, deferDataKey );
|
||||
if ( defer &&
|
||||
( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
|
||||
( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
|
||||
( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
|
||||
( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
|
||||
// Give room for hard-coded callbacks to fire first
|
||||
// and eventually mark/queue something else on the element
|
||||
setTimeout( function() {
|
||||
if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
|
||||
!jQuery.data( elem, markDataKey, undefined, true ) ) {
|
||||
if ( !jQuery._data( elem, queueDataKey ) &&
|
||||
!jQuery._data( elem, markDataKey ) ) {
|
||||
jQuery.removeData( elem, deferDataKey, true );
|
||||
defer.resolve();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ jQuery.extend({
|
|||
_mark: function( elem, type ) {
|
||||
if ( elem ) {
|
||||
type = (type || "fx") + "mark";
|
||||
jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
|
||||
jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -38,9 +38,9 @@ jQuery.extend({
|
|||
if ( elem ) {
|
||||
type = type || "fx";
|
||||
var key = type + "mark",
|
||||
count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
|
||||
count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
|
||||
if ( count ) {
|
||||
jQuery.data( elem, key, count, true );
|
||||
jQuery._data( elem, key, count );
|
||||
} else {
|
||||
jQuery.removeData( elem, key, true );
|
||||
handleQueueMarkDefer( elem, type, "mark" );
|
||||
|
@ -49,13 +49,15 @@ jQuery.extend({
|
|||
},
|
||||
|
||||
queue: function( elem, type, data ) {
|
||||
var q;
|
||||
if ( elem ) {
|
||||
type = (type || "fx") + "queue";
|
||||
var q = jQuery.data( elem, type, undefined, true );
|
||||
q = jQuery._data( elem, type );
|
||||
|
||||
// Speed up dequeue by getting out quickly if this is just a lookup
|
||||
if ( data ) {
|
||||
if ( !q || jQuery.isArray(data) ) {
|
||||
q = jQuery.data( elem, type, jQuery.makeArray(data), true );
|
||||
q = jQuery._data( elem, type, jQuery.makeArray(data) );
|
||||
} else {
|
||||
q.push( data );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue