summaryrefslogtreecommitdiff
path: root/src/lib/navigation.ts
blob: c759d97d8333a9314db8fd578381bf26b0815769 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
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);
});