marcelodolza / iziToast

Elegant, responsive, flexible and lightweight notification plugin with no dependencies.
https://marcelodolza.github.io/iziToast/
Apache License 2.0
2.62k stars 306 forks source link

Close related events called 2 times when overlay is used #176

Open pawelkania opened 5 years ago

pawelkania commented 5 years ago

When onClosing or onClosed event is used together with overlay (which can close toast) event is called two times.

Steps to reproduce:

  1. Create two toasts with overlay and overlayClose,
  2. close first notification by clicking "x" button (first "onClosing 1" function executed which is correct)
  3. close second notification by clicking overlay - "onClosing 1" and "onClosing 2" function is executed but only "onClosing 2" should be executed because first toast is already closed.
iziToast.show({
    position: 'center',
    title: 'Hey',
    message: 'Welcome!',
    timeout: false,
    overlay: true,
    overlayClose: true,
    onClosing: function(instance, toast){
        console.log('onClosing 1', instance);
    }
});

iziToast.show({
    position: 'center',
    title: 'Hey',
    message: 'Welcome!',
    timeout: false,
    overlay: true,
    overlayClose: true,
    onClosing: function(instance, toast){
        console.log('onClosing 2', instance);
    }
});

Working example is here: https://jsfiddle.net/xjz2qu7e