impr(loader): delay showing the loading bar by 125ms to avoid it flashing on screen for things that take a short time

!nuf
This commit is contained in:
Miodec 2024-04-23 11:35:32 +02:00
parent 59636e9d05
commit 299fc35685

View file

@ -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;
}