Sticky DOM elements
npm install storm-sticky
Sticky DOM elements - use with restraint and care to avoid jank.
npm i -S storm-sticky
`
either using es6 import
`
import Sticky from 'storm-sticky';Sticky.init('.js-sticky');
`
or aynchronous browser loading (use the .standalone version in the /dist folder)
`
import Load from 'storm-load';Load('/content/js/async/storm-sticky.standalone.js')
.then(() => {
StormSticky.init('.js-sticky');
});
`Options
`
{
offset: 0,//from the top of the screen
callback: false,//triggeed when stuck
extentDOMElement: false,//DOM node selector, the node's height will determine when the sticky element unsticks
className: 'is--stuck'//className for active 'stuck' state
}
`
e.g.
`
Sticky.init('.js-sticky', {
extentDOMElement: '.corresponding-article'
});
`Tests
`
npm run test
``This module depends upon Object.assign and window.requestAnimationFrame available in all evergreen browsers. ie9+ is supported with polyfills, ie8+ will work with even more polyfills for Array functions and eventListeners.