diff options
author | Eugene <eug-vs@keemail.me> | 2020-01-04 22:25:21 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-04 22:25:21 +0000 |
commit | af91e785e66cf70e3055ded8e519f575b7d46f0d (patch) | |
tree | 3733b128db43e30b39737533c44b4c35f30ad87e /src | |
parent | a86a19717d9824c7a6dde6a8252255cf56acf133 (diff) | |
parent | a179118bfa2f7af306893895161adf9fb9bd1897 (diff) | |
download | chrono-cube-ui-af91e785e66cf70e3055ded8e519f575b7d46f0d.tar.gz |
Merge pull request #20 from Eug-VS/timer-fix
Fix timer behavior and initial time value
Diffstat (limited to 'src')
-rw-r--r-- | src/components/Timer/Timer.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/components/Timer/Timer.js b/src/components/Timer/Timer.js index f840429..4712265 100644 --- a/src/components/Timer/Timer.js +++ b/src/components/Timer/Timer.js @@ -7,7 +7,7 @@ import { Typography } from '@material-ui/core'; const Timer = () => { const SPACE = 32; const maxCountdown = 15000; - const [time, setTime] = useState('00:15:00'); + const [time, setTime] = useState('00:00:00'); const [isRunning, setIsRunning] = useState(false); const [timer, setTimer] = useState(0); const [isCountdown, setIsCountdown] = useState(false); @@ -32,14 +32,14 @@ const Timer = () => { }; const handleKeyUp = event => { - clearInterval(timer); - if (event.keyCode === SPACE){ + if (event.keyCode === SPACE) { + clearInterval(timer); if (!isRunning) { startingTime = Date.now(); setIsRunning(true); setTimer(setInterval(() => setTime(convertTimeToString((Date.now() - startingTime))), 10)); } else { - + clearInterval(timer); setIsRunning(false); setIsCountdown(false); |