Scroll Control
Control your scroll IN A WAY THAT DOESN'T SUCK!
Do you hate it when the browser takes control of your scroll?
Do you like the idea generally, but haven't found a solution that doesn't annoy you?
FINALLY THERE IS AN ANSWER!!!
Installation
npm install scroll-control
- Add to your webpack imports
import ScrollControl from 'scroll-control'
Usage
- After the DOM loads, call
ScrollControl.init([options])
- If you feel like it, call
ScrollControl.destroy()
Configuration
/** * An array of DOM elements that ScrollControl will snap to. * This defaults to document.querySelectorAll('section') * * @type */ sections: /** * The duration of the snap, in milliseconds * * @type */ duration: 500 /** * The offset of the snapping target * * @type */ edgeOffset: 0 /** * Force ScrollControl to snap on a part of each section. * * null Snap to the bottom of each section if going up & top if going down. * 'top' Force snap to the top of each section * 'bottom' Force snap to the bottom of each section * * @type */ forceSnapOn: null /** * Enable or disable smooth scrolling when clicking on in-page anchor tags. * This is just an extension of zenscroll.js, * so the ScrollControl events will NOT fire. * * @type */ enableSmoothAnchors: true /** * Called before the snapping starts * * @param * @param * @param * * @return */ { // } /** * Called after the snapping completes * * @param * @param * @param * * @return */ { // };