mirror of
https://github.com/jquery/jquery.git
synced 2026-02-01 20:24:54 -05:00
Effects: Adding unit tests for jQuery.Animation
Closes gh-2340
(cherry picked from commit b3b2d6c3dd)
Conflicts:
src/effects.js
This commit is contained in:
47
src/effects.js
vendored
47
src/effects.js
vendored
@@ -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 );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user