2.2.1 • Published 5 years ago

smooth-scroller v2.2.1

Weekly downloads
44
License
MIT
Repository
github
Last release
5 years ago

Smooth-scroller

npm

A tiny, ES6 JavaScript lib to handle smooth scrolling.

Installation

npm install smooth-scroller

Usage

See the full example.

Javascript

import 'smooth-scroller';

HTML

<a href="#foo" data-smooth>Scroll Smoothly</a>
...some content...
<div id="foo"></div>

Events

Custom events are fired on the element:

EventDescription
smoothscroll:startSmooth scroll starts
smoothscroll:endSmooth scroll ends

Methods

Smooth-scroller exposes two methods:

init([selector='data-smooth'], offset=0)

Enables smooth-scroller on the elements matched by selector.

Parameters

selector='[data-smooth]' - {String} - Elements that will trigger smooth-scroll call once they're clicked

offset=0 - {Number} - Controls the distance (negative or positive) between the top border of the element and the top border of the window.

scroll(target, hash, offset=0, silent=false)

target - {string|Element|NodeList} - Target element to scroll

hash - {string|Element|NodeList} - DOM element ID to scroll

offset=0 - {Number} - Controls the distance (negative or positive) between the top border of the element and the top border of the window.

silent=false - {Boolean} - If enabled, will generate a history.pushState event

2.2.1

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.4.0

6 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago