Indicates when user makes swipe gesture on a trackpad or mouse wheel.
npm i -S wheel-indicator
or oldschool method:
<scriptsrc= "wheel-indicator.js"></script>
varWheelIndicator=require('wheel-indicator');// ← if you use build system
varindicator=newWheelIndicator({
elem:document.querySelector('.element'),
callback:function(e){
console.log(e.direction)// "up" or "down"
}
});
//The method call
indicator.getOption('preventMouse');// true
Field | Type | Default value | Mutable (bysetOptions() ) |
Description |
---|---|---|---|---|
elem |
Object (dom node) |
document |
No | DOM node to listenwheel event on. |
callback |
Function |
- | Yes | The callback, which will be triggered on gesture. Gets for the first argument a nativewheel event object, extended bydirection property, taking value'up' or'down' . |
preventMouse |
Bool |
true |
Yes | Disables mouse wheel working. In other words appliespreventDefault() towheel event. |
Method | Description |
---|---|
turnOff() |
Turns off callback triggering. |
turnOn() |
Turns on callback trigerring. |
setOptions(options) |
Sets the mutable options. The only argument must beObject . |
getOption('option') |
Returns option value. The only argument must beString . |
destroy() |
Removes event listener. |