diff options
author | asketonim <anton.dubik33@gmail.com> | 2020-01-05 00:40:40 +0300 |
---|---|---|
committer | asketonim <anton.dubik33@gmail.com> | 2020-01-05 00:40:40 +0300 |
commit | a179118bfa2f7af306893895161adf9fb9bd1897 (patch) | |
tree | 3dfb4a19f908cbb5faa5abf23f1176c991a9e463 /src/components | |
parent | 347f9d604044236830020f232fab3733c628720f (diff) | |
download | chrono-cube-ui-a179118bfa2f7af306893895161adf9fb9bd1897.tar.gz |
Fix timer behavior and initial time value
Diffstat (limited to 'src/components')
-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); |