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

[Bug] Whenever I press on restart clock counter, it "restarts" but with a faster pace #6

Open
TOTON95 opened this issue Jun 18, 2022 · 3 comments

Comments

@TOTON95
Copy link

TOTON95 commented Jun 18, 2022

As the title indicates, whenever I attempt to restart the counter I can get it returned to the desired value, but it seems that there's a hidden accumulation of time difference between each counter state (?), which can be increased as much as I keep pressing the Restart button.

@TOTON95 TOTON95 changed the title [Bug] Whenever I press on restart clock counter "restarts" but with a faster pace [Bug] Whenever I press on restart clock counter, it "restarts" but with a faster pace Jun 18, 2022
@fferegrino
Copy link
Owner

The problem must be here:

study-with-me/index.html

Lines 133 to 135 in f213d93

clearTimeout(interval)
elapsedSeconds = 0
interval = setInterval(tick, 1000);
, it may be the case that clearTimeout is not as fast?

@TOTON95
Copy link
Author

TOTON95 commented Jun 20, 2022

@fferegrino it could be, also it might be a good idea to add a clearTimeout to

console.log(interval)
because maybe something is messing up with the function setInterval

TOTON95 added a commit to TOTON95/study-with-me that referenced this issue Jun 20, 2022
@TOTON95
Copy link
Author

TOTON95 commented Jun 20, 2022

On a second review, I noticed it that it's more related to the start button than the restart, it can be fixed with adding clearTimeout before setting a new interval on the start button event listener.

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