Skip to content

Instantly share code, notes, and snippets.

@thykka
Last active August 29, 2015 13:57
Show Gist options
  • Save thykka/9794508 to your computer and use it in GitHub Desktop.
Save thykka/9794508 to your computer and use it in GitHub Desktop.
function beginCountdown (mins) {
var secs = mins * 60
var now = new Date()
var elapsed
var countdown = setInterval(function(){
elapsed = new Date() - now
if (elapsed/1000 < secs) {
updateProgress(elapsed/1000, secs)
} else {
updateProgress(1, 1)
clearInterval(countdown)
}
}, 1000)
updateProgress(0, 1)
return countdown
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment