diff --git a/src/animations/Carousel.js b/src/animations/Carousel.js index 928e73f..2d75d25 100644 --- a/src/animations/Carousel.js +++ b/src/animations/Carousel.js @@ -52,27 +52,29 @@ export const animateIn = scope => { // Reveal on scroll let visible = false - const carouselReveal = ScrollOut({ - once: true, - targets: scope, - onChange: (el, ctx) => { - requestAnimationFrame(() => { - if (ctx.visible === 0) { - visible = true - } - }) - }, - onShown: (el, ctx) => { - requestAnimationFrame(() => { - // If revealed on scroll, no delay - if (visible) { - tl.restart() - } - // If revealed on load, add a delay - else { - setTimeout(() => tl.restart(), animDelay * 2) - } - }) - } + requestAnimationFrame(() => { + const carouselReveal = ScrollOut({ + once: true, + targets: scope, + onChange: (el, ctx) => { + requestAnimationFrame(() => { + if (ctx.visible === 0) { + visible = true + } + }) + }, + onShown: (el, ctx) => { + requestAnimationFrame(() => { + // If revealed on scroll, no delay + if (visible) { + tl.restart() + } + // If revealed on load, add a delay + else { + setTimeout(() => tl.restart(), animDelay * 2) + } + }) + } + }) }) } \ No newline at end of file