MCPcopy Create free account
hub / github.com/angular/angular / getAnimationDuration

Function getAnimationDuration

packages/core/src/animation/longest_animation.ts:73–88  ·  view source on GitHub ↗
(animation: Animation)

Source from the content-addressed store, hash-verified

71
72/** Gets an animation's total duration, including its delay and playback rate. */
73export function getAnimationDuration(animation: Animation): number | undefined {
74 const timing = animation.effect?.getTiming();
75 if (timing === undefined) return undefined;
76
77 // duration can be a string 'auto' or a number.
78 const animationDuration = typeof timing.duration === 'number' ? timing.duration : 0;
79 let duration = (timing.delay ?? 0) + animationDuration;
80
81 // Account for playback rate if it is set.
82 const playbackRate = animation.playbackRate;
83 if (playbackRate !== undefined && playbackRate !== 0 && playbackRate !== 1) {
84 duration /= Math.abs(playbackRate);
85 }
86
87 return duration;
88}
89
90/**
91 * Determines the longest animation, but with `getComputedStyles` instead of `getAnimations`. This

Calls

no outgoing calls

Tested by

no test coverage detected