From bdf93e89fb175bbfb590d1d22ae2919f3de9fb9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Tue, 21 Apr 2020 13:09:11 +0200 Subject: [PATCH] Last little fixes and debugging --- src/animations/Carousel.js | 35 ++++++++++++++----- src/animations/viewer.js | 11 ++---- src/atoms/TitleSite.svelte | 4 +-- src/organisms/Carousel.svelte | 3 +- src/routes/_layout.svelte | 4 +-- .../viewer/[country]/[place]/[photo].svelte | 32 ++++++++--------- src/style/organisms/_fullscreen.scss | 1 + src/style/pages/_viewer.scss | 2 +- src/utils/Transition.svelte | 12 +++---- 9 files changed, 56 insertions(+), 48 deletions(-) diff --git a/src/animations/Carousel.js b/src/animations/Carousel.js index cc9fb50..1f36dd1 100644 --- a/src/animations/Carousel.js +++ b/src/animations/Carousel.js @@ -10,7 +10,6 @@ export const animateIn = scope => { const tl = anime.timeline({ easing: 'easeOutQuart', duration: animDuration, - // delay: animDelay, autoplay: false }) @@ -27,7 +26,8 @@ export const animateIn = scope => { tl.add({ targets: scope.querySelector('.is-active picture'), translateY: [8, 0], - translateZ: [0, 0] + translateZ: [0, 0], + complete: event => event.animatables[0].target.removeAttribute('style') }, 100) // Photo: Prev @@ -36,7 +36,8 @@ export const animateIn = scope => { translateY: [8, 0], translateX: [64, 0], translateZ: [0, 0], - rotate: window.innerWidth >= 768 ? [-2, 0] : [0, 0] + rotate: window.innerWidth >= 768 ? [-2, 0] : [0, 0], + complete: event => event.animatables[0].target.removeAttribute('style') }, 100) // Photo: Next @@ -45,13 +46,31 @@ export const animateIn = scope => { translateY: [8, 0], translateX: [-48, 0], translateZ: [0, 0], - rotate: window.innerWidth >= 768 ? [2, 0] : [0, 0] + rotate: window.innerWidth >= 768 ? [2, 0] : [0, 0], + complete: event => event.animatables[0].target.removeAttribute('style') }, 100) // Reveal on scroll - const carouselIn = ScrollOut({ - once: true, - targets: scope, - onShown: () => tl.restart() + let visible = false + requestAnimationFrame(() => { + const carouselReveal = ScrollOut({ + once: true, + targets: scope, + onChange: (el, ctx) => { + if (ctx.visible === 0) { + visible = true + } + }, + onShown: (el, ctx) => { + // If revealed on scroll, no delay + if (visible) { + tl.restart() + } + // If revealed on load, add a delay + else { + setTimeout(() => tl.restart(), animDelay * 2) + } + } + }) }) } \ No newline at end of file diff --git a/src/animations/viewer.js b/src/animations/viewer.js index 3df09d6..dd9b7dc 100644 --- a/src/animations/viewer.js +++ b/src/animations/viewer.js @@ -7,18 +7,11 @@ import { animDuration, animDelay } from 'utils/store' */ export const animateIn = () => { const viewer = document.querySelector('.viewer') + const tl = anime.timeline({ easing: 'easeOutQuart', duration: animDuration, - delay: animDelay - }) - - // Carousel - tl.add({ - targets: viewer.querySelector('.carousel .wrap'), - opacity: [0, 1], - translateY: ['-4%', 0], - translateZ: [0, 0] + delay: 1400 }) // Carousel: Number diff --git a/src/atoms/TitleSite.svelte b/src/atoms/TitleSite.svelte index 98a86b6..27965cd 100644 --- a/src/atoms/TitleSite.svelte +++ b/src/atoms/TitleSite.svelte @@ -19,11 +19,11 @@ }) -
-
+
{@html charsToSpan('Houses')}
diff --git a/src/organisms/Carousel.svelte b/src/organisms/Carousel.svelte index ca321df..e287060 100644 --- a/src/organisms/Carousel.svelte +++ b/src/organisms/Carousel.svelte @@ -135,8 +135,7 @@ -