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
let visible = false
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()
@@ -70,7 +72,7 @@ export const animateIn = scope => {
else {
setTimeout(() => tl.restart(), animDelay * 2)
}
}
})
})
}
})
}