From 001f89690bba46edfc091bff969ffcfea664e0ee Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 16 Aug 2026 20:06:01 +0300 Subject: [PATCH] Delay nprogress --- apps/web/src/routes/+layout.svelte | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/web/src/routes/+layout.svelte b/apps/web/src/routes/+layout.svelte index 6cff739d5..3414501ba 100644 --- a/apps/web/src/routes/+layout.svelte +++ b/apps/web/src/routes/+layout.svelte @@ -16,18 +16,28 @@ import { IS_E2E_TEST_RUN } from "#lib/utils/e2e.ts"; import { navigating } from "$app/state"; import type { LayoutProps } from "./$types"; +const LOADING_INDICATOR_DELAY_MS = 150; + let { data, children }: LayoutProps = $props(); const theme = $derived(data.theme ?? null); NProgress.configure({ parent: "#nprogress-anchor", showSpinner: false }); +const isNavigating = $derived(Boolean(navigating.to)); + $effect(() => { - if (navigating.to) { - NProgress.start(); - } else { - NProgress.done(); - } + const navigationOngoing = isNavigating; + + const timeout = setTimeout(() => { + if (navigationOngoing) { + NProgress.start(); + } else { + NProgress.done(); + } + }, LOADING_INDICATOR_DELAY_MS); + + return () => clearTimeout(timeout); });