Skip to content

Instantly share code, notes, and snippets.

@brydavis
Created September 24, 2019 00:32
Show Gist options
  • Save brydavis/d24b2c6401ef28ddf0f6edbeab8542b3 to your computer and use it in GitHub Desktop.
Save brydavis/d24b2c6401ef28ddf0f6edbeab8542b3 to your computer and use it in GitHub Desktop.
Progress Bar Snippet
// pb is a DIV that respresents the progress bar itself
// this example is a demo; update it to track actually progress
function move(pb) {
pb.style.width = "0%"
setTimeout(function () {
console.log("start")
var width = 1;
var id = setInterval(frame, 50);
function frame() {
if (width >= 100) {
clearInterval(id);
console.log("done")
} else {
width++;
pb.style.width = width + '%';
}
}
}, 1000)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment