MCPcopy Create free account
hub / github.com/JsAaron/jQuery / Animation

Function Animation

2.1.1/test/jquery-2.1.1.js:6505–6607  ·  view source on GitHub ↗
( elem, properties, options )

Source from the content-addressed store, hash-verified

6503}
6504
6505function Animation( elem, properties, options ) {
6506 var result,
6507 stopped,
6508 index = 0,
6509 length = animationPrefilters.length,
6510 deferred = jQuery.Deferred().always( function() {
6511 // don't match elem in the :animated selector
6512 delete tick.elem;
6513 }),
6514 tick = function() {
6515 if ( stopped ) {
6516 return false;
6517 }
6518 var currentTime = fxNow || createFxNow(),
6519 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
6520 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
6521 temp = remaining / animation.duration || 0,
6522 percent = 1 - temp,
6523 index = 0,
6524 length = animation.tweens.length;
6525
6526 for ( ; index < length ; index++ ) {
6527 animation.tweens[ index ].run( percent );
6528 }
6529
6530 deferred.notifyWith( elem, [ animation, percent, remaining ]);
6531
6532 if ( percent < 1 && length ) {
6533 return remaining;
6534 } else {
6535 deferred.resolveWith( elem, [ animation ] );
6536 return false;
6537 }
6538 },
6539 animation = deferred.promise({
6540 elem: elem,
6541 props: jQuery.extend( {}, properties ),
6542 opts: jQuery.extend( true, { specialEasing: {} }, options ),
6543 originalProperties: properties,
6544 originalOptions: options,
6545 startTime: fxNow || createFxNow(),
6546 duration: options.duration,
6547 tweens: [],
6548 createTween: function( prop, end ) {
6549 var tween = jQuery.Tween( elem, animation.opts, prop, end,
6550 animation.opts.specialEasing[ prop ] || animation.opts.easing );
6551 animation.tweens.push( tween );
6552 return tween;
6553 },
6554 stop: function( gotoEnd ) {
6555 var index = 0,
6556 // if we are going to the end, we want to run all the tweens
6557 // otherwise we skip this part
6558 length = gotoEnd ? animation.tweens.length : 0;
6559 if ( stopped ) {
6560 return this;
6561 }
6562 stopped = true;

Callers 1

doAnimationFunction · 0.70

Calls 2

createFxNowFunction · 0.70
propFilterFunction · 0.70

Tested by

no test coverage detected