mrchimp / tock

Timer Object/Class. Kickass!
MIT License
237 stars 33 forks source link

[QST] Why delay start timer #9

Closed Sydney-o9 closed 10 years ago

Sydney-o9 commented 10 years ago

Hey @mrchimp,

Great work! I am impressed by how accurate that thing is.

I have a quick question, why delay the timer on start?

see Here

function _startTimer() {
    //....
    this.timeout = window.setTimeout(_tick, 100);
}
mrchimp commented 10 years ago

Hi @Sydney-o9 , Glad you like it!

I haven't touched this for a while now but I've just had brief look...

What I think is happening is that _startTimer() counts as the first tick which sets the clock to zero. It then cues the next tick up after a certain amount of time which then adds the given amount of time to the clock. If _tick was called instantly it would start counting at 1 tick.

However, if that's right then it should be interval rather than 100. Either way something's not quite right!

I'll have to look into it more. Thanks for bringing it to my attention.