m-lm / minmath

A minimalist mental math website.
MIT License
1 stars 0 forks source link

Progress bar timer inconsistent when player switches tabs #28

Open m-lm opened 4 months ago

m-lm commented 4 months ago

Progress bar behaves weirdly when player switches tabs. The more tab switches, the more it will "accelerate" and display an inaccurate progress bar. As far as testing goes, the progress bar display is the main problem rather than the numerical timer itself.

A general width formula that incorporates timeLapsed helps but does not really solve the problem. Presumably has something to do with browser throttling when the page is out of focus; why it mainly affects the progress bar timer interval is not completely determined, however it probably appears more noticeable because the interval is every 100 ms instead of the timer's 1000 ms. Does this mean the browser slows down the timer to ~1 second? It definitely does not maintain the 100 ms interval. This is not a super important issue but should be addressed in the future.

m-lm commented 1 month ago

Alternative solution is to just pause the timer and the progress bar while player is away. That is probably also more user-friendly and can act as a "pause" button.