diff options
author | Corey Frang <gnarf@gnarf.net> | 2015-05-19 17:48:42 -0400 |
---|---|---|
committer | Corey Frang <gnarf@gnarf.net> | 2015-06-26 20:12:42 -0400 |
commit | 0ff805772ad046ff1e9ecf1f9958408ce0cfcfcd (patch) | |
tree | 31d37683dfca18588b0d663cdde38560f35f81dc /src | |
parent | 6b10f9d7e9fb6d062d2bbda49196544cd059b05c (diff) | |
download | jquery-0ff805772ad046ff1e9ecf1f9958408ce0cfcfcd.tar.gz jquery-0ff805772ad046ff1e9ecf1f9958408ce0cfcfcd.zip |
Effects: Adding unit tests for jQuery.Animation
Closes gh-2340
(cherry picked from commit b3b2d6c3dd51fbdc69e1942e9af75cc99a1834c2)
Conflicts:
src/effects.js
Diffstat (limited to 'src')
-rw-r--r-- | src/effects.js | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/src/effects.js b/src/effects.js index 90cfb07b1..a80d2dbd6 100644 --- a/src/effects.js +++ b/src/effects.js @@ -1,6 +1,7 @@ define([ "./core", "./var/rcssNum", + "./var/rnotwhite", "./css/var/cssExpand", "./css/var/isHidden", "./css/var/swap", @@ -14,20 +15,12 @@ define([ "./manipulation", "./css", "./effects/Tween" -], function( jQuery, rcssNum, cssExpand, isHidden, swap, adjustCSS, showHide ) { +], function( jQuery, rcssNum, rnotwhite, cssExpand, isHidden, swap, adjustCSS, showHide ) { var fxNow, timerId, rfxtypes = /^(?:toggle|show|hide)$/, - rrun = /queueHooks$/, - animationPrefilters = [ defaultPrefilter ], - tweeners = { - "*": [ function( prop, value ) { - var tween = this.createTween( prop, value ); - adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); - return tween; - } ] - }; + rrun = /queueHooks$/; function raf() { if ( timerId ) { @@ -67,7 +60,7 @@ function genFx( type, includeWidth ) { function createTween( value, prop, animation ) { var tween, - collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), + collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), index = 0, length = collection.length; for ( ; index < length; index++ ) { @@ -280,7 +273,7 @@ function Animation( elem, properties, options ) { var result, stopped, index = 0, - length = animationPrefilters.length, + length = Animation.prefilters.length, deferred = jQuery.Deferred().always( function() { // don't match elem in the :animated selector delete tick.elem; @@ -357,8 +350,12 @@ function Animation( elem, properties, options ) { propFilter( props, animation.opts.specialEasing ); for ( ; index < length ; index++ ) { - result = animationPrefilters[ index ].call( animation, elem, props, animation.opts ); + result = Animation.prefilters[ 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; } } @@ -385,12 +382,24 @@ function Animation( elem, properties, options ) { } jQuery.Animation = jQuery.extend( Animation, { +<<<<<<< HEAD +======= + + tweeners: { + "*": [ function( prop, value ) { + var tween = this.createTween( prop, value ); + adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); + return tween; + } ] + }, + +>>>>>>> b3b2d6c... Effects: Adding unit tests for jQuery.Animation tweener: function( props, callback ) { if ( jQuery.isFunction( props ) ) { callback = props; props = [ "*" ]; } else { - props = props.split(" "); + props = props.match( rnotwhite ); } var prop, @@ -399,16 +408,18 @@ jQuery.Animation = jQuery.extend( Animation, { for ( ; index < length ; index++ ) { prop = props[ index ]; - tweeners[ prop ] = tweeners[ prop ] || []; - tweeners[ prop ].unshift( callback ); + Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; + Animation.tweeners[ prop ].unshift( callback ); } }, + prefilters: [ defaultPrefilter ], + prefilter: function( callback, prepend ) { if ( prepend ) { - animationPrefilters.unshift( callback ); + Animation.prefilters.unshift( callback ); } else { - animationPrefilters.push( callback ); + Animation.prefilters.push( callback ); } } }); |