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