1.0.2 • Published 7 years ago

nav-scroll-spy v1.0.2

Weekly downloads
125
License
MIT
Repository
github
Last release
7 years ago

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'
import NavScrollSpy from 'nav-scroll-spy';
let spy = new NavScrollSpy();
spy.init();

Markup example

<nav>
	<ul>
		<li><a href="#section-1">section-1</a></li>
		<li><a href="#section-2">section-2</a></li>
	</ul>
</nav>

Options

OptionTypeDefaultDescription
offsetnumber0Scroll offset
currentClassstring'active'Element class for current navigation item (or items). Class will be applied to link parent.
selectorstring (html)'nav ahref*="#"'Selector for navigation links
throttlenumber100Throttling window events (scroll and resize) to improve performance

Features

  1. Fast and lightweight
  2. No jQuery
  3. ES6 ready
1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago