diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2015-08-16 09:59:58 +0300 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2015-09-07 20:03:50 +0300 |
commit | 10fdad742a2a6aa9f0e00b3e04fc5264797c53c7 (patch) | |
tree | 6b6d7b1375ff88f4bebbfa0703f7b595eb485df9 /src/effects.js | |
parent | 7aa46e0df8a673e6b00550bbbbed21eed50108b7 (diff) | |
download | jquery-10fdad742a2a6aa9f0e00b3e04fc5264797c53c7.tar.gz jquery-10fdad742a2a6aa9f0e00b3e04fc5264797c53c7.zip |
Build: Update jscs and lint files
Fixes gh-2056
Diffstat (limited to 'src/effects.js')
-rw-r--r-- | src/effects.js | 81 |
1 files changed, 45 insertions, 36 deletions
diff --git a/src/effects.js b/src/effects.js index 40da88705..90ac4b1e6 100644 --- a/src/effects.js +++ b/src/effects.js @@ -1,4 +1,4 @@ -define([ +define( [ "./core", "./var/document", "./var/rcssNum", @@ -34,9 +34,9 @@ function raf() { // Animations created synchronously will run synchronously function createFxNow() { - window.setTimeout(function() { + window.setTimeout( function() { fxNow = undefined; - }); + } ); return ( fxNow = jQuery.now() ); } @@ -67,7 +67,7 @@ function createTween( value, prop, animation ) { 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; @@ -99,15 +99,16 @@ function defaultPrefilter( elem, props, opts ) { } 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 @@ -140,6 +141,7 @@ function defaultPrefilter( elem, props, opts ) { // Restrict "overflow" and "display" styles during box animations if ( isBox && elem.nodeType === 1 ) { + // Support: IE 9 - 11 // Record all 3 overflow attributes because IE does not infer the shorthand // from identically-valued overflowX and overflowY @@ -163,9 +165,9 @@ function defaultPrefilter( elem, props, opts ) { // Restore the original display value at the end of pure show/hide animations if ( !propTween ) { - anim.done(function() { + anim.done( function() { style.display = restoreDisplay; - }); + } ); if ( restoreDisplay == null ) { display = style.display; restoreDisplay = display === "none" ? "" : display; @@ -178,11 +180,11 @@ function defaultPrefilter( elem, props, opts ) { 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 @@ -210,7 +212,8 @@ function defaultPrefilter( elem, props, opts ) { } /* jshint -W083 */ - anim.done(function() { + anim.done( function() { + // The final step of a "hide" animation is actually hiding the element if ( !hidden ) { showHide( [ elem ] ); @@ -219,7 +222,7 @@ function defaultPrefilter( elem, props, opts ) { for ( prop in orig ) { jQuery.style( elem, prop, orig[ prop ] ); } - }); + } ); } // Per-property setup @@ -277,15 +280,17 @@ function Animation( elem, properties, options ) { index = 0, length = Animation.prefilters.length, deferred = jQuery.Deferred().always( function() { + // Don't match elem in the :animated selector delete tick.elem; - }), + } ), tick = function() { if ( stopped ) { return false; } var currentTime = fxNow || createFxNow(), remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), + // Support: Android 2.3 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) temp = remaining / animation.duration || 0, @@ -297,7 +302,7 @@ function Animation( elem, properties, options ) { animation.tweens[ index ].run( percent ); } - deferred.notifyWith( elem, [ animation, percent, remaining ]); + deferred.notifyWith( elem, [ animation, percent, remaining ] ); if ( percent < 1 && length ) { return remaining; @@ -306,7 +311,7 @@ function Animation( elem, properties, options ) { return false; } }, - animation = deferred.promise({ + animation = deferred.promise( { elem: elem, props: jQuery.extend( {}, properties ), opts: jQuery.extend( true, { @@ -326,6 +331,7 @@ function Animation( elem, properties, options ) { }, 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; @@ -345,7 +351,7 @@ function Animation( elem, properties, options ) { } return this; } - }), + } ), props = animation.props; propFilter( props, animation.opts.specialEasing ); @@ -372,7 +378,7 @@ function Animation( elem, properties, options ) { elem: elem, anim: animation, queue: animation.opts.queue - }) + } ) ); // attach callbacks from options @@ -420,7 +426,7 @@ jQuery.Animation = jQuery.extend( Animation, { Animation.prefilters.push( callback ); } } -}); +} ); jQuery.speed = function( speed, easing, fn ) { var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { @@ -461,19 +467,20 @@ jQuery.speed = function( speed, easing, fn ) { 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( 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 ); @@ -504,7 +511,7 @@ jQuery.fn.extend({ this.queue( type || "fx", [] ); } - return this.each(function() { + return this.each( function() { var dequeue = true, index = type != null && type + "queueHooks", timers = jQuery.timers, @@ -524,7 +531,7 @@ jQuery.fn.extend({ for ( index = timers.length; index--; ) { if ( timers[ index ].elem === this && - (type == null || timers[ index ].queue === type) ) { + ( type == null || timers[ index ].queue === type ) ) { timers[ index ].anim.stop( gotoEnd ); dequeue = false; @@ -538,13 +545,13 @@ jQuery.fn.extend({ 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 ), queue = data[ type + "queue" ], @@ -579,24 +586,24 @@ jQuery.fn.extend({ // 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" ? 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" } @@ -604,7 +611,7 @@ jQuery.each({ jQuery.fn[ name ] = function( speed, easing, callback ) { return this.animate( props, speed, easing, callback ); }; -}); +} ); jQuery.timers = []; jQuery.fx.tick = function() { @@ -616,6 +623,7 @@ jQuery.fx.tick = function() { 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 ); @@ -659,9 +667,10 @@ jQuery.fx.stop = function() { jQuery.fx.speeds = { slow: 600, fast: 200, + // Default speed _default: 400 }; return jQuery; -}); +} ); |