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">
</div>
-
Link JavaScript and trigger script
<script src="sticky-scroll.js"></script>
<script>
var stickyScroll = StickyScroll('#top')
</script>
Licence
Licensed under the MIT Licence