I noticed that whenever I dock a browser window or switch tabs requestAnimationFrame stops being called (which I expect to happen).
Is there any way to detect when this stop occurs?
The reason is that there is a timer in my game. I want to stop the timer when requestAnimationFrame is no longer rendering.
I looked at the window.blur and window.focus events, but they are not related to when requestAnimationFrame stops and fires (for example, when you click outside the browser window, the window.blur event fires, but requestAnimationFrame continues to work).
I want to subscribe when requestAnimationFrame starts and stops. Do you know a way?
source share