Skip to content

Reset Interval #58

Answered by KevinBatdorf
usernotnull asked this question in Ideas
Dec 1, 2020 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

You can clear the timer on click with something like <button @click="autoIntervalTest = false"> and you could abstract that to a function that will set it to true after 2 seconds.

Internally, there's a watcher for that property

this.$watch('autoIntervalTest', test => {
  if (test) {
    this.autoIntervalLoop = loop

    forceInterval ? this.autoIntervalLoop() : requestAnimationFrame(this.autoIntervalLoop)
  } else {
    clearTimeout(this.autoIntervalLoop)

    this.autoIntervalLoop = null
  }
})

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by usernotnull
Comment options

You must be logged in to vote
1 reply
@KevinBatdorf
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants