aboutsummaryrefslogtreecommitdiffstats
path: root/src/effects.js
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-09-03 02:52:01 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-09-07 20:14:50 +0300
commit20ddbe4f594f78f7f1095050aabd91882dde0670 (patch)
treecec646466acf1470780105c743e72d52f5c691ba /src/effects.js
parentfa8a5a90e157f26a54ce50b4e8bb8f2f4bce3500 (diff)
downloadjquery-20ddbe4f594f78f7f1095050aabd91882dde0670.tar.gz
jquery-20ddbe4f594f78f7f1095050aabd91882dde0670.zip
Build: Update jscs and lint files
Ref 10fdad742a2a6aa9f0e00b3e04fc5264797c53c7 Fixes gh-2056
Diffstat (limited to 'src/effects.js')
-rw-r--r--src/effects.js82
1 files changed, 46 insertions, 36 deletions
diff --git a/src/effects.js b/src/effects.js
index 9a0e4e0f1..64ec4ae15 100644
--- a/src/effects.js
+++ b/src/effects.js
@@ -1,4 +1,4 @@
-define([
+define( [
"./core",
"./var/document",
"./var/rcssNum",
@@ -33,9 +33,9 @@ function raf() {
// Animations created synchronously will run synchronously
function createFxNow() {
- window.setTimeout(function() {
+ window.setTimeout( function() {
fxNow = undefined;
- });
+ } );
return ( fxNow = jQuery.now() );
}
@@ -66,7 +66,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;
@@ -98,16 +98,17 @@ function defaultPrefilter( elem, props, opts ) {
}
hooks.unqueued++;
- anim.always(function() {
+ anim.always( function() {
+
// doing this makes sure that the complete handler will be 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;
@@ -346,7 +352,7 @@ function Animation( elem, properties, options ) {
}
return this;
}
- }),
+ } ),
props = animation.props;
propFilter( props, animation.opts.specialEasing );
@@ -373,7 +379,7 @@ function Animation( elem, properties, options ) {
elem: elem,
anim: animation,
queue: animation.opts.queue
- })
+ } )
);
// attach callbacks from options
@@ -421,7 +427,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 ) : {
@@ -462,18 +468,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 +512,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 +532,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 +546,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 = jQuery._data( this ),
queue = data[ type + "queue" ],
@@ -579,24 +587,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 +612,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 +624,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 );
@@ -658,9 +667,10 @@ jQuery.fx.stop = function() {
jQuery.fx.speeds = {
slow: 600,
fast: 200,
+
// Default speed
_default: 400
};
return jQuery;
-});
+} );