Progress Bars III: Pause and Resume
UI Coding
Hard
40 min
animation
state
reducers
effects
Extend the download manager from Progress Bars II (each bar takes 2 seconds, at most 3 run at once, the rest are queued) with global controls.
Requirements
- Add appends a bar, as before. The concurrency limit of 3 still applies.
- Pause freezes every running bar exactly where it is. The button becomes Resume, and resuming continues from the same percentage. It must not restart from 0 or jump ahead by the paused time.
- Bars added while paused are queued and don't start until you resume.
- Reset removes every bar and leaves the manager running (not paused).
- Expose the toggle state accessibly. The Pause/Resume button's name changes with its action, and the summary ("Paused · 2 running · 3 queued · 1 done") is visible text.
- Each bar:
role="progressbar",aria-valuenow, a label "Download N", andaria-valuetext="Queued"while waiting. - Use a single animation loop for all bars, not one per bar, and stop it whenever there's nothing to animate.
Follow-up
- Why does pause and resume push you towards a central clock?
- What should happen when the tab is hidden? Should hidden time count?
- How would you test this without fake timers?
Spotted a mistake or a rights concern? Report an issue