File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 33 import { page } from ' $app/stores' ;
44 import logo from ' $lib/logo.svg' ;
55 import clsx from ' clsx' ;
6+ import { afterNavigate , beforeNavigate } from ' $app/navigation' ;
67 interface Props {
78 children? : import (' svelte' ).Snippet ;
89 }
910
1011 let { children }: Props = $props ();
12+
13+ let showSpinner = $state (false );
14+ let navigationTimer: ReturnType <typeof setTimeout > | null = null ;
15+
16+ beforeNavigate (() => {
17+ if (navigationTimer ) {
18+ clearTimeout (navigationTimer );
19+ showSpinner = false ;
20+ }
21+ navigationTimer = setTimeout (() => {
22+ showSpinner = true ;
23+ }, 200 );
24+ });
25+
26+ afterNavigate (() => {
27+ if (navigationTimer ) {
28+ clearTimeout (navigationTimer );
29+ navigationTimer = null ;
30+ }
31+ showSpinner = false ;
32+ });
1133 </script >
1234
1335<svelte:head >
7799 /> Carbon Budget Explorer</a
78100 >
79101 </div >
102+ {#if showSpinner }
103+ <div class =" loading loading-spinner loading-md me-4" title =" Loading..." ></div >
104+ {/if }
80105 <div class =" alert" style =" width: 50%" >
81106 <svg
82107 xmlns =" http://www.w3.org/2000/svg"
You can’t perform that action at this time.
0 commit comments