1.0.2 • Published 6 years ago
animate-scroll-to-hash v1.0.2
animate-scroll-to-hash
Installing
Using npm:
$ npm install animate-scroll-to-hashHow to use
const AnimateScrollToHash = require('animate-scroll-to-hash');
new AnimateScrollToHash(); // set listeners to all links with hash on pageConfig
You can pass the configuration object to the constructor. If you want set listeners on links only to children of block:
new AnimateScrollToHash({
block: document, // search for links. default: document
});If you have fixed header element, you may set margin:
new AnimateScrollToHash({
margin: 60, // top margin after scrolling (px). default: 0
});If height of header may vary depending on screen width:
new AnimateScrollToHash({
margin: {
0: 60, // if client width more than or equal to 0.
960: 80, // if client width more than or equal to 960.
},
});You can change animation duration
new AnimateScrollToHash({
transition: 500, // animation duration (ms). default: 500
});