Smooth scroll anchor links, update the URL and focus on the first child node of the target
npm install storm-scroll-to
...
...
...
`
JS
`
npm i -S storm-scroll-to
`
either using es6 import
`
import ScrollTo from 'storm-scroll-to';
ScrollTo.init('.js-scroll-to');
`
aynchronous browser loading (use the .standalone version in the /dist folder)
`
import Load from 'storm-load';
Load('/content/js/async/storm-scroll-to.standalone.js')
.then(() => {
ScrollTo.init('.js-scroll-to');
});
`
Options
`
{
easing: 'easeInOutCubic', //see src/lib/easing.js for availble easing functions
speed: 260,//ms
offset: 0,
pushState: true,//update the URL
focus: true,//focus on the first focusable child of the target node
callback: null
}
`
e.g.
`
ScrollTo.init('.js-scroll-to', {
offset: '50%'
});
`
Tests
`
npm run test
``