nav-scroll-spy
Simple ES6 Scroll Spy Class
Example: komock.github.io/nav-scroll-spy
Install
npm i --save-dev nav-scroll-spy
Usage
// Absolute path to module 'node_modules/nav-scroll-spy/src/js/nav-scroll-spy.js';let spy = ;spy;
Markup example
section-1 section-2
Options
Option | Type | Default | Description |
---|---|---|---|
offset | number | 0 | Scroll offset |
currentClass | string | 'active' | Element class for current navigation item (or items). Class will be applied to link parent. |
selector | string (html) | 'nav a[href*="#"]' | Selector for navigation links |
throttle | number | 100 | Throttling window events (scroll and resize) to improve performance |
Features
- Fast and lightweight
- No jQuery
- ES6 ready