rintoj / ngx-virtual-scroller

Virtual Scroll displays a virtual, "infinite" list.
https://rintoj.github.io/ngx-virtual-scroller
MIT License
979 stars 295 forks source link

Blank white page from items update on inactive tab #467

Open raizemm opened 4 years ago

raizemm commented 4 years ago

Consider a scenario for items added asynchronously via WebSocket or even setInterval. When you're on the tab that uses virtual scroller everything works flawlessly but when you switch to any other browser tab all of subsequent updates to the table items aren't happening.

That happens because of requestAnimationFrame usage inside refresh_internal function which doesn't run on background tabs. After coming back to the tab after a while you get white blank page and have to wait for a while for the tab to be responsive again probably because of all the rAF queued on timer queue has to run. This can be easily reproduced using list-with-api sample and switching setTimeout to setInterval .

One thing to consider is checking whether tab is active using document.hidden property or allow the library users to pass some stop function via options which will prevent rAF from queuing.

Hephaestus901 commented 1 year ago

Hi everyone Does anyone find solution for this problem yet?