diff options
author | axtloss <axtlos@disroot.org> | 2024-08-20 23:22:50 +0200 |
---|---|---|
committer | axtloss <axtlos@disroot.org> | 2024-08-20 23:22:50 +0200 |
commit | b6c6b705c15ff02e26eb5463a8b1550fa131ee38 (patch) | |
tree | 7767ce76ac88b27a30721b0ca71f4fe7c1ea8cf0 /src/lib/navigation.ts | |
parent | 7890c18787e41ee3e69248dfecfc419eab020383 (diff) | |
download | website-b6c6b705c15ff02e26eb5463a8b1550fa131ee38.tar.gz website-b6c6b705c15ff02e26eb5463a8b1550fa131ee38.tar.bz2 |
add loader for long loading pages
Diffstat (limited to 'src/lib/navigation.ts')
-rw-r--r-- | src/lib/navigation.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/navigation.ts b/src/lib/navigation.ts new file mode 100644 index 0000000..c759d97 --- /dev/null +++ b/src/lib/navigation.ts @@ -0,0 +1,13 @@ +import { derived } from 'svelte/store'; +import { navigating } from '$app/stores'; + +let timer: ReturnType<typeof setTimeout> = null; +export const isNavigating = derived(navigating, (newValue, set) => { + if (timer) { + clearTimeout(timer); + } + if (newValue) { + timer = setTimeout(() => set(true), 500); + } + set(false); +}); |