Created
September 20, 2017 22:37
-
-
Save rssems/f09e1a15f769d8172b676ea51cb7bb61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
origin = null | |
timer = null | |
time = -> | |
now = Date.now() | |
secs = Math.floor((now - origin) / 1000) | |
s = secs % 60 | |
min = Math.floor(secs / 60) | |
if s < 10 then s = "0" + s | |
if min < 10 then min = "0" + min | |
textLayer.text = "#{min}:#{s}" | |
startTimer = -> | |
timer = setInterval(time, 1000) | |
origin = Date.now() | |
timer | |
stopTimer = -> | |
clearInterval(timer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment