apvarun / toastify-js

Pure JavaScript library for better notification messages
https://apvarun.github.io/toastify-js/
MIT License
2.13k stars 230 forks source link

multiple messages do not dissapear #36

Closed merkancam closed 3 years ago

merkancam commented 4 years ago

If I show one message it disappears. No problem but if i show multiple messages then only first one disappears rest are keeps alive.

here is my message below

toast.lib.init({ text: message, duration: 3000, newWindow: false, close: true, gravity: "top", position: 'right', backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)", stopOnFocus: true, }).showToast();

apvarun commented 4 years ago

Would be great if you could reproduce this issue. I tried by generating multiple toasts and it works as intended. Reference: https://jsbin.com/mikekeqiqi/2/edit?html,js,output

Illusionist3886 commented 4 years ago

@apvarun Reproduced Issue: https://jsbin.com/minaziyuve/edit?html,js,output It happens when we store the options on a js variable and trigger it on a mouse event.

apvarun commented 4 years ago

@Illusionist3886 This is related to how the library is designed. Each toast is expected to have its own instance. Create multiple toasts from one config is not the intended one.

Each toast is expected to have its own instance.

This is setup as such in order to have each of them controllable from JS


In order to achieve what you need, the following small changes could help

myToast = Toastify({ to myToast = () => Toastify({

myToast.showToast() to myToast().showToast()

Reference bin: https://jsbin.com/rafixuw/edit?html,js,output

apvarun commented 3 years ago

Closing this due to inactivity