From 692907a11d626e14930a007d6975889ad04c92fb Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Fri, 28 Jun 2024 23:03:37 -0700 Subject: [PATCH] fix: don't trigger navigation loader if going to external link --- src/routes/+layout.svelte | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index f125a52..9f0177b 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -10,6 +10,7 @@ import { onMount } from 'svelte' import { afterNavigate, beforeNavigate } from '$app/navigation' import Loading from '$lib/components/Loading.svelte' + import type { BeforeNavigate } from '@sveltejs/kit' let root: HTMLElement | null let navigating = false @@ -22,9 +23,11 @@ navigating = false }) - beforeNavigate(() => { - navigating = true - root?.classList.remove('smoothscroll') + beforeNavigate((navigation: BeforeNavigate) => { + if (navigation.to?.url.origin === window.location.origin) { + navigating = true + root?.classList.remove('smoothscroll') + } }) afterNavigate(() => {