Carousel: Fix reveal
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-04-21 18:12:32 +02:00
parent e9ad9deafd
commit a4f4b55705

View File

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