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

Function Animation

2.1.1/src/effects.js:294–396  ·  view source on GitHub ↗
( elem, properties, options )

Source from the content-addressed store, hash-verified

292}
293
294function Animation( elem, properties, options ) {
295 var result,
296 stopped,
297 index = 0,
298 length = animationPrefilters.length,
299 deferred = jQuery.Deferred().always( function() {
300 // Don't match elem in the :animated selector
301 delete tick.elem;
302 }),
303 tick = function() {
304 if ( stopped ) {
305 return false;
306 }
307 var currentTime = fxNow || createFxNow(),
308 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
309 // Support: Android 2.3
310 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
311 temp = remaining / animation.duration || 0,
312 percent = 1 - temp,
313 index = 0,
314 length = animation.tweens.length;
315
316 for ( ; index < length ; index++ ) {
317 animation.tweens[ index ].run( percent );
318 }
319
320 deferred.notifyWith( elem, [ animation, percent, remaining ]);
321
322 if ( percent < 1 && length ) {
323 return remaining;
324 } else {
325 deferred.resolveWith( elem, [ animation ] );
326 return false;
327 }
328 },
329 animation = deferred.promise({
330 elem: elem,
331 props: jQuery.extend( {}, properties ),
332 opts: jQuery.extend( true, { specialEasing: {} }, options ),
333 originalProperties: properties,
334 originalOptions: options,
335 startTime: fxNow || createFxNow(),
336 duration: options.duration,
337 tweens: [],
338 createTween: function( prop, end ) {
339 var tween = jQuery.Tween( elem, animation.opts, prop, end,
340 animation.opts.specialEasing[ prop ] || animation.opts.easing );
341 animation.tweens.push( tween );
342 return tween;
343 },
344 stop: function( gotoEnd ) {
345 var index = 0,
346 // If we are going to the end, we want to run all the tweens
347 // otherwise we skip this part
348 length = gotoEnd ? animation.tweens.length : 0;
349 if ( stopped ) {
350 return this;
351 }

Callers 1

doAnimationFunction · 0.70

Calls 2

createFxNowFunction · 0.70
propFilterFunction · 0.70

Tested by

no test coverage detected