• Vanilla
X

MenuSpy: Highlight navigation item based on section in view

A JavaScript library to make navigation menus highlight the item based on currently in view section.

It could not be easier to use, just include the script in your page and initialize it. The items in your menu will get active class when the section referenced in your anchor is visible. It’s got a really small footprint and uses requestAnimationFrame to monitor scroll position.