Page and components animations rework WIP
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-04-03 23:03:00 +02:00
parent 7e0d1e33fb
commit 462359fcf2
10 changed files with 147 additions and 261 deletions

View File

@@ -1,36 +1,38 @@
import anime from 'animejs' import anime from 'animejs'
import ScrollOut from 'scroll-out' import ScrollOut from 'scroll-out'
import { transitionNormal, transitionDelay } from 'utils/store' import { animDuration, animDelay } from 'utils/store'
/* /*
** Transition In ** Transition In
*/ */
export const animateIn = scope => { export const animateIn = scope => {
// Timeline
const tl = anime.timeline({ const tl = anime.timeline({
easing: 'easeOutQuart', easing: 'easeOutQuart',
duration: transitionNormal, duration: animDuration
delay: transitionDelay
}) })
// Photo: Active // Photo: Active
tl.add({ tl.add({
targets: scope.querySelector('.is-active picture'), targets: scope.querySelector('.is-active picture'),
translateY: [32, 0] translateY: [32, 0]
}, 400) })
// Photo: Prev // Photo: Prev
tl.add({ tl.add({
targets: scope.querySelector('.is-prev picture'), targets: scope.querySelector('.is-prev picture'),
translateY: [8, 0], translateY: [8, 0],
translateX: [64, 0] translateX: [64, 0],
}, 550) rotate: [-2, 0]
}, 100)
// Photo: Next // Photo: Next
tl.add({ tl.add({
targets: scope.querySelector('.is-next picture'), targets: scope.querySelector('.is-next picture'),
translateY: [8, 0], translateY: [8, 0],
translateX: [-48, 0] translateX: [-48, 0],
}, 550) rotate: [2, 0]
}, 150)
// Reveal on scroll
const carouselIn = ScrollOut({ const carouselIn = ScrollOut({
once: true, once: true,
targets: scope, targets: scope,

View File

@@ -1,17 +1,12 @@
import anime from 'animejs' import anime from 'animejs'
import ScrollOut from 'scroll-out' import ScrollOut from 'scroll-out'
import { transitionLong } from 'utils/store' import { animDurationLong } from 'utils/store'
/* /*
** Transition In ** Transition In
*/ */
export const animateIn = scope => { export const animateIn = scope => {
// Each location
const locations = ScrollOut({
targets: scope.querySelectorAll('.location'),
onShown (el) {
// Timeline
const tl = anime.timeline({ const tl = anime.timeline({
autoplay: false, autoplay: false,
duration: 600, duration: 600,
@@ -21,7 +16,7 @@ export const animateIn = scope => {
// Image // Image
tl.add({ tl.add({
targets: el.querySelector('img'), targets: scope.querySelector('img'),
scale: [1.3, 1], scale: [1.3, 1],
opacity: [0, 1], opacity: [0, 1],
duration: 1800, duration: 1800,
@@ -30,18 +25,22 @@ export const animateIn = scope => {
// Name // Name
tl.add({ tl.add({
targets: el.querySelector('h3'), targets: scope.querySelector('h3'),
translateY: ['100%', 0] translateY: ['100%', 0]
}, 300) }, 300)
// Country // Country
tl.add({ tl.add({
targets: el.querySelector('p'), targets: scope.querySelector('p'),
translateY: ['100%', 0] translateY: ['100%', 0]
}, 550) }, 550)
// Play
tl.play() // Each location (reveal on scroll)
const locations = ScrollOut({
targets: scope.querySelectorAll('.location'),
onShown (el) {
tl.restart()
} }
}) })
} }

View File

@@ -9,7 +9,7 @@ import { parallaxAnime } from 'utils/functions'
** Transition In ** Transition In
*/ */
export const animateIn = scope => { export const animateIn = scope => {
// Title appearing // Title (reveal on scroll)
const titleReveal = ScrollOut({ const titleReveal = ScrollOut({
once: true, once: true,
targets: scope, targets: scope,
@@ -25,7 +25,7 @@ export const animateIn = scope => {
} }
}) })
// Photo appearing // Photo (reveal on scroll)
const photoReveal = ScrollOut({ const photoReveal = ScrollOut({
once: true, once: true,
targets: scope.querySelector('.photo__image'), targets: scope.querySelector('.photo__image'),

View File

@@ -1,34 +1,27 @@
import anime from 'animejs' import anime from 'animejs'
import ScrollOut from 'scroll-out' import ScrollOut from 'scroll-out'
import { transitionDelay } from 'utils/store'
/* /*
** Transition In ** Transition In
*/ */
export const animateIn = (scope, init) => { export const animateIn = (scope, init) => {
const tl = anime.timeline({
easing: 'easeOutQuart',
duration: 1000
})
// Stagger each letters and words
tl.add({
targets: scope.querySelectorAll('span, em span'),
translateY: ['100%', 0],
delay: anime.stagger(40),
})
// On scroll animation // On scroll animation
const title = ScrollOut({ const title = ScrollOut({
once: true, once: true,
targets: scope, targets: scope,
onShown (el) { onShown: () => tl.restart()
// Each letters
anime({
targets: el.querySelectorAll('span'),
translateY: ['100%', 0],
easing: 'easeOutQuart',
delay: anime.stagger(40, { start: init ? 0 : transitionDelay }),
duration: 1000
})
// Word in between
anime({
targets: el.querySelectorAll('em span'),
opacity: [0, 1],
delay: anime.stagger(80, { start: (init ? 0 : transitionDelay) + 400 }),
duration: 1000,
easing: 'easeOutQuart'
})
}
}) })
} }

View File

@@ -1,75 +1,16 @@
import anime from 'animejs' import { quartInOut } from 'svelte/easing'
import { transitionNormal, transitionLong, transitionPanelIn } from 'utils/store'
/* /*
** Transition In ** Animation Out: Background
*/ */
export const animateIn = scope => { export const panelBackgroundOut = (node, params) => {
const tl = anime.timeline({ return {
duration: transitionPanelIn, delay: params.delay || 0,
easing: 'easeInOutQuart', duration: params.duration || 400,
begin: () => { easing: params.easing || quartInOut,
// Show the panel css: (t, u) => `
scope.classList.remove('hidden') transform: scaleY(${t})
`
} }
})
// Panel itself
tl.add({
targets: scope.querySelector('.transition__background'),
scaleY: [1, 1],
opacity: [0, 1],
duration: transitionPanelIn
}, 0)
// Globe icon
tl.add({
targets: scope.querySelector('svg'),
opacity: [0, 1],
translateY: ['3vh', 0],
duration: transitionPanelIn
}, 0)
}
/*
** Transition Out
*/
export const animateOut = (scope, callback) => {
const tl = anime.timeline({
easing: 'easeInOutQuart',
complete: () => {
// Hide the panel
scope.classList.add('hidden')
// Run callback
callback()
}
})
// Background
tl.add({
targets: scope.querySelector('.transition__background'),
scaleY: [1, 0],
duration: transitionLong
}, 600)
// Title
tl.add({
targets: scope.querySelector('.title-location'),
opacity: [1, 0],
translateY: [0, '-50vh'],
duration: transitionNormal
}, 850)
// Globe icon
tl.add({
targets: scope.querySelector('svg'),
opacity: [1, 0],
translateY: [0, '-50vh'],
duration: transitionNormal
}, 850)
// Play
tl.play()
} }

View File

@@ -1,6 +1,6 @@
import anime from 'animejs' import anime from 'animejs'
import ScrollOut from 'scroll-out' import ScrollOut from 'scroll-out'
import { transitionNormal, transitionLong, transitionDelay } from 'utils/store' import { animDuration, animDelay } from 'utils/store'
import { throttle, parallaxAnime } from 'utils/functions' import { throttle, parallaxAnime } from 'utils/functions'
@@ -9,16 +9,11 @@ import { throttle, parallaxAnime } from 'utils/functions'
*/ */
export const animateIn = () => { export const animateIn = () => {
// Title: Houses // Title: Houses
// const titleHouses = ScrollOut({ const titleHouses = anime({
// once: true,
// targets: '#title-houses',
// onShown (el) {
// Reveal each letter
anime({
targets: document.querySelectorAll('#title-houses span'), targets: document.querySelectorAll('#title-houses span'),
translateY: ['-70%', 0], translateY: ['-70%', 0],
delay: anime.stagger(80, { start: transitionDelay }), delay: anime.stagger(80, { start: animDelay }),
duration: transitionNormal, duration: animDuration,
easing: 'easeOutQuart' easing: 'easeOutQuart'
}) })
@@ -28,48 +23,39 @@ export const animateIn = () => {
translateX: ['7%', '-15%'], translateX: ['7%', '-15%'],
easing: 'linear', easing: 'linear',
autoplay: false, autoplay: false,
duration: transitionNormal duration: animDuration
}) })
window.addEventListener('scroll', throttle(() => parallaxAnime(document.getElementById('title-houses'), translate), 10)) window.addEventListener('scroll', throttle(() => parallaxAnime(document.getElementById('title-houses'), translate), 10))
setTimeout(() => parallaxAnime(document.getElementById('title-houses'), translate), 50) setTimeout(() => parallaxAnime(document.getElementById('title-houses'), translate), 50)
// },
// onHidden: () => window.removeEventListener('scroll', parallaxAnime)
// })
// Intro: Description // Intro: Description
// const introDescription = ScrollOut({ const introDescription = anime({
// once: true, targets: document.getElementById('intro-description').querySelectorAll('p, a'),
// targets: '#intro-description',
// onShown (el) {
anime({
targets: '#intro-description p, #intro-description a',
opacity: [0, 1], opacity: [0, 1],
translateY: [8, 0], translateY: [8, 0],
easing: 'easeOutQuart', easing: 'easeOutQuart',
duration: transitionNormal, duration: animDuration,
delay: anime.stagger(200, { start: transitionDelay + 400 }) delay: anime.stagger(200, { start: animDelay + 200 })
}) })
// }
// })
// Intro: Carousel // Intro: Carousel revealing (scroll)
// const introCarousel = ScrollOut({ const introCarousel = ScrollOut({
// once: true, once: true,
// targets: '#intro-carousel', targets: '#intro-carousel',
// onShown (el) { onShown (el) {
anime({ anime({
targets: '#intro-carousel', targets: '#intro-carousel',
opacity: [0, 1], opacity: [0, 1],
translateY: [24, 0], translateY: [24, 0],
easing: 'easeOutQuart', easing: 'easeOutQuart',
duration: transitionNormal, duration: animDuration,
delay: transitionDelay + 600, delay: animDelay + 400,
complete: event => event.animatables[0].target.removeAttribute('style') complete: event => event.animatables[0].target.removeAttribute('style')
}) })
// } }
// }) })
// Title: Of // Title: Of (reveal on scroll)
const titleOf = ScrollOut({ const titleOf = ScrollOut({
once: true, once: true,
targets: '#title-of', targets: '#title-of',
@@ -79,51 +65,35 @@ export const animateIn = () => {
translateY: ['100%', 0], translateY: ['100%', 0],
easing: 'easeOutQuart', easing: 'easeOutQuart',
delay: anime.stagger(70), delay: anime.stagger(70),
duration: transitionNormal duration: animDuration
}) })
} }
}) })
// Title: World // Title: World (reveal on scroll)
const titleWorldLetters = anime({
targets: scope.querySelectorAll('span'),
translateY: ['100%', 0],
easing: 'easeOutQuart',
delay: anime.stagger(70),
duration: animDuration,
autoplay: false
})
const titleWorldTranslate = anime({
targets: scope,
translateX: ['5%', '-3%'],
easing: 'linear',
autoplay: false,
duration: animDuration
})
// Reveal on scroll
const titleWorld = ScrollOut({ const titleWorld = ScrollOut({
once: true, once: true,
targets: '#title-world', targets: '#title-world',
onShown (el) { onShown (el) {
anime({ window.addEventListener('scroll', throttle(() => parallaxAnime(el, titleWorldTranslate), 10))
targets: el.querySelectorAll('span'), setTimeout(() => parallaxAnime(el, titleWorldTranslate), 50)
translateY: ['100%', 0],
easing: 'easeOutQuart',
delay: anime.stagger(70),
duration: transitionNormal
})
// Parallax on scroll
const translate = anime({
targets: el,
translateX: ['5%', '-3%'],
easing: 'linear',
autoplay: false,
duration: transitionNormal
})
window.addEventListener('scroll', throttle(() => parallaxAnime(el, translate), 10))
setTimeout(() => parallaxAnime(el, translate), 50)
}, },
onHidden: () => window.removeEventListener('scroll', parallaxAnime) onHidden: () => window.removeEventListener('scroll', parallaxAnime)
}) })
} }
/*
** Transition Out
*/
export const animateOut = () => {
anime({
targets: document.querySelector('#title-houses'),
translateY: ['-70%', 0],
opacity: [1, 0],
duration: transitionNormal,
easing: 'easeOutQuart'
})
}

View File

@@ -1,6 +1,5 @@
import anime from 'animejs' import anime from 'animejs'
import ScrollOut from 'scroll-out' import { animDuration, animDelay } from 'utils/store'
import { transitionNormal, transitionDelay } from 'utils/store'
/* /*
@@ -8,18 +7,12 @@ import { transitionNormal, transitionDelay } from 'utils/store'
*/ */
export const animateIn = () => { export const animateIn = () => {
// Simple slide and fade on each part of the page // Simple slide and fade on each part of the page
// const page = ScrollOut({
// once: true,
// targets: '.page',
// onShown (el) {
anime({ anime({
targets: document.querySelectorAll('.page__part'), targets: document.querySelectorAll('.page__part'),
opacity: [0, 1], opacity: [0, 1],
translateY: [8, 0], translateY: [8, 0],
easing: 'easeOutQuart', easing: 'easeOutQuart',
duration: transitionNormal, duration: animDuration,
delay: anime.stagger(220, { start: transitionDelay }), delay: anime.stagger(220, { start: animDelay }),
}) })
// }
// })
} }

View File

@@ -1,6 +1,5 @@
import anime from 'animejs' import anime from 'animejs'
// import ScrollOut from 'scroll-out' import { animDuration, animDelay } from 'utils/store'
import { transitionNormal, transitionDelay } from 'utils/store'
/* /*
@@ -8,54 +7,45 @@ import { transitionNormal, transitionDelay } from 'utils/store'
*/ */
export const animateIn = () => { export const animateIn = () => {
const tl = anime.timeline({ const tl = anime.timeline({
duration: 1800, duration: animDuration,
delay: transitionDelay, // Delay in AnimeJS waits to run but sets the starting style as opposed to a setTimeout delay: animDelay, // Delay in AnimeJS waits to run but sets the starting style as opposed to a setTimeout
easing: 'easeOutQuart' easing: 'easeOutQuart'
}) })
// Title: Houses // Title: Houses
tl.add({ tl.add({
targets: '.place__title_houses', targets: '.place__title_houses',
translateY: ['150%', 0], translateY: ['150%', 0]
duration: transitionNormal })
}, 200)
// Title: Of // Title: Of
tl.add({ tl.add({
targets: '.place__title_of', targets: '.place__title_of',
opacity: [0, 1], opacity: [0, 1]
duration: transitionNormal }, 600)
}, 800)
// Title: Place name // Title: Place name
tl.add({ tl.add({
targets: '.place__title_name', targets: '.place__title_name',
translateY: ['150%', 0], translateY: ['150%', 0]
duration: transitionNormal }, 150)
}, 350)
// Switcher link // Switcher link
tl.add({ tl.add({
targets: '.place__title .button-control', targets: '.place__title .button-control',
scale: [0.95, 1], scale: [0.95, 1],
opacity: [0, 1], opacity: [0, 1]
duration: transitionNormal }, 500)
}, 700)
// Illustration // Illustration
tl.add({ tl.add({
targets: '.place__illustration', targets: '.place__illustration',
scale: [1.075, 1], scale: [1.075, 1],
opacity: [0, 1], opacity: [0, 1]
duration: transitionNormal }, 0)
}, 200)
// Description // Description
tl.add({ tl.add({
targets: '.place__description', targets: '.place__description',
opacity: [0, 1], opacity: [0, 1],
translateY: [24, 0], translateY: [24, 0]
duration: transitionNormal }, 450)
}, 650)
// Play
tl.play()
} }

View File

@@ -1,37 +1,35 @@
import anime from 'animejs' import anime from 'animejs'
import { transitionNormal } from 'utils/store' import { animDuration } from 'utils/store'
/* /*
** Transition In ** Transition In
*/ */
export const animateIn = () => { export const animateIn = () => {
const tl = anime.timeline({
easing: 'easeOutQuart',
duration: animDuration
})
// Buttons // Buttons
anime({ tl.add({
targets: '.viewer__top p, .viewer__top .buttons a', targets: '.viewer__top p, .viewer__top .buttons a',
translateY: [-32, 0], translateY: [-32, 0],
duration: transitionNormal,
delay: anime.stagger(150, { start: 600 }), delay: anime.stagger(150, { start: 600 }),
easing: 'easeOutQuart'
}) })
// Carousel // Carousel
anime({ tl.add({
targets: '.viewer .carousel', targets: '.viewer .carousel',
opacity: [0, 1], opacity: [0, 1],
translateY: window.innerWidth >= 768 ? [32, 0] : ['-33%', '-37%'], translateY: window.innerWidth >= 768 ? [32, 0] : ['-33%', '-37%']
duration: transitionNormal, }, 300)
delay: 300,
easing: 'easeOutQuart'
})
// Carousel: Number // Carousel: Number
anime({ tl.add({
targets: '.viewer .carousel__number_column', targets: '.viewer .carousel__number_column',
opacity: [0, 1], opacity: [0, 1],
marginTop: [24, 0], marginTop: [24, 0],
duration: transitionNormal, delay: anime.stagger(100)
delay: anime.stagger(100, { start: 450 }), }, 450)
easing: 'easeOutQuart'
})
} }