Browse Source

feat: ability to use duration=Infinity in showToast

Sv443 9 months ago
parent
commit
b8ce681a9d
1 changed files with 3 additions and 2 deletions
  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 */