1.3.0 • Published 4 years ago

wheel-indicator v1.3.0

Weekly downloads
155
License
MIT
Repository
github
Last release
4 years ago

wheel-indicator

Indicates when user makes swipe gesture on a trackpad or mouse wheel.

Build Status

trackpad

Installing

npm i -S wheel-indicator

or oldschool method:

<script src="wheel-indicator.js"></script>

Usage

var WheelIndicator = require('wheel-indicator'); // ← if you use build system

var indicator = new WheelIndicator({
  elem: document.querySelector('.element'),
  callback: function(e){
    console.log(e.direction) // "up" or "down"
  }
});

//The method call
indicator.getOption('preventMouse'); // true

API

Options

FieldTypeDefault valueMutable (by setOptions())Description
elemObject (dom node)documentNoDOM node to listen wheel event on.
callbackFunction-YesThe callback, which will be triggered on gesture. Gets for the first argument a native wheel event object, extended by direction property, taking value 'up' or 'down'.
preventMouseBooltrueYesDisables mouse wheel working. In other words applies preventDefault() to wheel event.

Instance methods

MethodDescription
turnOff()Turns off callback triggering.
turnOn()Turns on callback trigerring.
setOptions(options)Sets the mutable options. The only argument must be Object.
getOption('option')Returns option value. The only argument must be String.
destroy()Removes event listener.
1.3.0

4 years ago

1.2.2

5 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.4

8 years ago