perf(animations): do not create setTimeout if infinite iterations (#19632)

closes #19627
This commit is contained in:
Liam DeBeasi
2019-10-11 12:49:54 -04:00
committed by GitHub
parent 589e67e4af
commit 0d699fb2e4

View File

@ -819,7 +819,10 @@ export const createAnimation = (): Animation => {
const animationDuration = getDuration() || 0;
const animationIterations = getIterations() || 1;
cssAnimationsTimerFallback = setTimeout(onAnimationEndFallback, animationDelay + (animationDuration * animationIterations) + ANIMATION_END_FALLBACK_PADDING_MS);
// No need to set a timeout when animation has infinite iterations
if (isFinite(animationIterations)) {
cssAnimationsTimerFallback = setTimeout(onAnimationEndFallback, animationDelay + (animationDuration * animationIterations) + ANIMATION_END_FALLBACK_PADDING_MS);
}
animationEnd(elements[0], () => {
clearCSSAnimationsTimeout();