1.0.1 • Published 5 years ago

react-wheeler v1.0.1

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

React-Wheeler by Adrian

Version Repository size Number of GitHub issues MIT License

React component for listening to and acting on scroll/wheel/touchmove events.

How to use

Installation

yarn add react-wheeler

As a component

import Wheeler from 'react-wheeler';

const YourComponent = () => {
  const handleWheelStart = () => {};
  const handleWheel = ({ delta }) => {};
  const handleWheelEnd = ({ delta }) => {};

  return (
    <>
      <Wheeler
        onWheel={handleWheel}
        onWheelStart={handleWheelStart}
        onWheelEnd={handleWheelEnd}
      />
    </>
  );
};

Properties

PropTypeDefaultDescription
throttleNumber20How many milliseconds between each onWheel event
onWheelStartfuncFired when wheeling starts
onWheelfuncFired while wheeling
onWheelEndfuncFired when wheeling has stopped
eventString'auto'Which event to listen to. Possible values 'auto', 'wheel', 'touch'
elementRefReact refElement reference created with React.createRef(). Required for touch

Development

yarn install to install dependencies

yarn start to start the file watcher to automatically build on file changes

Contribute

I'm open for pull requests if you've got any enhancements! You're a star! ⭐