MCPcopy Create free account
hub / github.com/frank-lam/fullstack-tutorial / Animation

Function Animation

notes/docsify/unpkg/gotop/jquery-2.1.0.js:6449–6551  ·  view source on GitHub ↗
( elem, properties, options )

Source from the content-addressed store, hash-verified

6447}
6448
6449function Animation( elem, properties, options ) {
6450 var result,
6451 stopped,
6452 index = 0,
6453 length = animationPrefilters.length,
6454 deferred = jQuery.Deferred().always( function() {
6455 // don't match elem in the :animated selector
6456 delete tick.elem;
6457 }),
6458 tick = function() {
6459 if ( stopped ) {
6460 return false;
6461 }
6462 var currentTime = fxNow || createFxNow(),
6463 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
6464 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
6465 temp = remaining / animation.duration || 0,
6466 percent = 1 - temp,
6467 index = 0,
6468 length = animation.tweens.length;
6469
6470 for ( ; index < length ; index++ ) {
6471 animation.tweens[ index ].run( percent );
6472 }
6473
6474 deferred.notifyWith( elem, [ animation, percent, remaining ]);
6475
6476 if ( percent < 1 && length ) {
6477 return remaining;
6478 } else {
6479 deferred.resolveWith( elem, [ animation ] );
6480 return false;
6481 }
6482 },
6483 animation = deferred.promise({
6484 elem: elem,
6485 props: jQuery.extend( {}, properties ),
6486 opts: jQuery.extend( true, { specialEasing: {} }, options ),
6487 originalProperties: properties,
6488 originalOptions: options,
6489 startTime: fxNow || createFxNow(),
6490 duration: options.duration,
6491 tweens: [],
6492 createTween: function( prop, end ) {
6493 var tween = jQuery.Tween( elem, animation.opts, prop, end,
6494 animation.opts.specialEasing[ prop ] || animation.opts.easing );
6495 animation.tweens.push( tween );
6496 return tween;
6497 },
6498 stop: function( gotoEnd ) {
6499 var index = 0,
6500 // if we are going to the end, we want to run all the tweens
6501 // otherwise we skip this part
6502 length = gotoEnd ? animation.tweens.length : 0;
6503 if ( stopped ) {
6504 return this;
6505 }
6506 stopped = true;

Callers 1

doAnimationFunction · 0.85

Calls 2

createFxNowFunction · 0.85
propFilterFunction · 0.85

Tested by

no test coverage detected