Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wheel

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wheel - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

31

index.js

@@ -8,16 +8,27 @@ /**

* Usage:
* var addWheelListener = require('wheel');
* var addWheelListener = require('wheel').addWheelListener;
* var removeWheelListener = require('wheel').removeWheelListener;
* addWheelListener(domElement, function (e) {
* // mouse wheel event
* });
* removeWheelListener(domElement, function);
*/
// by default we shortcut to 'addEventListener':
module.exports = addWheelListener;
var prefix = "", _addEventListener, onwheel, support;
// But also expose "advanced" api with unsubscribe:
mdoule.exports.addWheelListener = addWheelListener;
mdoule.exports.removeWheelListener = removeWheelListener;
var prefix = "", _addEventListener, _removeEventListener, onwheel, support;
// detect event model
if ( window.addEventListener ) {
_addEventListener = "addEventListener";
_removeEventListener = "removeEventListener";
} else {
_addEventListener = "attachEvent";
_removeEventListener = "detachEvent";
prefix = "on";

@@ -40,3 +51,15 @@ }

function removeWheelListener( elem, callback, useCapture ) {
_removeWheelListener( elem, support, callback, useCapture );
// handle MozMousePixelScroll in older Firefox
if( support == "DOMMouseScroll" ) {
_removeWheelListener( elem, "MozMousePixelScroll", callback, useCapture );
}
};
function _addWheelListener( elem, eventName, callback, useCapture ) {
// TODO: in theory this anonymous function may result in incorrect
// unsubscription in some browsers. But in practice, I don't think we should
// worry too much about it (those browsers are on the way out)
elem[ _addEventListener ]( prefix + eventName, support == "wheel" ? callback : function( originalEvent ) {

@@ -83,1 +106,5 @@ !originalEvent && ( originalEvent = window.event );

}
function _removeWheelListener( elem, eventName, callback, useCapture ) {
elem[ _removeEventListener ]( prefix + eventName, callback, useCapture || false );
}

2

package.json
{
"name": "wheel",
"version": "0.0.1",
"version": "0.0.2",
"description": "Mouse wheel event unified for all browsers",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -11,5 +11,16 @@ # wheel

``` js
var addWheelListener = require('wheel').addWheelListener;
var removeWheelListener = require('wheel').removeWheelListener;
addWheelListener(domElement, function (e) {
// mouse wheel event
});
removeWheelListener(domElement, function);
```
You can also use a shortcut for addWheelListener:
``` js
var addWheelListener = require('wheel');
addWheelListener(domElement, function (e) {
// mouse wheel event
// mouse wheel event
});

@@ -16,0 +27,0 @@ ```

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