Repository navigation
✨ Features
roundUpoption foruseClockCountDown(#56). WithroundUp: true,daystosecondsand theformatted*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 anupdateFrequencyunder a second.totalMillisecondsandmillisecondsstay exact. Defaultfalse.
⚡ 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. SetroundUp: trueto keep the full duration on screen until completion. - A duration starts at its exact length:
seconds: 5is 5000 ms, with no clock reading involved.
🐛 Bug Fixes
pause()shows the exact time left, andresume()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 firesonCountDownCompletedinstead of stopping at 0. onCountDownCompletedfires once per run: also when one step jumps past the end, and also when the callback itself callspause().- A
targetDatecreated during render for the same instant no longer re-initialises the countdown on every render. - Fractional durations are kept in whole milliseconds:
hours: 1.1withroundUpshowed 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