Fix some animations
This commit is contained in:
@@ -10,7 +10,7 @@ export const animateIn = scope => {
|
|||||||
const tl = anime.timeline({
|
const tl = anime.timeline({
|
||||||
easing: 'easeOutQuart',
|
easing: 'easeOutQuart',
|
||||||
duration: animDuration,
|
duration: animDuration,
|
||||||
delay: 0
|
autoplay: false
|
||||||
})
|
})
|
||||||
|
|
||||||
// Photo: Active
|
// Photo: Active
|
||||||
@@ -18,6 +18,7 @@ export const animateIn = scope => {
|
|||||||
targets: scope.querySelector('.is-active picture'),
|
targets: scope.querySelector('.is-active picture'),
|
||||||
translateY: [8, 0]
|
translateY: [8, 0]
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|
||||||
// Photo: Prev
|
// Photo: Prev
|
||||||
tl.add({
|
tl.add({
|
||||||
targets: scope.querySelector('.is-prev picture'),
|
targets: scope.querySelector('.is-prev picture'),
|
||||||
@@ -25,6 +26,7 @@ export const animateIn = scope => {
|
|||||||
translateX: [64, 0],
|
translateX: [64, 0],
|
||||||
rotate: [-2, 0]
|
rotate: [-2, 0]
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|
||||||
// Photo: Next
|
// Photo: Next
|
||||||
tl.add({
|
tl.add({
|
||||||
targets: scope.querySelector('.is-next picture'),
|
targets: scope.querySelector('.is-next picture'),
|
||||||
|
|||||||
@@ -47,6 +47,6 @@ export const animateIn = scope => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Increase delay between locations
|
// Increase delay between locations
|
||||||
delay += 80
|
delay += 65
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export const animateIn = scope => {
|
|||||||
}, 400)
|
}, 400)
|
||||||
|
|
||||||
// Reveal on scroll
|
// Reveal on scroll
|
||||||
const photoReveal = ScrollOut({
|
const locationScroll = ScrollOut({
|
||||||
once: true,
|
once: true,
|
||||||
targets: scope,
|
targets: scope,
|
||||||
onShown: () => tlLocation.restart()
|
onShown: () => tlLocation.restart()
|
||||||
@@ -37,26 +37,26 @@ export const animateIn = scope => {
|
|||||||
|
|
||||||
// Image (reveal on scroll)
|
// Image (reveal on scroll)
|
||||||
const photoImage = scope.querySelector('.photo__image')
|
const photoImage = scope.querySelector('.photo__image')
|
||||||
const photoAnim = anime.timeline({
|
const photoReveal = anime.timeline({
|
||||||
easing: 'easeOutQuart',
|
easing: 'easeOutQuart',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
autoplay: false
|
autoplay: false
|
||||||
})
|
})
|
||||||
photoAnim.add({
|
photoReveal.add({
|
||||||
targets: scope.querySelector('.photo__picture'),
|
targets: scope.querySelector('.photo__picture'),
|
||||||
opacity: [0, 1]
|
opacity: [0, 1]
|
||||||
}, 50)
|
}, 50)
|
||||||
photoAnim.add({
|
photoReveal.add({
|
||||||
targets: scope.querySelector('.photo__picture img'),
|
targets: scope.querySelector('.photo__picture img'),
|
||||||
scale: [1.12, 1]
|
scale: [1.12, 1]
|
||||||
}, 50)
|
}, 50)
|
||||||
|
|
||||||
// Show photo when image is loaded
|
// Show photo when image is loaded
|
||||||
imagesLoaded(photoImage, instance => {
|
imagesLoaded(photoImage, instance => {
|
||||||
const photoReveal = ScrollOut({
|
const photoScroll = ScrollOut({
|
||||||
once: true,
|
once: true,
|
||||||
targets: photoImage,
|
targets: photoImage,
|
||||||
onShown: () => photoAnim.restart()
|
onShown: () => photoReveal.restart()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -71,13 +71,14 @@ export const animateIn = scope => {
|
|||||||
easing: 'linear',
|
easing: 'linear',
|
||||||
autoplay: false
|
autoplay: false
|
||||||
})
|
})
|
||||||
|
const numberPallaxAnime = () => parallaxAnime(number, numberPallax)
|
||||||
const numberPallaxScroll = matchMedia => {
|
const numberPallaxScroll = matchMedia => {
|
||||||
if (matchMedia.matches) {
|
if (matchMedia.matches) {
|
||||||
const scroll = ScrollOut({
|
const scroll = ScrollOut({
|
||||||
targets: scope,
|
targets: scope,
|
||||||
onShown: (el) => {
|
onShown: () => {
|
||||||
window.addEventListener('scroll', throttle(() => parallaxAnime(el, numberPallax), 50))
|
window.addEventListener('scroll', throttle(numberPallaxAnime, 50))
|
||||||
requestAnimationFrame(() => parallaxAnime(el, numberPallax))
|
requestAnimationFrame(numberPallaxAnime)
|
||||||
},
|
},
|
||||||
onHidden: () => {
|
onHidden: () => {
|
||||||
if (parallaxAnime) window.removeEventListener('scroll', parallaxAnime)
|
if (parallaxAnime) window.removeEventListener('scroll', parallaxAnime)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export const animateIn = () => {
|
|||||||
|
|
||||||
// Title: Of (reveal on scroll)
|
// Title: Of (reveal on scroll)
|
||||||
const titleOf = document.getElementById('title-of')
|
const titleOf = document.getElementById('title-of')
|
||||||
const titleOfAnime = anime({
|
const titleOfReveal = anime({
|
||||||
targets: titleOf.querySelectorAll('span'),
|
targets: titleOf.querySelectorAll('span'),
|
||||||
translateY: ['100%', 0],
|
translateY: ['100%', 0],
|
||||||
easing: 'easeOutQuart',
|
easing: 'easeOutQuart',
|
||||||
@@ -62,30 +62,32 @@ export const animateIn = () => {
|
|||||||
const titleOfScroll = ScrollOut({
|
const titleOfScroll = ScrollOut({
|
||||||
once: true,
|
once: true,
|
||||||
targets: titleOf,
|
targets: titleOf,
|
||||||
onShown: () => titleOfAnime.restart()
|
onShown: () => titleOfReveal.restart()
|
||||||
})
|
})
|
||||||
|
|
||||||
// Title: World (reveal on scroll)
|
// Title: World (reveal on scroll)
|
||||||
const titleWorld = document.getElementById('title-world')
|
const titleWorld = document.getElementById('title-world')
|
||||||
const titleWorldTranslate = anime({
|
const titleWorldReveal = anime({
|
||||||
targets: titleWorld,
|
|
||||||
translateX: ['5%', '-3%'],
|
|
||||||
easing: 'linear',
|
|
||||||
autoplay: false,
|
|
||||||
duration: animDuration
|
|
||||||
})
|
|
||||||
const titleWorldAnime = () => parallaxAnime(titleWorld, titleWorldTranslate)
|
|
||||||
const titleWorldScroll = ScrollOut({
|
|
||||||
once: true,
|
|
||||||
targets: titleWorld,
|
|
||||||
onShown: () => {
|
|
||||||
const titleWorldLetters = anime({
|
|
||||||
targets: titleWorld.querySelectorAll('span'),
|
targets: titleWorld.querySelectorAll('span'),
|
||||||
translateY: ['100%', 0],
|
translateY: ['100%', 0],
|
||||||
easing: 'easeOutQuart',
|
easing: 'easeOutQuart',
|
||||||
delay: anime.stagger(70),
|
delay: anime.stagger(70),
|
||||||
duration: animDuration
|
duration: animDuration,
|
||||||
|
autoplay: false
|
||||||
})
|
})
|
||||||
|
const titleWorldParallax = anime({
|
||||||
|
targets: titleWorld,
|
||||||
|
translateX: ['5%', '-3%'],
|
||||||
|
easing: 'linear',
|
||||||
|
duration: animDuration,
|
||||||
|
autoplay: false
|
||||||
|
})
|
||||||
|
const titleWorldAnime = () => parallaxAnime(titleWorld, titleWorldParallax)
|
||||||
|
const titleWorldScroll = ScrollOut({
|
||||||
|
once: true,
|
||||||
|
targets: titleWorld,
|
||||||
|
onShown: () => {
|
||||||
|
titleWorldReveal.restart()
|
||||||
window.addEventListener('scroll', throttle(titleWorldAnime, 10))
|
window.addEventListener('scroll', throttle(titleWorldAnime, 10))
|
||||||
requestAnimationFrame(titleWorldAnime)
|
requestAnimationFrame(titleWorldAnime)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user