scrollDetector
scrollDetector
detects scroll event types: scroll derection and whether page-top or page-bottom or middle.
Example
Usage
$ npm install --save scroll-detector
then
import scrollDetector from 'scroll-detector';
scrollDetector.on( 'scroll', () => {
console.log( 'scroll' );
} );
scrollDetector.on( 'scroll:up', () => {
console.log( 'scroll:up' );
} );
scrollDetector.on( 'scroll:down', () => {
console.log( 'scroll:down' );
} );
scrollDetector.on( 'at:top', () => {
console.log( 'at:top' );
} );
scrollDetector.on( 'at:bottom', () => {
console.log( 'at:bottom' );
} );
Other features
scrollDetector.isPageTop()
whether at the page top or not.scrollDetector.isPageBottom()
whether at the page bottom or not.scrollDetector.off( eventName, func )
to remove the listener.scrollDetector.getScrollTop()
will return scrollTop amount in pixels.scrollDetector.mute()
to disabled the detector.scrollDetector.unmute()
to re-enable the detector.