sciactive / pnotify

Beautiful JavaScript notifications with Web Notifications support.
https://sciactive.com/pnotify/
Apache License 2.0
3.65k stars 513 forks source link

Notice stuck on closing state #241

Closed fynncfchen closed 6 years ago

fynncfchen commented 8 years ago

I found that when I open a notice then close it in a very short time, the notice will be hidden but remain on the top of the page.

My code

var notice = PNotify();
someApiCall(function (response) {
  notice.remove();
});

or just

var notice = PNotify();
notice.remove();

the notice will stuck on closing state and not actually closed.

Nikita-Boyarskikh commented 6 years ago

I've got the same issue

If I try to use the animation and hover a notice when it closes, the notice remains visible translucent block with the status "closing" and is not removed either from the DOM or from global array notices. However, this does not happen every time: if at the same time a lot to create and delete notifications, it happens sometimes.

My code:

function foo() {
  const ID = 'clickable_link';
  new PNotify({
    title: 'title',
    type: 'info',
    text: '<a id=' + ID + '>Click me!</a>',
    nonblock: {
      nonblock: true,
    },
    hide: false,
    after_open: () => {
      const link = document.getElementById(ID);
      link.onclick = bar;
      return true;
    }
  });
}
// ...
foo();
PNotify.removeAll(); foo(); // this code evaluated many times

In contrast, if I don't use the animation, everything works as expected: notification is deleted from the DOM and from the global array notices.

Code:

function foo() {
  const ID = 'clickable_link';
  new PNotify({
    title: 'title',
    type: 'info',
    text: '<a id=' + ID + '>Click me!</a>',
    nonblock: {
      nonblock: true,
    },
    animation: 'none',
    hide: false,
    after_open: () => {
      const link = document.getElementById(ID);
      link.onclick = bar;
      return true;
    }
  });
}
// ...
foo();
PNotify.removeAll(); foo(); // this code evaluated many times
fynncfchen commented 6 years ago

I'm not willing to use PNotify anymore