From b6c6b705c15ff02e26eb5463a8b1550fa131ee38 Mon Sep 17 00:00:00 2001 From: axtloss Date: Tue, 20 Aug 2024 23:22:50 +0200 Subject: add loader for long loading pages --- src/lib/navigation.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/lib/navigation.ts (limited to 'src/lib') 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 = null; +export const isNavigating = derived(navigating, (newValue, set) => { + if (timer) { + clearTimeout(timer); + } + if (newValue) { + timer = setTimeout(() => set(true), 500); + } + set(false); +}); -- cgit v1.2.3