Lexicon / Scroll behaviour · 10 of 11

23 / Scroll behaviour

Scrollspy

Whatever has reached eye level is the thing the index marks as where you are.

also called section tracking · active-anchor highlight · reading position

That rootMargin collapses the viewport to a thin band across its middle, so “current” means what is at eye level rather than what merely happens to be on screen. The index pinned to the top of this page is one.

How it is builtnew IntersectionObserver(fn, { rootMargin: '-45% 0px -45% 0px' })
scroll inside ↓