Skip to content

Instantly share code, notes, and snippets.

@ar-android
Created October 4, 2017 00:02
Show Gist options
  • Save ar-android/e1807f9e9303648fb63813cc0592bad3 to your computer and use it in GitHub Desktop.
Save ar-android/e1807f9e9303648fb63813cc0592bad3 to your computer and use it in GitHub Desktop.
var timeFrame = 500
this.timer = setInterval(() => {
if (this.state.progress == 1) {
clearInterval(this.timer);
setTimeout(() => {
//When delay is finish do something
}, timeFrame)
} else {
let random = Math.random() * 0.5;
let progress = this.state.progress + random;
if (progress > 1) {
progress = 1;
}
this.setState({progress})
}
}, timeFrame)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment