Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timer not accurate in mobile #65

Open
veeramarni opened this issue Mar 5, 2021 · 1 comment
Open

timer not accurate in mobile #65

veeramarni opened this issue Mar 5, 2021 · 1 comment

Comments

@veeramarni
Copy link

It seems if I lock my phone and get back to the browser, it slows down and after 5 minutes the timer has just counted 20 seconds. How can the timer can be current after the browser becomes active after it being minimized or phone screen locked?

@markmccoid
Copy link

I ran into this problem also and it boils down to the setInterval not being the best way to implement a timer.

I think most of the issues could be fixed by you if you were to fork this repo and use the Date() to determine the time.

Here is an implementation I did for another project that should help:

https://github.com/markmccoid/healingbreath/blob/main/src/utils/timerAdjustingInterval.ts

I'm using a state machine in my project to implement the timer, but in the end that above function is what is being used to calculate the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants