aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCorey Frang <gnarf@gnarf.net>2015-05-19 17:48:42 -0400
committerCorey Frang <gnarf@gnarf.net>2015-06-26 20:06:03 -0400
commitb3b2d6c3dd51fbdc69e1942e9af75cc99a1834c2 (patch)
treeebd6d168bf16e1cadf77e4b97b8c74997cb5bcde /src
parentcdaed15c7ea1bbfdde5a5bea691c583ce7961526 (diff)
downloadjquery-b3b2d6c3dd51fbdc69e1942e9af75cc99a1834c2.tar.gz
jquery-b3b2d6c3dd51fbdc69e1942e9af75cc99a1834c2.zip
Effects: Adding unit tests for jQuery.Animation
Closes gh-2326
Diffstat (limited to 'src')
-rw-r--r--src/effects.js44
1 files changed, 26 insertions, 18 deletions
diff --git a/src/effects.js b/src/effects.js
index 53b73fd84..40da88705 100644
--- a/src/effects.js
+++ b/src/effects.js
@@ -2,6 +2,7 @@ define([
"./core",
"./var/document",
"./var/rcssNum",
+ "./var/rnotwhite",
"./css/var/cssExpand",
"./css/var/isHidden",
"./css/var/swap",
@@ -16,20 +17,13 @@ define([
"./manipulation",
"./css",
"./effects/Tween"
-], function( jQuery, document, rcssNum, cssExpand, isHidden, swap, adjustCSS, dataPriv, showHide ) {
+], function( jQuery, document, rcssNum, rnotwhite, cssExpand, isHidden, swap,
+ adjustCSS, dataPriv, 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 ) {
@@ -69,7 +63,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++ ) {
@@ -281,7 +275,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 +351,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;
}
}
@@ -386,12 +384,20 @@ function Animation( elem, properties, options ) {
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.split(" ");
+ props = props.match( rnotwhite );
}
var prop,
@@ -400,16 +406,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 );
}
}
});