K
K
Kusmich2015-10-19 15:32:58
JavaScript
Kusmich, 2015-10-19 15:32:58

How can I reset the timer and then start it again?

There is a condition after the satisfaction of which the timer needs to be cleared, and when the condition is not satisfied, start again.

For example: if (StateStnum_1!= stnum_1) { interval should work. And if the condition is met and StateStnum_1 === stnum_1 interval should be cleared...

The code is complete:

var intervaled = setInterval(function() {
  if (StateStnum_1 != stnum_1) {
    StateStnum_1++;
    flip('hoursUp' + 1, 'hoursDown' + 1, StateStnum_1, 'Single/Up/' + 2 + '/', 'Single/Down/' + 1 + '/');
    if (StateStnum_1 === 10) {
      StateStnum_1 = 0;
    }
  };
}, 1500);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Kirenkov, 2015-10-19
@Kusmich

Google towards clearInterval

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question