marcelodolza / iziToast

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

Update events on izitoast.marcelodolce.com #136

Closed Zamberetta closed 6 years ago

Zamberetta commented 6 years ago

Hi Marcelo,

Once again thank you for creating such an amazing and well polished plugin. I was looking at the documentation on your site and noticed that the events need a little updating as they no longer are correct. Looking through your code I have created some updated ones below, hope it helps!

Opening

// You can compare by any option (id, class..)

document.addEventListener('iziToast-opening', function(data) {
  if (data.originalEvent.detail.class === 'test') { // data.originalEvent.detail will have all toast settings.
    console.info('EventListener iziToast-opening');
  }
});

Opened

document.addEventListener('iziToast-opened', function(data) {
  if (data.originalEvent.detail.class === 'test') {
    console.info('EventListener iziToast-opened');
  }
});

Closing

document.addEventListener('iziToast-closing', function(data) {
  if (data.originalEvent.detail.class === 'test') {
    console.info('EventListener iziToast-closing');
  }
});

Closed

document.addEventListener('iziToast-closed', function(data) {
  if (data.originalEvent.detail.class === 'test') {
    console.info('EventListener iziToast-closed');
    console.info(data.originalEvent.detail.closedBy);
  }
});

Keep up the good work! Aston