Simple ES6 Class for scroll window to DOM element with smooth animation
Example: komock.github.io/scroll-window-to-element/
npm i --save-dev scroll-window-to-element
// Absolute path to module 'node_modules/scroll-window-to-element/lib/scroll-window-to-element.js'
import scrollToElement from 'scroll-window-to-element';
let scroller = new scrollToElement({
anchors: 'nav a'
});
scroller.init();
Option | Type | Default | Description |
---|---|---|---|
anchors | string (html) | 'a[href*="#"]' | Selector for anchor (links) |
duration | number | 350 | Animation duration |
offset | number | 0 | Scroll offset |
easing | string | 'easeInOut' | Animation easing. Available: linear, easeInOut |
To link section you can use 'id' or 'data-section' attribute (without '#').
- Fast and lightweight
- No jQuery
- ES6 ready