mirror of
https://github.com/youwen5/site.git
synced 2024-11-24 17:33:51 -08:00
fix: don't trigger navigation loader if going to external link
This commit is contained in:
parent
b75f2c7085
commit
692907a11d
1 changed files with 6 additions and 3 deletions
|
@ -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) => {
|
||||||
|
if (navigation.to?.url.origin === window.location.origin) {
|
||||||
navigating = true
|
navigating = true
|
||||||
root?.classList.remove('smoothscroll')
|
root?.classList.remove('smoothscroll')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
afterNavigate(() => {
|
afterNavigate(() => {
|
||||||
|
|
Loading…
Reference in a new issue