From 7d4899fa48eb8fa656e64484714be44f97abba05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Tue, 14 Jun 2022 23:14:12 +0200 Subject: [PATCH] Keep original photos ratio if not 3/2 on Viewer - Fix previousPage usage - Fix entering animation timings and previous photo navigation - Add fade transition on fullscreen viewer for mobile - Display date only if existing --- .../[country]/[location]/[photo].svelte | 31 ++++++++++++------- src/routes/[country]/[location]/[photo].ts | 1 + src/style/pages/_viewer.scss | 29 +++++++++-------- 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/routes/[country]/[location]/[photo].svelte b/src/routes/[country]/[location]/[photo].svelte index 02a8cb0..f7989bf 100644 --- a/src/routes/[country]/[location]/[photo].svelte +++ b/src/routes/[country]/[location]/[photo].svelte @@ -3,7 +3,7 @@ import { page } from '$app/stores' import { goto } from '$app/navigation' import { onMount, tick } from 'svelte' - import { scale } from 'svelte/transition' + import { fade, scale } from 'svelte/transition' import { quartOut } from 'svelte/easing' import { getAssetUrlKey } from '$utils/helpers' import { fetchAPI } from '$utils/api' @@ -66,7 +66,7 @@ } // Define previous URL - $: previousUrl = $previousPage ?? `/${location.country.slug}/${location.slug}` + $: previousUrl = $previousPage ? $previousPage : `/${location.country.slug}/${location.slug}` /** @@ -130,7 +130,7 @@ await tick() const picture = fullscreenEl.querySelector('picture') const image = fullscreenEl.querySelector('img') - picture.scrollTo((image.offsetWidth - innerWidth) / 2, 0) + picture.scrollTo((image.offsetWidth - innerWidth / 2), 0) } } } @@ -221,6 +221,7 @@ const timeline: AnimeTimelineInstance = anime.timeline({ duration: 1600, easing: 'easeOutQuart', + autoplay: false, }) anime.set('.viewer__picture', { @@ -238,14 +239,14 @@ duration: 900, }, 250) timeline.add({ - targets: '.viewer__picture:not(.is-0):not(.is-1)', + targets: '.viewer__picture:not(.is-1)', opacity: 1, translateX (element: HTMLElement, index: number) { const x = getComputedStyle(element).getPropertyValue('--offset-x').trim() return [`-${x}`, 0] }, delay: anime.stagger(55) - }, 500) + }, 350) // Prev/Next buttons timeline.add({ @@ -282,7 +283,7 @@ translateY: ['100%', 0], delay: anime.stagger(200), duration: 1000, - }, 700) + }, 1100) // Transition in requestAnimationFrame(timeline.play) @@ -320,12 +321,12 @@ {#if isFullscreen} -
+