From 589e67e4af3c2c5e42984f82cbd83d0246029535 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Fri, 11 Oct 2019 12:00:52 -0400 Subject: [PATCH] perf(animations): wrap loops in requestAnimationFrame call (#19630) fixes #19629 --- core/src/utils/animation/animation.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/utils/animation/animation.ts b/core/src/utils/animation/animation.ts index 76436c5a8a..66ba1c9191 100644 --- a/core/src/utils/animation/animation.ts +++ b/core/src/utils/animation/animation.ts @@ -128,8 +128,8 @@ export const createAnimation = (): Animation => { webAnimations.length = 0; } else { - elements.forEach(element => { - raf(() => { + raf(() => { + elements.forEach(element => { removeStyleProperty(element, 'animation-name'); removeStyleProperty(element, 'animation-duration'); removeStyleProperty(element, 'animation-timing-function'); @@ -632,8 +632,8 @@ export const createAnimation = (): Animation => { }; const updateCSSAnimation = (toggleAnimationName = true) => { - elements.forEach(element => { - raf(() => { + raf(() => { + elements.forEach(element => { setStyleProperty(element, 'animation-name', keyframeName || null); setStyleProperty(element, 'animation-duration', `${getDuration()}ms`); setStyleProperty(element, 'animation-timing-function', getEasing()); @@ -796,12 +796,12 @@ export const createAnimation = (): Animation => { const playCSSAnimations = () => { clearCSSAnimationsTimeout(); - elements.forEach(element => { - if (_keyframes.length > 0) { - raf(() => { + raf(() => { + elements.forEach(element => { + if (_keyframes.length > 0) { setStyleProperty(element, 'animation-play-state', 'running'); - }); - } + } + }); }); if (_keyframes.length === 0 || elements.length === 0) {