Skip to content

4.1.0

Latest

Choose a tag to compare

@gfazioli gfazioli released this 04 Dec 14:12

✨ Features

  • roundUp option for useClockCountDown (#56). With roundUp: true, days to seconds and the formatted* strings round the time left up to the next whole second, so a countdown starts at its full duration and shows 0 only on completion, also with an updateFrequency under a second. totalMilliseconds and milliseconds stay exact. Default false.

⚡ Improvements

  • Ticks on whole intervals. Each update lands on a grid of updateFrequency, anchored to the target in target mode and to the start (or the last resume) in duration mode, and reports that line's value. A tick a few milliseconds late reports the value it was due to report; one more than half an interval late skips a value, never repeats one, and a late tick just before the end never completes early.
  • Visible change with the default options: a 5 second countdown now reads 5, 4, 3, 2, 1 and shows 0 together with isCompleted. Before, it usually skipped a value (5, 3, 2, 1, 0) and showed 0 for the last second while still running. Set roundUp: true to keep the full duration on screen until completion.
  • A duration starts at its exact length: seconds: 5 is 5000 ms, with no clock reading involved.

🐛 Bug Fixes

  • pause() shows the exact time left, and resume() continues from it (#65). Paused 2.5 s into a 10 second countdown, the hook reads 7500 ms; it used to keep showing 8 and resume on 6. pause() while not running is now a no-op (it zeroed the stored duration).
  • A pause() that lands after the end, before the delayed tick runs (a throttled background tab), completes the run and fires onCountDownCompleted instead of stopping at 0.
  • onCountDownCompleted fires once per run: also when one step jumps past the end, and also when the callback itself calls pause().
  • A targetDate created during render for the same instant no longer re-initialises the countdown on every render.
  • Fractional durations are kept in whole milliseconds: hours: 1.1 with roundUp showed 01:06:01.

📝 Summary

useClockCountDown now ticks on whole intervals and gains an opt-in roundUp, with fixes to pause() and to completion. The docs have a new "Rounding" section with a side-by-side demo, and the comparison with Mantine core's useCountdown now lists aligned ticks as shared. Peer ranges are unchanged.


What's Changed

  • docs: add a comparison with Mantine core useCountdown by @gfazioli in #54
  • chore(security): patch vulnerable dependencies by @gfazioli in #70
  • feat(useClockCountDown): ticks on whole intervals, and roundUp by @gfazioli in #69

Full Changelog: 4.0.24...4.1.0