diff --git a/frontend/src/ts/elements/loader.ts b/frontend/src/ts/elements/loader.ts index 2ea8b0f2e..369823120 100644 --- a/frontend/src/ts/elements/loader.ts +++ b/frontend/src/ts/elements/loader.ts @@ -1,7 +1,25 @@ +let timeout: NodeJS.Timeout | null = null; + +let visible = false; + +function clearTimeout(): void { + if (timeout !== null) { + window.clearTimeout(timeout); + timeout = null; + } +} + export function show(): void { - $("#backgroundLoader").stop(true, true).fadeIn(125); + if (visible) return; + timeout = setTimeout(() => { + $("#backgroundLoader").stop(true, true).show(); + }, 125); + visible = true; } export function hide(): void { + if (!visible) return; + clearTimeout(); $("#backgroundLoader").stop(true, true).fadeOut(125); + visible = false; }