Carousel: Fix reveal

This commit is contained in:
2020-04-21 15:31:57 +02:00
parent 99dd2c5327
commit fa2a213516

View File

@@ -52,16 +52,18 @@ export const animateIn = scope => {
// Reveal on scroll // Reveal on scroll
let visible = false let visible = false
requestAnimationFrame(() => { const carouselReveal = ScrollOut({
const carouselReveal = ScrollOut({ once: true,
once: true, targets: scope,
targets: scope, onChange: (el, ctx) => {
onChange: (el, ctx) => { requestAnimationFrame(() => {
if (ctx.visible === 0) { if (ctx.visible === 0) {
visible = true visible = true
} }
}, })
onShown: (el, ctx) => { },
onShown: (el, ctx) => {
requestAnimationFrame(() => {
// If revealed on scroll, no delay // If revealed on scroll, no delay
if (visible) { if (visible) {
tl.restart() tl.restart()
@@ -70,7 +72,7 @@ export const animateIn = scope => {
else { else {
setTimeout(() => tl.restart(), animDelay * 2) setTimeout(() => tl.restart(), animDelay * 2)
} }
} })
}) }
}) })
} }