1.0.16 • Published 6 years ago

active-scroll-navigation v1.0.16

Weekly downloads
10
License
ISC
Repository
github
Last release
6 years ago

Scrolling Active Navigation

Whats This

This is a plain JavaScript Class that changes the active navigation item while the user scroll up/down the page. It has options for active class name and scroll offset. You can also turn the event listener for window scroll on and off if need along with retrieving the active item index.

Demo Link

https://codepen.io/Cagosto/pen/opwJoK

Installation

Get if from npm

npm i active-scroll-navigation

import it in your app

import ACTIVE_SCROLL from 'active-scroll-navigation'

How to use

new ACTIVE_SCROLL({
  nav: '.main-nav'
  offSet: 0,
  activeString: 'main-nav__item—active'
});

Settings

NameTypeRequiredValue
navStringTrue""
offSetNumFalse0
activeStringStringTruemain-nav__item--active

Get Active Index

const activeScroll = new ACTIVE_SCROLL();
let index = activeScroll.activeItem();

Events

const activeScroll = new ACTIVE_SCROLL();

activeScroll.eventsSrollOff() //Stop Scroll Listener

activeScroll.eventsSroll() //Start Scroll Listener
1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago