sticky-scroll
v1.0.5
Published
Stick elements to the top of the page on scroll once they reach the top of the window.
Downloads
9
Maintainers
Readme
Sticky Scroll
JavaScript module for sticking elements to the top of the page on scroll once they reach the top of the window, supports offset from the top of the page.
Instructions
Browserify
var StickyScroll = require('sticky-scroll')
var stickyScroll = new StickyScroll('#top')
Customisable offset
var stickyScroll = StickyScroll('#top', 120)
Second argument is the number of offset pixels from the top of the browser window.
Browser Usage
Add Markup
<div id="top"> <!-- Sticky content --> </div>
Link JavaScript and trigger script
<!-- Put this right before the </body> closing tag --> <script src="sticky-scroll.js"></script> <script> var stickyScroll = StickyScroll('#top') </script>
Licence
Licensed under the MIT Licence