From ac3070b0b7850376dec52f9dcd2a2c2ad54b2de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Tue, 12 Nov 2024 15:12:06 +0100 Subject: [PATCH] fix: exceeded effect on Photos page? --- .../src/routes/(site)/photos/+page.svelte | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/apps/website/src/routes/(site)/photos/+page.svelte b/apps/website/src/routes/(site)/photos/+page.svelte index 0c640f0..b02d975 100644 --- a/apps/website/src/routes/(site)/photos/+page.svelte +++ b/apps/website/src/routes/(site)/photos/+page.svelte @@ -197,12 +197,13 @@ // Workaround: Reactive photos based on data $effect(() => { - if (data.photos && data.photos !== photos) { + if (data.photos) { photos = data.photos } }) - $effect(() => { + + onMount(() => { /** * Observers */ @@ -237,17 +238,6 @@ const existingPhotos = photosGridEl.querySelectorAll('.photo') existingPhotos.forEach(el => observerPhotos.observe(el)) - - // Destroy - return () => { - // Disconnect observers - observerPhotos && observerPhotos.disconnect() - mutationPhotos && mutationPhotos.disconnect() - } - }) - - - onMount(() => { /** * Animations */ @@ -271,6 +261,13 @@ // Run animation requestAnimationFrame(animation.play) + + // Destroy + return () => { + // Disconnect observers + observerPhotos && observerPhotos.disconnect() + mutationPhotos && mutationPhotos.disconnect() + } })