Locations: Add delay between each location reveal

This commit is contained in:
2020-04-07 19:23:24 +02:00
parent c5836dcbc1
commit c3c888da52

View File

@@ -2,42 +2,53 @@ import anime from 'animejs'
import ScrollOut from 'scroll-out' import ScrollOut from 'scroll-out'
import { animDurationLong } from 'utils/store' import { animDurationLong } from 'utils/store'
// Variables
let delay = 0
/* /*
** Transition In ** Transition In
*/ */
export const animateIn = scope => { export const animateIn = scope => {
// Each location (reveal on scroll) // Each location (reveal on scroll)
const locations = ScrollOut({ scope.querySelectorAll('.location').forEach(location => {
targets: scope.querySelectorAll('.location'), console.log(delay)
onShown: el => {
// Image
anime({
targets: el.querySelector('img'),
scale: [1.3, 1],
opacity: [0, 1],
easing: 'easeOutQuart',
duration: 1800,
delay: 100
})
// Name const tl = anime.timeline({
anime({ easing: 'easeOutQuart',
targets: el.querySelector('h3'), duration: 600,
translateY: ['100%', 0], autoplay: false,
easing: 'easeOutQuart', delay
duration: 600, })
delay: 300
})
// Country // Image
anime({ tl.add({
targets: el.querySelector('p'), targets: location.querySelector('img'),
translateY: ['100%', 0], scale: [1.3, 1],
easing: 'easeOutQuart', opacity: [0, 1],
duration: 600, duration: 1800
delay: 550 }, 100)
})
} // Name
tl.add({
targets: location.querySelector('h3'),
translateY: ['100%', 0]
}, 150)
// Country
tl.add({
targets: location.querySelector('p'),
translateY: ['100%', 0]
}, 200)
// Scroll reveal
ScrollOut({
once: true,
targets: location,
onShown: () => tl.restart()
})
// Increase delay between locations
delay += 80
}) })
} }