fix: don't trigger navigation loader if going to external link

This commit is contained in:
Youwen Wu 2024-06-28 23:03:37 -07:00
parent b75f2c7085
commit 692907a11d
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3

View file

@ -10,6 +10,7 @@
import { onMount } from 'svelte' import { onMount } from 'svelte'
import { afterNavigate, beforeNavigate } from '$app/navigation' import { afterNavigate, beforeNavigate } from '$app/navigation'
import Loading from '$lib/components/Loading.svelte' import Loading from '$lib/components/Loading.svelte'
import type { BeforeNavigate } from '@sveltejs/kit'
let root: HTMLElement | null let root: HTMLElement | null
let navigating = false let navigating = false
@ -22,9 +23,11 @@
navigating = false navigating = false
}) })
beforeNavigate(() => { beforeNavigate((navigation: BeforeNavigate) => {
navigating = true if (navigation.to?.url.origin === window.location.origin) {
root?.classList.remove('smoothscroll') navigating = true
root?.classList.remove('smoothscroll')
}
}) })
afterNavigate(() => { afterNavigate(() => {