Skip to content

Instantly share code, notes, and snippets.

@thijssmudde
Created March 1, 2018 14:15
Show Gist options
  • Select an option

  • Save thijssmudde/afa29ce0b044c07fb48bcd67c52a96be to your computer and use it in GitHub Desktop.

Select an option

Save thijssmudde/afa29ce0b044c07fb48bcd67c52a96be to your computer and use it in GitHub Desktop.
Stopwatch Resume and Stop
resume = () => {
//update the timestart to continue with same time
this.setState(state => {
let timestart = moment().unix() - (this.state.timestop - this.state.timestart)
return {running: true, timestart}
}, () => {
this.startTimer()
})
}
stop = () => { //Press STOP
clearInterval(this.timer) //Release the timer
this.setState({
running: false,
timestop: moment().unix()
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment