sciactive / pnotify

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

Notification not hide when in non focused tab/window #381

Open edika99 opened 4 years ago

edika99 commented 4 years ago

I've notice that notification shown in non focused browser windows, does not hide automatically until the windows/tab is focused again. In my case, I have an application that send notification about some events with a PNotify and a sound. While I'm browsing on other open tabs in Chrome, I can hear the notification arriving by the sound, but when I focus again the tab where the application is running, I find all the PNotifys still shown on the application, even if is is passed a lot of time, and the notification should be expired. Then, after some seconds, all notification starts to hide, in the order that were been show. Does this depends by a browser behaviour or is a PNotify problem?

lbochen commented 2 years ago

I have the same problem. It think, that the problem is window.requestAnimationFrame function that pauses when the tab is inactive and resumes after tab is focused

    window.requestAnimationFrame(() => {
      if (_state !== 'opening') {
        reject();
        _openPromise = null;
        return; 
...