scroll-detector
TypeScript icon, indicating that this package has built-in type declarations

0.7.1 • Public • Published

scrollDetector

scrollDetector detects scroll event types: scroll derection and whether page-top or page-bottom or middle.

Latest NPM release MIT License

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.

/scroll-detector/

    Package Sidebar

    Install

    npm i scroll-detector

    Weekly Downloads

    137

    Version

    0.7.1

    License

    MIT

    Unpacked Size

    29.6 kB

    Total Files

    11

    Last publish

    Collaborators

    • yomotsu