Explorar o código

feat: ability to use duration=Infinity in showToast

Sv443 hai 9 meses
pai
achega
27a5cdb3fd
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      src/components/toast.ts

+ 3 - 2
src/components/toast.ts

@@ -105,9 +105,10 @@ export async function showToast({
 
   await pauseFor(100);
 
-  toastElem.classList.add("visible", `pos-${position}`);
+  toastElem.classList.add("visible", `pos-${position.toLowerCase()}`);
 
-  timeout = setTimeout(async () => await closeToast(), duration * 1000);
+  if(duration < Number.POSITIVE_INFINITY)
+    timeout = setTimeout(async () => await closeToast(), duration * 1000);
 }
 
 /** Closes the currently open toast */