glide-scroll

Scroll this page with a mouse wheel. Then turn the glide off with the button in the corner and scroll again. Source on GitHub.

Things to notice

  1. Each wheel tick eases into the next instead of jumping 100 pixels.
  2. Keep the mouse still over this list while you scroll. The rows don't highlight as they pass under it. Nudge the mouse and hover is back.
  3. The box below has its own scrollbar. Scrolling inside it is left to the browser until it hits the end.
  4. The arrow keys, space bar and scrollbar all work the way they always do.
  5. Turn on reduced motion in your system settings and the glide switches off.

The whole library

This is src/index.ts, about 200 lines.

Loading…

Why I wrote it

I was using Lenis on a site with long tables. It was smooth on a fast laptop, but with the CPU slowed down in Chrome's dev tools it dropped frames. Two things were costing the most: Lenis runs a frame loop all the time, and every row passing under a still mouse got a hover style and a repaint.

glide-scroll only runs while the page is moving, and it puts an invisible layer over the page during a glide so nothing underneath gets hovered. On that site it cut the main-thread work per scroll by about 60%.

It does less than Lenis. It only smooths the whole page, not scrolling elements, and it doesn't give you scroll events for animation libraries. If you need those, use Lenis.

Filler, so there's something to scroll