(animation: Animation)
| 71 | |
| 72 | /** Gets an animation's total duration, including its delay and playback rate. */ |
| 73 | export 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 |
no outgoing calls
no test coverage detected