added stopwatch example

added requestAnimationFrame polyfill

moved raf logic into a subscription

separated logic into multiple files, all state lives in a global namespaced model, reset no longer sends multiple actions only one
This commit is contained in:
traducer
2016-07-13 16:59:20 +00:00
parent a1795c29ee
commit 5f858cfdf5
5 changed files with 120 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
function formatMinutes (minutes) {
return `${minutes >= 10 ? minutes : (minutes < 10) ? '0' + minutes : '00'}`
}
function formatSeconds (seconds) {
return `${seconds < 10 ? '0' + seconds : seconds}`
}
module.exports = function format (elapsed) {
const minutes = formatMinutes(Math.floor((elapsed / 1000) / 60))
const seconds = formatSeconds(Math.floor((elapsed / 1000) % 60))
const ms = formatSeconds(Math.floor((elapsed % 1000) / 10))
return `${minutes}:${seconds}.${ms}`
}