Carousel: Fix reveal again?
This commit is contained in:
@@ -16,7 +16,7 @@ export const animateIn = scope => {
|
|||||||
// Carousel
|
// Carousel
|
||||||
tl.add({
|
tl.add({
|
||||||
targets: scope,
|
targets: scope,
|
||||||
translateY: [32, 0],
|
translateY: [window.innerWidth <= 768 ? 16 : 32, 0],
|
||||||
translateZ: [0, 0],
|
translateZ: [0, 0],
|
||||||
opacity: [0, 1],
|
opacity: [0, 1],
|
||||||
complete: event => event.animatables[0].target.removeAttribute('style')
|
complete: event => event.animatables[0].target.removeAttribute('style')
|
||||||
@@ -52,29 +52,25 @@ 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(() => {
|
||||||
requestAnimationFrame(() => {
|
if (ctx.visible === 0) {
|
||||||
if (ctx.visible === 0) {
|
visible = true
|
||||||
visible = true
|
}
|
||||||
}
|
})
|
||||||
})
|
},
|
||||||
},
|
onShown: (el, ctx) => {
|
||||||
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 {
|
|
||||||
setTimeout(() => tl.restart(), animDelay * 2)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
// If revealed on load, add a delay
|
||||||
|
else {
|
||||||
|
setTimeout(() => tl.restart(), animDelay * 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user