New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wheel-indicator

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wheel-indicator - npm Package Compare versions

Comparing version 1.1.4 to 1.2.0

34

lib/wheel-indicator.js
/**
* Generates event when user makes new movement (like a swipe on a touchscreen).
* @version 1.1.4
* @version 1.2.0
* @link https://github.com/Promo/wheel-indicator

@@ -10,12 +10,11 @@ * @license MIT

var WheelIndicator = (function(win, doc) {
var eventWheel = 'onwheel' in doc ? 'wheel' : 'mousewheel',
DEFAULTS = {
var WheelIndicator = (function() {
function Module(options) {
var DEFAULTS = {
callback: function(){},
elem: doc,
elem: document,
preventMouse: true
};
function Module(options){
this.eventWheel = 'onwheel' in document ? 'wheel' : 'mousewheel';
this._options = extend(DEFAULTS, options);

@@ -35,3 +34,3 @@ this._deltaArray = [ 0, 0, 0 ];

if (self._options.preventMouse) {
preventDefault(event);
preventDefault(event);
}

@@ -41,3 +40,3 @@ }

addEvent(this._options.elem, eventWheel, this._wheelHandler);
addEvent(this._options.elem, this.eventWheel, this._wheelHandler);
}

@@ -70,3 +69,3 @@

if (neededOption !== undefined) {
return neededOption;
return neededOption;
}

@@ -78,3 +77,3 @@

destroy: function(){
removeEvent(this._options.elem, eventWheel, this._wheelHandler);
removeEvent(this._options.elem, this.eventWheel, this._wheelHandler);

@@ -92,4 +91,3 @@ return this;

var getDeltaY = function(event){
if(event.wheelDelta && !event.deltaY) {
if (event.wheelDelta && !event.deltaY) {
getDeltaY = function(event) {

@@ -108,3 +106,3 @@ return event.wheelDelta * -1;

function preventDefault(event){
event = event || win.event;
event = event || window.event;

@@ -147,3 +145,3 @@ if (event.preventDefault) {

//if all of last three deltas is greater than 0 or lesser than 0 then direction is switched
if(Math.abs(repeatDirection) === arrayLength) {
if (Math.abs(repeatDirection) === arrayLength) {
//determine type of sustainable direction

@@ -161,3 +159,3 @@ //(three positive or negative deltas in a row)

//if wheel`s moving and current event is not the first in array
if(!self._isStopped){
if (!self._isStopped){
if(changedDirection) {

@@ -180,3 +178,3 @@ self._isAcceleration = true;

//if wheel is stopped and current delta value is the first in array
if(self._isStopped) {
if (self._isStopped) {
self._isStopped = false;

@@ -252,3 +250,3 @@ self._isAcceleration = true;

return Module;
}(window, document));
}());

@@ -255,0 +253,0 @@ if (typeof exports === 'object') {

{
"name": "wheel-indicator",
"version": "1.1.4",
"version": "1.2.0",
"description": "normalizes an inertial mousewheel",

@@ -5,0 +5,0 @@ "main": "lib/wheel-indicator",

# wheel-indicator
Generates event when user makes new movement (like a `touchstart` on a touchscreen).
Indicates when user makes swipe gesture on a trackpad or mouse wheel.

@@ -8,22 +8,24 @@ [![Build Status][travis-image]][travis-url]

## Connection
## Installing
```bash
npm i -S wheel-indicator
```
or oldschool method:
```html
<script src="wheel-indicator.js"></script>
```
or if you use build system:
```javascript
var WheelIndicator = require('wheel-indicator');
```
## Usage
```javascript
var indicator = new WheelIndicator({
elem: document.querySelector('.element'),
callback: function(e){
console.log(e.direction) // "up" or "down"
}
});
var WheelIndicator = require('wheel-indicator'); // ← if you use build system
//The method call
indicator.getOption('preventMouse'); // true
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
```

@@ -36,16 +38,16 @@

| ------- | --------- | ----------- | ---- | ---------------------------------------- |
| `elem` | `Object` (dom node) | `document` | No | Dom node to listen `wheel` event on. |
| `elem` | `Object` (dom node) | `document` | No | DOM node to listen `wheel` event on. |
| `callback` | `Function` | - | Yes | The 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'`. |
| `preventMouse` | `Bool` | `true` | Yes | Disables mouse wheel working. In other words apply `preventDefault()` to `wheel` event. |
| `preventMouse` | `Bool` | `true` | Yes | Disables mouse wheel working. In other words applies `preventDefault()` to `wheel` event. |
### Instance methods
| Method | Description |
| ------- | ------- | ---------------------------------------- |
| `turnOff()` | Turn off callback triggering |
| `turnOn()` | Turn 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. |
| ------- | ---------------------------------------- |
| `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. |
[travis-url]: http://travis-ci.org/Promo/wheel-indicator
[travis-image]: http://img.shields.io/travis/Promo/wheel-indicator.svg?branch=master&style=flat
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc