wheelcapture

2.0.0 • Public • Published

WheelCapture

Tiny utility to avoid capturing (cancelling) wheel-events when users are using their mouse-wheel to scroll the page.

WheelCapture.isOkFor( capturingElm ); returns true if the current burst (or sequence) of wheel-events started on capturingElm or an element within capturingElm.

0: Install and inclusion

npm install wheelcapture

WheelCapture is CommonJS (require()) friendly, using module.exports by default -- setting window.WheelCapture only as last resort.

Configuration

You can control how many milliseconds must elapse for wheel-events to be considered separate/unconnected events.

var WheelCapture = require('wheelcapture');

WheelCapture.settings.delay = 400; // 400ms is the default

Usage

React example:

componentDidMount: function () {
    WheelCapture.on();
  },

componentWillUnmount: function () {
    WheelCapture.off();
  },

onWheelHandler: function (e) {
    var capturingElm = this;
    if ( WheelCapture.isOkFor(capturingElm) ) {
      e.preventDefault();
      doTimelineShift();
    }
  },

Package Sidebar

Install

npm i wheelcapture

Weekly Downloads

2

Version

2.0.0

License

MIT / GPL-2.0+

Last publish

Collaborators

  • maranomynet