/bower_components/jquery/src/effects.js |
@@ -1,44 +1,81 @@ |
define( [ |
define([ |
"./core", |
"./var/document", |
"./var/rcssNum", |
"./var/rnothtmlwhite", |
"./var/pnum", |
"./css/var/cssExpand", |
"./css/var/isHiddenWithinTree", |
"./css/var/swap", |
"./css/adjustCSS", |
"./data/var/dataPriv", |
"./css/showHide", |
"./css/var/isHidden", |
"./css/defaultDisplay", |
"./data/var/data_priv", |
|
"./core/init", |
"./effects/Tween", |
"./queue", |
"./css", |
"./deferred", |
"./traversing", |
"./manipulation", |
"./css", |
"./effects/Tween" |
], function( jQuery, document, rcssNum, rnothtmlwhite, cssExpand, isHiddenWithinTree, swap, |
adjustCSS, dataPriv, showHide ) { |
"./traversing" |
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, data_priv ) { |
|
"use strict"; |
|
var |
fxNow, timerId, |
rfxtypes = /^(?:toggle|show|hide)$/, |
rrun = /queueHooks$/; |
rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ), |
rrun = /queueHooks$/, |
animationPrefilters = [ defaultPrefilter ], |
tweeners = { |
"*": [ function( prop, value ) { |
var tween = this.createTween( prop, value ), |
target = tween.cur(), |
parts = rfxnum.exec( value ), |
unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), |
|
function raf() { |
if ( timerId ) { |
window.requestAnimationFrame( raf ); |
jQuery.fx.tick(); |
} |
} |
// Starting value computation is required for potential unit mismatches |
start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) && |
rfxnum.exec( jQuery.css( tween.elem, prop ) ), |
scale = 1, |
maxIterations = 20; |
|
if ( start && start[ 3 ] !== unit ) { |
// Trust units reported by jQuery.css |
unit = unit || start[ 3 ]; |
|
// Make sure we update the tween properties later on |
parts = parts || []; |
|
// Iteratively approximate from a nonzero starting point |
start = +target || 1; |
|
do { |
// If previous iteration zeroed out, double until we get *something*. |
// Use string for doubling so we don't accidentally see scale as unchanged below |
scale = scale || ".5"; |
|
// Adjust and apply |
start = start / scale; |
jQuery.style( tween.elem, prop, start + unit ); |
|
// Update scale, tolerating zero or NaN from tween.cur(), |
// break the loop if scale is unchanged or perfect, or if we've just had enough |
} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations ); |
} |
|
// Update tween properties |
if ( parts ) { |
start = tween.start = +start || +target || 0; |
tween.unit = unit; |
// If a +=/-= token was provided, we're doing a relative animation |
tween.end = parts[ 1 ] ? |
start + ( parts[ 1 ] + 1 ) * parts[ 2 ] : |
+parts[ 2 ]; |
} |
|
return tween; |
} ] |
}; |
|
// Animations created synchronously will run synchronously |
function createFxNow() { |
window.setTimeout( function() { |
setTimeout(function() { |
fxNow = undefined; |
} ); |
}); |
return ( fxNow = jQuery.now() ); |
} |
|
@@ -51,7 +88,7 @@ |
// If we include width, step value is 1 to do all cssExpand values, |
// otherwise step value is 2 to skip over Left and Right |
includeWidth = includeWidth ? 1 : 0; |
for ( ; i < 4; i += 2 - includeWidth ) { |
for ( ; i < 4 ; i += 2 - includeWidth ) { |
which = cssExpand[ i ]; |
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; |
} |
@@ -65,11 +102,11 @@ |
|
function createTween( value, prop, animation ) { |
var tween, |
collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), |
collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), |
index = 0, |
length = collection.length; |
for ( ; index < length; index++ ) { |
if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { |
if ( (tween = collection[ index ].call( animation, prop, value )) ) { |
|
// We're done with this property |
return tween; |
@@ -78,15 +115,15 @@ |
} |
|
function defaultPrefilter( elem, props, opts ) { |
var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, |
isBox = "width" in props || "height" in props, |
/* jshint validthis: true */ |
var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay, |
anim = this, |
orig = {}, |
style = elem.style, |
hidden = elem.nodeType && isHiddenWithinTree( elem ), |
dataShow = dataPriv.get( elem, "fxshow" ); |
hidden = elem.nodeType && isHidden( elem ), |
dataShow = data_priv.get( elem, "fxshow" ); |
|
// Queue-skipping animations hijack the fx hooks |
// Handle queue: false promises |
if ( !opts.queue ) { |
hooks = jQuery._queueHooks( elem, "fx" ); |
if ( hooks.unqueued == null ) { |
@@ -100,151 +137,113 @@ |
} |
hooks.unqueued++; |
|
anim.always( function() { |
|
anim.always(function() { |
// Ensure the complete handler is called before this completes |
anim.always( function() { |
anim.always(function() { |
hooks.unqueued--; |
if ( !jQuery.queue( elem, "fx" ).length ) { |
hooks.empty.fire(); |
} |
} ); |
} ); |
}); |
}); |
} |
|
// Detect show/hide animations |
for ( prop in props ) { |
value = props[ prop ]; |
if ( rfxtypes.test( value ) ) { |
delete props[ prop ]; |
toggle = toggle || value === "toggle"; |
if ( value === ( hidden ? "hide" : "show" ) ) { |
|
// Pretend to be hidden if this is a "show" and |
// there is still data from a stopped show/hide |
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { |
hidden = true; |
|
// Ignore all other no-op show/hide data |
} else { |
continue; |
} |
} |
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); |
} |
} |
|
// Bail out if this is a no-op like .hide().hide() |
propTween = !jQuery.isEmptyObject( props ); |
if ( !propTween && jQuery.isEmptyObject( orig ) ) { |
return; |
} |
|
// Restrict "overflow" and "display" styles during box animations |
if ( isBox && elem.nodeType === 1 ) { |
|
// Support: IE <=9 - 11, Edge 12 - 13 |
// Record all 3 overflow attributes because IE does not infer the shorthand |
// from identically-valued overflowX and overflowY |
// Height/width overflow pass |
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { |
// Make sure that nothing sneaks out |
// Record all 3 overflow attributes because IE9-10 do not |
// change the overflow attribute when overflowX and |
// overflowY are set to the same value |
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; |
|
// Identify a display type, preferring old show/hide data over the CSS cascade |
restoreDisplay = dataShow && dataShow.display; |
if ( restoreDisplay == null ) { |
restoreDisplay = dataPriv.get( elem, "display" ); |
} |
// Set display property to inline-block for height/width |
// animations on inline elements that are having width/height animated |
display = jQuery.css( elem, "display" ); |
if ( display === "none" ) { |
if ( restoreDisplay ) { |
display = restoreDisplay; |
} else { |
|
// Get nonempty value(s) by temporarily forcing visibility |
showHide( [ elem ], true ); |
restoreDisplay = elem.style.display || restoreDisplay; |
display = jQuery.css( elem, "display" ); |
showHide( [ elem ] ); |
} |
} |
// Test default display if display is currently "none" |
checkDisplay = display === "none" ? |
data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display; |
|
// Animate inline elements as inline-block |
if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { |
if ( jQuery.css( elem, "float" ) === "none" ) { |
|
// Restore the original display value at the end of pure show/hide animations |
if ( !propTween ) { |
anim.done( function() { |
style.display = restoreDisplay; |
} ); |
if ( restoreDisplay == null ) { |
display = style.display; |
restoreDisplay = display === "none" ? "" : display; |
} |
} |
style.display = "inline-block"; |
} |
if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) { |
style.display = "inline-block"; |
} |
} |
|
if ( opts.overflow ) { |
style.overflow = "hidden"; |
anim.always( function() { |
anim.always(function() { |
style.overflow = opts.overflow[ 0 ]; |
style.overflowX = opts.overflow[ 1 ]; |
style.overflowY = opts.overflow[ 2 ]; |
} ); |
}); |
} |
|
// Implement show/hide animations |
propTween = false; |
for ( prop in orig ) { |
// show/hide pass |
for ( prop in props ) { |
value = props[ prop ]; |
if ( rfxtypes.exec( value ) ) { |
delete props[ prop ]; |
toggle = toggle || value === "toggle"; |
if ( value === ( hidden ? "hide" : "show" ) ) { |
|
// General show/hide setup for this element animation |
if ( !propTween ) { |
if ( dataShow ) { |
if ( "hidden" in dataShow ) { |
hidden = dataShow.hidden; |
// If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden |
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { |
hidden = true; |
} else { |
continue; |
} |
} else { |
dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); |
} |
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); |
|
// Store hidden/visible for toggle so `.stop().toggle()` "reverses" |
if ( toggle ) { |
dataShow.hidden = !hidden; |
} |
// Any non-fx value stops us from restoring the original display value |
} else { |
display = undefined; |
} |
} |
|
// Show elements before animating them |
if ( hidden ) { |
showHide( [ elem ], true ); |
if ( !jQuery.isEmptyObject( orig ) ) { |
if ( dataShow ) { |
if ( "hidden" in dataShow ) { |
hidden = dataShow.hidden; |
} |
} else { |
dataShow = data_priv.access( elem, "fxshow", {} ); |
} |
|
/* eslint-disable no-loop-func */ |
// Store state if its toggle - enables .stop().toggle() to "reverse" |
if ( toggle ) { |
dataShow.hidden = !hidden; |
} |
if ( hidden ) { |
jQuery( elem ).show(); |
} else { |
anim.done(function() { |
jQuery( elem ).hide(); |
}); |
} |
anim.done(function() { |
var prop; |
|
anim.done( function() { |
data_priv.remove( elem, "fxshow" ); |
for ( prop in orig ) { |
jQuery.style( elem, prop, orig[ prop ] ); |
} |
}); |
for ( prop in orig ) { |
tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); |
|
/* eslint-enable no-loop-func */ |
|
// The final step of a "hide" animation is actually hiding the element |
if ( !hidden ) { |
showHide( [ elem ] ); |
if ( !( prop in dataShow ) ) { |
dataShow[ prop ] = tween.start; |
if ( hidden ) { |
tween.end = tween.start; |
tween.start = prop === "width" || prop === "height" ? 1 : 0; |
} |
dataPriv.remove( elem, "fxshow" ); |
for ( prop in orig ) { |
jQuery.style( elem, prop, orig[ prop ] ); |
} |
} ); |
} |
} |
|
// Per-property setup |
propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); |
if ( !( prop in dataShow ) ) { |
dataShow[ prop ] = propTween.start; |
if ( hidden ) { |
propTween.end = propTween.start; |
propTween.start = 0; |
} |
} |
// If this is a noop like .hide().hide(), restore an overwritten display value |
} else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) { |
style.display = display; |
} |
} |
|
@@ -289,12 +288,11 @@ |
var result, |
stopped, |
index = 0, |
length = Animation.prefilters.length, |
length = animationPrefilters.length, |
deferred = jQuery.Deferred().always( function() { |
|
// Don't match elem in the :animated selector |
delete tick.elem; |
} ), |
}), |
tick = function() { |
if ( stopped ) { |
return false; |
@@ -301,8 +299,7 @@ |
} |
var currentTime = fxNow || createFxNow(), |
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), |
|
// Support: Android 2.3 only |
// Support: Android 2.3 |
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) |
temp = remaining / animation.duration || 0, |
percent = 1 - temp, |
@@ -309,11 +306,11 @@ |
index = 0, |
length = animation.tweens.length; |
|
for ( ; index < length; index++ ) { |
for ( ; index < length ; index++ ) { |
animation.tweens[ index ].run( percent ); |
} |
|
deferred.notifyWith( elem, [ animation, percent, remaining ] ); |
deferred.notifyWith( elem, [ animation, percent, remaining ]); |
|
if ( percent < 1 && length ) { |
return remaining; |
@@ -322,13 +319,10 @@ |
return false; |
} |
}, |
animation = deferred.promise( { |
animation = deferred.promise({ |
elem: elem, |
props: jQuery.extend( {}, properties ), |
opts: jQuery.extend( true, { |
specialEasing: {}, |
easing: jQuery.easing._default |
}, options ), |
opts: jQuery.extend( true, { specialEasing: {} }, options ), |
originalProperties: properties, |
originalOptions: options, |
startTime: fxNow || createFxNow(), |
@@ -342,7 +336,6 @@ |
}, |
stop: function( gotoEnd ) { |
var index = 0, |
|
// If we are going to the end, we want to run all the tweens |
// otherwise we skip this part |
length = gotoEnd ? animation.tweens.length : 0; |
@@ -350,13 +343,12 @@ |
return this; |
} |
stopped = true; |
for ( ; index < length; index++ ) { |
for ( ; index < length ; index++ ) { |
animation.tweens[ index ].run( 1 ); |
} |
|
// Resolve when we played the last frame; otherwise, reject |
if ( gotoEnd ) { |
deferred.notifyWith( elem, [ animation, 1, 0 ] ); |
deferred.resolveWith( elem, [ animation, gotoEnd ] ); |
} else { |
deferred.rejectWith( elem, [ animation, gotoEnd ] ); |
@@ -363,18 +355,14 @@ |
} |
return this; |
} |
} ), |
}), |
props = animation.props; |
|
propFilter( props, animation.opts.specialEasing ); |
|
for ( ; index < length; index++ ) { |
result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); |
for ( ; index < length ; index++ ) { |
result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); |
if ( result ) { |
if ( jQuery.isFunction( result.stop ) ) { |
jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = |
jQuery.proxy( result.stop, result ); |
} |
return result; |
} |
} |
@@ -390,7 +378,7 @@ |
elem: elem, |
anim: animation, |
queue: animation.opts.queue |
} ) |
}) |
); |
|
// attach callbacks from options |
@@ -402,20 +390,12 @@ |
|
jQuery.Animation = jQuery.extend( Animation, { |
|
tweeners: { |
"*": [ function( prop, value ) { |
var tween = this.createTween( prop, value ); |
adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); |
return tween; |
} ] |
}, |
|
tweener: function( props, callback ) { |
if ( jQuery.isFunction( props ) ) { |
callback = props; |
props = [ "*" ]; |
} else { |
props = props.match( rnothtmlwhite ); |
props = props.split(" "); |
} |
|
var prop, |
@@ -422,23 +402,21 @@ |
index = 0, |
length = props.length; |
|
for ( ; index < length; index++ ) { |
for ( ; index < length ; index++ ) { |
prop = props[ index ]; |
Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; |
Animation.tweeners[ prop ].unshift( callback ); |
tweeners[ prop ] = tweeners[ prop ] || []; |
tweeners[ prop ].unshift( callback ); |
} |
}, |
|
prefilters: [ defaultPrefilter ], |
|
prefilter: function( callback, prepend ) { |
if ( prepend ) { |
Animation.prefilters.unshift( callback ); |
animationPrefilters.unshift( callback ); |
} else { |
Animation.prefilters.push( callback ); |
animationPrefilters.push( callback ); |
} |
} |
} ); |
}); |
|
jQuery.speed = function( speed, easing, fn ) { |
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { |
@@ -448,21 +426,9 @@ |
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing |
}; |
|
// Go to the end state if fx are off or if document is hidden |
if ( jQuery.fx.off || document.hidden ) { |
opt.duration = 0; |
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; |
|
} else { |
if ( typeof opt.duration !== "number" ) { |
if ( opt.duration in jQuery.fx.speeds ) { |
opt.duration = jQuery.fx.speeds[ opt.duration ]; |
|
} else { |
opt.duration = jQuery.fx.speeds._default; |
} |
} |
} |
|
// Normalize opt.queue - true/undefined/null -> "fx" |
if ( opt.queue == null || opt.queue === true ) { |
opt.queue = "fx"; |
@@ -484,25 +450,24 @@ |
return opt; |
}; |
|
jQuery.fn.extend( { |
jQuery.fn.extend({ |
fadeTo: function( speed, to, easing, callback ) { |
|
// Show any hidden elements after setting opacity to 0 |
return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show() |
return this.filter( isHidden ).css( "opacity", 0 ).show() |
|
// Animate to the value specified |
.end().animate( { opacity: to }, speed, easing, callback ); |
.end().animate({ opacity: to }, speed, easing, callback ); |
}, |
animate: function( prop, speed, easing, callback ) { |
var empty = jQuery.isEmptyObject( prop ), |
optall = jQuery.speed( speed, easing, callback ), |
doAnimation = function() { |
|
// Operate on a copy of prop so per-property easing won't be lost |
var anim = Animation( this, jQuery.extend( {}, prop ), optall ); |
|
// Empty animations, or finishing resolves immediately |
if ( empty || dataPriv.get( this, "finish" ) ) { |
if ( empty || data_priv.get( this, "finish" ) ) { |
anim.stop( true ); |
} |
}; |
@@ -528,11 +493,11 @@ |
this.queue( type || "fx", [] ); |
} |
|
return this.each( function() { |
return this.each(function() { |
var dequeue = true, |
index = type != null && type + "queueHooks", |
timers = jQuery.timers, |
data = dataPriv.get( this ); |
data = data_priv.get( this ); |
|
if ( index ) { |
if ( data[ index ] && data[ index ].stop ) { |
@@ -547,9 +512,7 @@ |
} |
|
for ( index = timers.length; index--; ) { |
if ( timers[ index ].elem === this && |
( type == null || timers[ index ].queue === type ) ) { |
|
if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { |
timers[ index ].anim.stop( gotoEnd ); |
dequeue = false; |
timers.splice( index, 1 ); |
@@ -562,15 +525,15 @@ |
if ( dequeue || !gotoEnd ) { |
jQuery.dequeue( this, type ); |
} |
} ); |
}); |
}, |
finish: function( type ) { |
if ( type !== false ) { |
type = type || "fx"; |
} |
return this.each( function() { |
return this.each(function() { |
var index, |
data = dataPriv.get( this ), |
data = data_priv.get( this ), |
queue = data[ type + "queue" ], |
hooks = data[ type + "queueHooks" ], |
timers = jQuery.timers, |
@@ -603,11 +566,11 @@ |
|
// Turn off finishing flag |
delete data.finish; |
} ); |
}); |
} |
} ); |
}); |
|
jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) { |
jQuery.each([ "toggle", "show", "hide" ], function( i, name ) { |
var cssFn = jQuery.fn[ name ]; |
jQuery.fn[ name ] = function( speed, easing, callback ) { |
return speed == null || typeof speed === "boolean" ? |
@@ -614,13 +577,13 @@ |
cssFn.apply( this, arguments ) : |
this.animate( genFx( name, true ), speed, easing, callback ); |
}; |
} ); |
}); |
|
// Generate shortcuts for custom animations |
jQuery.each( { |
slideDown: genFx( "show" ), |
slideUp: genFx( "hide" ), |
slideToggle: genFx( "toggle" ), |
jQuery.each({ |
slideDown: genFx("show"), |
slideUp: genFx("hide"), |
slideToggle: genFx("toggle"), |
fadeIn: { opacity: "show" }, |
fadeOut: { opacity: "hide" }, |
fadeToggle: { opacity: "toggle" } |
@@ -628,7 +591,7 @@ |
jQuery.fn[ name ] = function( speed, easing, callback ) { |
return this.animate( props, speed, easing, callback ); |
}; |
} ); |
}); |
|
jQuery.timers = []; |
jQuery.fx.tick = function() { |
@@ -640,7 +603,6 @@ |
|
for ( ; i < timers.length; i++ ) { |
timer = timers[ i ]; |
|
// Checks the timer has not already been removed |
if ( !timer() && timers[ i ] === timer ) { |
timers.splice( i--, 1 ); |
@@ -663,21 +625,15 @@ |
}; |
|
jQuery.fx.interval = 13; |
|
jQuery.fx.start = function() { |
if ( !timerId ) { |
timerId = window.requestAnimationFrame ? |
window.requestAnimationFrame( raf ) : |
window.setInterval( jQuery.fx.tick, jQuery.fx.interval ); |
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval ); |
} |
}; |
|
jQuery.fx.stop = function() { |
if ( window.cancelAnimationFrame ) { |
window.cancelAnimationFrame( timerId ); |
} else { |
window.clearInterval( timerId ); |
} |
|
clearInterval( timerId ); |
timerId = null; |
}; |
|
@@ -684,10 +640,9 @@ |
jQuery.fx.speeds = { |
slow: 600, |
fast: 200, |
|
// Default speed |
_default: 400 |
}; |
|
return jQuery; |
} ); |
}); |