Skip to content

Instantly share code, notes, and snippets.

@AlanBreck
Last active April 19, 2017 19:58
Show Gist options
  • Save AlanBreck/eedf9bac93e5544b523462ad8a4baf8b to your computer and use it in GitHub Desktop.
Save AlanBreck/eedf9bac93e5544b523462ad8a4baf8b to your computer and use it in GitHub Desktop.
updateProgress = () => {
this.setState({ progress: 0 });
const min = 1;
const max = 60;
const totalTime = Math.floor(Math.random() * (max - min + 1) + min);
let counter = 0;
var progInterval = setInterval(() => {
counter++;
this.setState({
progress: counter / (totalTime * 60) * 100
});
if (counter >= totalTime * 60) {
clearInterval(progInterval);
counter = 0;
console.log("done");
}
}, 16);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment