Skip to content
Back to the lab

scroll → scaleX · rAF-throttled

Reading progress bar

The capsule at the bottom left of a post page: a thin progress bar and a percentage. It normally appears only on post pages; here it shows this page's progress.

Source · GitHub

Scroll events are throttled with rAF, and each update writes only a transform and a textContent, with no layout change and no React re-render. The entrance is a single 0.35s float-in; after that the capsule does not move, and only the fill's scaleX changes with the scroll. It has role=progressbar and aria-valuenow, so a screen reader can report the progress. In the layout it appears only on post routes, /blog/…; the pattern is anchored at both ends, otherwise the tag listing pages would match as well. This page is made long on purpose, so there is something to scroll.

Source

Source files on GitHub:

Back to the lab