diff options
author | David Gay <david@davidgay.org> | 2021-06-03 22:03:16 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-06-03 22:03:16 -0400 |
commit | a02cf6d28a28d312b8a4a8e8feb40eb03289a090 (patch) | |
tree | d1ae91742d5df9b40810ff78981334ca68016b07 /app/javascript | |
parent | 25c9a1650e7dd9b302b1d47e4a33721d759c44b7 (diff) |
Timer: Improve accuracy/feel by starting to count down immediately (before this, there was an uncomfortable delay)
Diffstat (limited to 'app/javascript')
-rw-r--r-- | app/javascript/controllers/timer_controller.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/javascript/controllers/timer_controller.js b/app/javascript/controllers/timer_controller.js index 5190a79..901ec0a 100644 --- a/app/javascript/controllers/timer_controller.js +++ b/app/javascript/controllers/timer_controller.js @@ -32,10 +32,11 @@ export default class extends Controller { return; } + if (controller.counter > 0) controller.counter--; + if (controller.counter > 0) { controller.timerTarget.textContent = controller.counter.toString(); - controller.counter--; - } else if (this.counter <= 0) { + } else { Rails.ajax({ type: "POST", url: controller.postUrlValue, |