MCPcopy Index your code
hub / github.com/angular/angular / animate

Method animate

adev/src/app/features/home/animation/animation.ts:409–439  ·  view source on GitHub ↗

Animate function.

(then: number, elapsed: number)

Source from the content-addressed store, hash-verified

407
408 /** Animate function. */
409 private animate(then: number, elapsed: number) {
410 this.animationFrameId = requestAnimationFrame(() => this.animate(then, elapsed));
411
412 const now = Date.now();
413 elapsed = now - then;
414
415 if (elapsed >= this.config.timestep) {
416 // Subtract the overflowed time from Now to maintain steady fps.
417 then = now - (elapsed % this.config.timestep);
418
419 const time = this.currentTime + elapsed;
420
421 if (time <= this._duration) {
422 this.updateFrame(time);
423 } else {
424 // Pause the animation and mark it as completed
425 // when we go over the duration.
426 this.pause();
427 this.completed = true;
428
429 // Since the last frame can be few milliseconds behind the duration
430 // (e.g. duration = 5000; current time = 4998) when the animation is
431 // completed, we perform one additional call to updateFrame in order
432 // to visualize any remaining static rules that match exactly the end
433 // of the animation.
434 if (this.duration > this.currentTime) {
435 requestAnimationFrame(() => this.updateFrame(this.duration));
436 }
437 }
438 }
439 }
440
441 /** Extract the objects from the selectors and validate their rules. */
442 private extractObjectsAndValidateRules(definition: AnimationDefinition) {

Callers 1

playMethod · 0.95

Calls 2

updateFrameMethod · 0.95
pauseMethod · 0.95

Tested by

no test coverage detected