From a673646645f2a7a17d48d3e6741bb28e9af8deb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Mon, 5 Aug 2024 15:06:25 +0200 Subject: [PATCH 1/4] fix: use correct CustomEvent for email copying --- apps/website/src/routes/(site)/about/+page.svelte | 2 +- apps/website/src/utils/functions/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/website/src/routes/(site)/about/+page.svelte b/apps/website/src/routes/(site)/about/+page.svelte index 5b3dcd0..52e8dc6 100644 --- a/apps/website/src/routes/(site)/about/+page.svelte +++ b/apps/website/src/routes/(site)/about/+page.svelte @@ -379,7 +379,7 @@ in:fly={{ y: 4, duration: 325, easing: quartOutSvelte, delay: 250 }} out:fade={{ duration: 250, easing: quartOutSvelte }} use:mailtoClipboard - oncopied={(email: string) => { + oncopied={({ detail: email }: CustomEvent) => { emailCopied = email // Clear timeout and add timeout to hide message clearTimeout(emailCopiedTimeout) diff --git a/apps/website/src/utils/functions/index.ts b/apps/website/src/utils/functions/index.ts index c5f6f38..a7a564c 100644 --- a/apps/website/src/utils/functions/index.ts +++ b/apps/website/src/utils/functions/index.ts @@ -14,7 +14,7 @@ export const mailtoClipboard = (node: HTMLElement) => { navigator.clipboard.writeText(emailAddress) // Send event - node.dispatchEvent(new CustomEvent('copied', emailAddress)) + node.dispatchEvent(new CustomEvent('copied', { detail: emailAddress })) // Record event in analytics sendEvent('emailCopy') From 2a29a32ff4ce33576c7e5076ef7f3db72b57cc51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Mon, 5 Aug 2024 15:06:48 +0200 Subject: [PATCH 2/4] fix: use correct data bindings for About page metas --- apps/website/src/routes/(site)/about/+page.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/website/src/routes/(site)/about/+page.svelte b/apps/website/src/routes/(site)/about/+page.svelte index 52e8dc6..3d9578f 100644 --- a/apps/website/src/routes/(site)/about/+page.svelte +++ b/apps/website/src/routes/(site)/about/+page.svelte @@ -174,7 +174,7 @@ From 1cc143ef275d1f2f38fed1f71237361ff8dbb646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Mon, 5 Aug 2024 15:35:08 +0200 Subject: [PATCH 3/4] fix: various issues to reduce effect_update_depth_exceeded + use `scroll` from Motion One for parallax --- .../components/atoms/ScrollingTitle.svelte | 2 +- .../molecules/Location/Location.svelte | 2 +- .../molecules/Switcher/Switcher.svelte | 2 +- .../InteractiveGlobe/InteractiveGlobe.svelte | 4 +- .../organisms/ShopBanner/ShopBanner.svelte | 4 +- .../(site)/[country]/[location]/+page.svelte | 61 +++++++++---------- .../src/routes/(site)/about/+page.svelte | 23 ++++--- apps/website/src/style/pages/_about.scss | 2 +- apps/website/src/style/pages/_location.scss | 4 +- 9 files changed, 50 insertions(+), 54 deletions(-) diff --git a/apps/website/src/components/atoms/ScrollingTitle.svelte b/apps/website/src/components/atoms/ScrollingTitle.svelte index 31a5cf1..96668d2 100644 --- a/apps/website/src/components/atoms/ScrollingTitle.svelte +++ b/apps/website/src/components/atoms/ScrollingTitle.svelte @@ -35,7 +35,7 @@ let scrollY = $state() let innerWidth = $state() let innerHeight = $state() - let titleEl = $state() + let titleEl: HTMLElement // Check if title is larger than viewport to translate it const isLarger = $derived(titleEl && titleEl.offsetWidth >= innerWidth) diff --git a/apps/website/src/components/molecules/Location/Location.svelte b/apps/website/src/components/molecules/Location/Location.svelte index 0d994a3..d278b87 100644 --- a/apps/website/src/components/molecules/Location/Location.svelte +++ b/apps/website/src/components/molecules/Location/Location.svelte @@ -24,7 +24,7 @@ const { settings }: any = getContext('global') - let locationEl = $state() + let locationEl: HTMLElement let photoIndex = $state(0) // Location date limit diff --git a/apps/website/src/components/molecules/Switcher/Switcher.svelte b/apps/website/src/components/molecules/Switcher/Switcher.svelte index b361348..f617675 100644 --- a/apps/website/src/components/molecules/Switcher/Switcher.svelte +++ b/apps/website/src/components/molecules/Switcher/Switcher.svelte @@ -12,7 +12,7 @@ const { settings: { switcher_links } }: any = getContext('global') - let switcherEl = $state() + let switcherEl: HTMLElement let isOpen = $state(false) diff --git a/apps/website/src/components/organisms/InteractiveGlobe/InteractiveGlobe.svelte b/apps/website/src/components/organisms/InteractiveGlobe/InteractiveGlobe.svelte index 6414965..d3a40a6 100644 --- a/apps/website/src/components/organisms/InteractiveGlobe/InteractiveGlobe.svelte +++ b/apps/website/src/components/organisms/InteractiveGlobe/InteractiveGlobe.svelte @@ -33,8 +33,8 @@ } = $props() let innerWidth = $state() - let globeParentEl = $state() - let globeEl = $state() + let globeParentEl: HTMLElement + let globeEl: HTMLElement let globe = $state() let observer: IntersectionObserver let animation = $state() diff --git a/apps/website/src/components/organisms/ShopBanner/ShopBanner.svelte b/apps/website/src/components/organisms/ShopBanner/ShopBanner.svelte index 0cc1625..50a470b 100644 --- a/apps/website/src/components/organisms/ShopBanner/ShopBanner.svelte +++ b/apps/website/src/components/organisms/ShopBanner/ShopBanner.svelte @@ -21,8 +21,8 @@ let innerWidth = $state() let navObserver: IntersectionObserver - let introEl = $state() - let navChooseEl = $state() + let introEl: HTMLElement + let navChooseEl: HTMLElement let scrolledPastIntro = $state(false) diff --git a/apps/website/src/routes/(site)/[country]/[location]/+page.svelte b/apps/website/src/routes/(site)/[country]/[location]/+page.svelte index ce133e2..ff019bf 100644 --- a/apps/website/src/routes/(site)/[country]/[location]/+page.svelte +++ b/apps/website/src/routes/(site)/[country]/[location]/+page.svelte @@ -5,7 +5,7 @@ - - -
+

Houses @@ -269,7 +266,7 @@ {#if location?.hero?.id} - + () let innerWidth = $state() - let innerHeight = $state() - let photosGridEl = $state() - let photosGridOffset = $state() + let photosGridEl: HTMLElement + let photosGridParallax = $state() let currentStep = $state(0) let emailCopied = $state() let emailCopiedTimeout: ReturnType | number - const parallaxPhotos = $derived(photosGridEl && map(scrollY, photosGridOffset - innerHeight, photosGridOffset + innerHeight / 1.5, 0, innerHeight * 0.15, true)) const fadedPhotosIndexes = $derived( innerWidth > 768 ? [0, 2, 5, 7, 9, 12, 17, 20, 22, 26, 30, 32, 34] @@ -41,9 +38,11 @@ $effect(() => { - // Update photos grid top offset - photosGridOffset = photosGridEl.offsetTop - + // Add parallax to photos grid + scroll(({ y }) => photosGridParallax = lerp(-15, 10, y.progress), { + target: photosGridEl, + offset: ['start end', 'end start'] + }) /** * Animations @@ -171,7 +170,7 @@ }) - +
-
+
{#each data.photos as { image: { id }, title }, index} Date: Mon, 5 Aug 2024 16:28:14 +0200 Subject: [PATCH 4/4] refactor: rethink ProcessStep transition + use tick in transitions --- apps/website/src/animations/transitions.ts | 56 ++++++++++--------- .../molecules/ProcessStep/ProcessStep.svelte | 7 +-- .../src/routes/(site)/about/+page.svelte | 29 +++++----- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/apps/website/src/animations/transitions.ts b/apps/website/src/animations/transitions.ts index df45e23..a7ba82f 100644 --- a/apps/website/src/animations/transitions.ts +++ b/apps/website/src/animations/transitions.ts @@ -9,24 +9,25 @@ import { quartOut } from './easings' export const scaleFade = (node: HTMLElement, { scale = [0.7, 1], opacity = [1, 0], - x = null, + x = [0, 0], delay = 0, - duration = 1, + duration = 0.75, }): TransitionConfig => { - return { - css: () => { - animate(node, { - scale, - opacity, - x, - z: 0, - }, { - easing: quartOut, - duration, - delay, - }) + const anim = animate(node, { + scale, + opacity, + x, + z: 0, + }, { + easing: quartOut, + duration, + delay, + }) - return null + return { + duration: anim.duration * 1000, + tick: (t) => { + anim.currentTime = t } } } @@ -42,19 +43,20 @@ export const revealSplit = (node: HTMLElement, { duration = 1, delay = 0, }): TransitionConfig => { - return { - css: () => { - animate(node.querySelectorAll(children), { - opacity, - y, - z: 0, - }, { - easing: quartOut, - duration, - delay: stagger(0.04, { start: delay }), - }) + const anim = animate(node.querySelectorAll(children), { + opacity, + y, + z: 0, + }, { + easing: quartOut, + duration, + delay: stagger(0.04, { start: delay }), + }) - return null + return { + duration: anim.duration * 1000, + tick: (t) => { + anim.currentTime = t } } } diff --git a/apps/website/src/components/molecules/ProcessStep/ProcessStep.svelte b/apps/website/src/components/molecules/ProcessStep/ProcessStep.svelte index 2ca6951..41b1a4e 100644 --- a/apps/website/src/components/molecules/ProcessStep/ProcessStep.svelte +++ b/apps/website/src/components/molecules/ProcessStep/ProcessStep.svelte @@ -3,18 +3,18 @@