vydimitrov/use-count-up

Count up does not start if Electron window is in background

Closed this issue · 3 comments

Thanks for the great package!

My issue is with background behavior in Electron. I've noticed that if CountUp starts, then is backgrounded, the counting up properly continues. However if the component is rendered while the Electron app is backgrounded, then CountUp wont begin until Electron is brought to the foreground.

Since CountUp is used for displaying time passing, I want it to either (1) start in the background or (2) be updated instantly to the proper value.

Perhaps a setInterval could be used to periodically update it? Curious how you would approach this.

Hey @andrewschreiber, the count up does not start because all animations that run in a window that is not focused are suspended until the window is focused. The countUp is using requestAnimationFrame internally for the animation. In the second case where the countUp starts and after that the window us blurred, the same happens... just that when the window comes back we take the current time and use the difference between it and the last time we got the time (beforing going blurred).

In seems your use case is related to measuring elapsed time? If that is the case, I would recommend using use-elapsed-time hook where you can pass a prop startAt, which can be used to compensate the time until the window comes back focused.  

Hey @andrewschreiber, was this helpful in any way?

Closing this one due to inactivity.