Photo: Fix scroll and reveal
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
import anime from 'animejs'
|
import anime from 'animejs'
|
||||||
import ScrollOut from 'scroll-out'
|
import ScrollOut from 'scroll-out'
|
||||||
import imagesLoaded from 'imagesloaded'
|
import imagesLoaded from 'imagesloaded'
|
||||||
import { parallaxAnime } from 'utils/functions'
|
import { throttle, parallaxAnime } from 'utils/functions'
|
||||||
// import { animDuration, animDurationLong } from 'utils/store'
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -12,36 +11,37 @@ export const animateIn = scope => {
|
|||||||
// Title (reveal on scroll)
|
// Title (reveal on scroll)
|
||||||
const titleReveal = ScrollOut({
|
const titleReveal = ScrollOut({
|
||||||
once: true,
|
once: true,
|
||||||
targets: scope,
|
targets: scope.querySelector('h2'),
|
||||||
onShown (el) {
|
onShown (el) {
|
||||||
// Title reveal
|
// Title reveal
|
||||||
anime({
|
anime({
|
||||||
targets: el.querySelectorAll('h2 span'),
|
targets: el.querySelectorAll('span'),
|
||||||
translateY: ['100%', 0],
|
translateY: ['100%', 0],
|
||||||
|
easing: 'easeOutQuart',
|
||||||
duration: 1000,
|
duration: 1000,
|
||||||
delay: anime.stagger(120),
|
delay: anime.stagger(120)
|
||||||
easing: 'easeOutQuart'
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Photo (reveal on scroll)
|
// Photo (reveal on scroll)
|
||||||
const photoReveal = ScrollOut({
|
imagesLoaded(scope.querySelector('.photo__image'), instance => {
|
||||||
once: true,
|
const image = instance.elements[0]
|
||||||
targets: scope.querySelector('.photo__image'),
|
const photoReveal = ScrollOut({
|
||||||
onShown (el) {
|
once: true,
|
||||||
// Load the photo then reveal it
|
targets: image,
|
||||||
imagesLoaded(el, instance => {
|
onShown (el) {
|
||||||
|
// Load the photo then reveal it
|
||||||
anime({
|
anime({
|
||||||
targets: el.querySelector('img'),
|
targets: el.querySelector('img'),
|
||||||
scale: [1.12, 1],
|
scale: [1.12, 1],
|
||||||
opacity: [0, 1],
|
opacity: [0, 1],
|
||||||
|
easing: 'easeOutQuart',
|
||||||
duration: 2000,
|
duration: 2000,
|
||||||
delay: 50,
|
delay: 50
|
||||||
easing: 'easeOutQuart'
|
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Number parallax on scroll
|
// Number parallax on scroll
|
||||||
@@ -58,11 +58,12 @@ export const animateIn = scope => {
|
|||||||
easing: 'linear',
|
easing: 'linear',
|
||||||
autoplay: false
|
autoplay: false
|
||||||
})
|
})
|
||||||
window.addEventListener('scroll', () => parallaxAnime(el, translate))
|
window.addEventListener('scroll', throttle(() => parallaxAnime(el, translate), 50))
|
||||||
setTimeout(() => parallaxAnime(el, translate), 50)
|
setTimeout(() => parallaxAnime(el, translate), 50)
|
||||||
|
console.log('show')
|
||||||
},
|
},
|
||||||
onHidden () {
|
onHidden () {
|
||||||
window.removeEventListener('scroll', parallaxAnime)
|
if (parallaxAnime) window.removeEventListener('scroll', parallaxAnime)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user