Trigger className changes and callbacks when an element scrolls into view
npm install storm-scroll-points
Trigger className changes and callbacks when an element scrolls into view. Use with care to avoid jank.
`JS
`
npm i -S storm-scroll-points
`
either using es6 import
`
import ScrollPoints from 'storm-scroll-points';ScrollPoints.init('.js-scroll-point');
`
aynchronous browser loading (use the .standalone version in the /dist folder)
`
import Load from 'storm-load';Load('/content/js/async/storm-scroll-point.standalone.js')
.then(() => {
StormScrollPoints.init('.js-scroll-point');
});
`$3
`
{
offset: 0,
callback: false,
throttle: 60,
className: 'is-scrolled-in',
unload: true //only trigger once, to unload the scroll listener
}`
e.g.
`
ScrollPoints.init('.js-scroll-point', {
callback(){
console.info('Scrolled into view');
}
});
`Tests
`
npm run test
``This module depends upon Object.assign available in all evergreen browsers. ie9+ is supported with polyfills, ie8+ will work with even more polyfills for Array functions and eventListeners.
Imports raf-throttle.