From cecb0a605c4c20d1e07ee3d31c9fcd2cbd7f1111 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 1 Dec 2023 15:17:58 -0800 Subject: optimizing --- src/routes/+page.svelte | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/routes/+page.svelte') diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 9d2ba213..59d56bf1 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -11,8 +11,7 @@ } from '$comp'; import { t } from '$lib/translations'; - import { close } from '$lib/socket'; - import { onDestroy, onMount } from 'svelte'; + import { onDestroy, onMount, tick } from 'svelte'; export let data; let { faqs, locations, user } = data; @@ -33,16 +32,17 @@ let loaded; - onMount(async () => { - close(); + let observer; + let isIntersecting = false; - try { - ({ locations } = await fetch('/locations').then((r) => r.json())); - } catch (e) { - console.log(e); - } + onMount(async () => { + observer = new IntersectionObserver((entries) => { + isIntersecting = isIntersecting || entries[0].isIntersecting; + }); loaded = true; + await tick(); + observer.observe(document.getElementById('faq')); }); onDestroy(() => (loaded = false)); @@ -56,7 +56,7 @@
- +
-

{$t('howItWorks.header')}

+

+ {$t('howItWorks.header')} +

{#each howItWorksSteps as step} @@ -93,7 +95,9 @@
-

{$t('faq.header')}

+

+ {$t('faq.header')} +

{#each faqs as f} {/each} @@ -101,7 +105,9 @@
- + {#if isIntersecting} + + {/if}