Files
housesof/src/animations/TitleSite.js
Félix Péault be0f4c8b59 Optimize animations and transitions
will-change is apparently not enough to run GPU-enabled animations, use translateZ on top of it
2020-04-09 20:23:24 +02:00

28 lines
663 B
JavaScript

import anime from 'animejs'
import ScrollOut from 'scroll-out'
import { animDelay } from 'utils/store'
/*
** Transition In
*/
export const animateIn = (scope, init) => {
// Stagger each letters and words
const letters = anime({
targets: scope.querySelectorAll('span, em span'),
translateY: ['100%', 0],
translateZ: [0, 0],
easing: 'easeOutQuart',
duration: 1000,
delay: anime.stagger(40, { start: init ? 0 : animDelay }),
autoplay: false
})
// On scroll animation
const title = ScrollOut({
once: true,
targets: scope,
onShown: () => letters.restart()
})
}