scroll-to-element
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/scroll-to-element package

2.0.3 • Public • Published

scroll-to-element

Smooth scrolls to element of the specified selector or element reference with optional offset, scroll-positon, easing, and duration. Takes into account document height for elements low on the page.

NPM

scrollToElement(selector, <options>)

Valid options:
offset : number

Add an additional offset to the final position. if > 0 then page is moved to the bottom otherwise the page is moved to the top.

align : string

Alignment of the element in the resulting viewport. Can be one of 'top', 'middle' or 'bottom'. Defaulting to 'top'.

ease : string

Easing function defaulting to "out-circ" (view ease for more)

duration : number

Animation duration defaulting to 1000

EXAMPLE

var scrollToElement = require('scroll-to-element');
 
scrollToElement('#id');
 
// with options
scrollToElement('.className', {
    offset: 0,
    ease: 'out-bounce',
    duration: 1500
});
 
// or if you already have a reference to the element
var elem = document.querySelector('.className');
scrollToElement(elem, {
    offset: 0,
    ease: 'out-bounce',
    duration: 1500
});

LICENSE

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.341,972latest

Version History

VersionDownloads (Last 7 Days)Published
2.0.341,972
2.0.2304
2.0.10
2.0.0200
1.1.09
1.0.03
0.0.21
0.0.11

Package Sidebar

Install

npm i scroll-to-element

Weekly Downloads

42,490

Version

2.0.3

License

MIT

Unpacked Size

36.8 kB

Total Files

11

Last publish

Collaborators

  • willhoag