wheelcapture
v2.0.0
Published
Tiny utility to avoid capturing (cancelling) wheel-events when users are using their mouse-wheel to scroll the page.
Downloads
6
Maintainers
Readme
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();
}
},