wobsoriano / svelte-sonner

An opinionated toast component for Svelte. A port of @emilkowalski's sonner.
https://svelte-sonner.vercel.app
MIT License
715 stars 23 forks source link

Changing state of a toast using `id` don't have animations #109

Open CNSeniorious000 opened 4 months ago

CNSeniorious000 commented 4 months ago

Describe the bug

If I use toast.promise, when it changes from loading state to success/error state, it has a smooth scale-in-out animation, and the background color is fade-in-out too.

But if I use id to set an existing toast with loading state to success or others, it is not animated.

Reproduction

https://stackblitz.com/edit/vitejs-vite-dfaa5m?file=src%2FApp.svelte

Logs

No response

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 AMD Ryzen 7 7840HS w/ Radeon 780M Graphics
    Memory: 1.56 GB / 15.18 GB
  Binaries:
    Node: 20.9.0 - D:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - ~\AppData\Local\pnpm\yarn.CMD
    npm: 10.8.1 - D:\Program Files\nodejs\npm.CMD
    pnpm: 9.4.0 - ~\AppData\Local\pnpm\pnpm.CMD
    bun: 1.1.13 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (126.0.2592.68)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @sveltejs/kit: ^2.5.17 => 2.5.17
    svelte: ^4.2.18 => 4.2.18
    svelte-sonner: 0.3.24 => 0.3.24

Severity

annoyance

CNSeniorious000 commented 4 months ago

After reading the source in state.ts, I found that adding a promise: true to the options can make it animate like toast.promise do. I am thinking whether this can become a default behavior.