├── .gitignore ├── LICENSE ├── README.md ├── index.js ├── package.json └── test └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | 10 | pids 11 | logs 12 | results 13 | 14 | npm-debug.log 15 | node_modules 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2023 Andrei Kashcha 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wheel 2 | 3 | I don't think you need to use this library anymore. Use this instead: 4 | 5 | 6 | ``` js 7 | element.addEventListener('wheel', ...); 8 | ``` 9 | 10 | In 2014 this module was supposed to unify handling of mouse wheel event across 11 | different browsers. 12 | 13 | Now it's just a wrapper on top of `element.addEventListener('wheel', callback)`. 14 | 15 | # Usage 16 | 17 | ``` js 18 | var addWheelListener = require('wheel').addWheelListener; 19 | var removeWheelListener = require('wheel').removeWheelListener; 20 | addWheelListener(domElement, function (e) { 21 | // mouse wheel event 22 | }); 23 | removeWheelListener(domElement, function); 24 | ``` 25 | 26 | You can also use a shortcut for addWheelListener: 27 | 28 | ``` js 29 | var addWheelListener = require('wheel'); 30 | addWheelListener(domElement, function (e) { 31 | // mouse wheel event 32 | }); 33 | ``` 34 | 35 | # install 36 | 37 | With [npm](https://npmjs.org) do: 38 | 39 | ``` 40 | npm install wheel 41 | ``` 42 | 43 | # license 44 | 45 | MIT 46 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This module used to unify mouse wheel behavior between different browsers in 2014 3 | * Now it's just a wrapper around addEventListener('wheel'); 4 | * 5 | * Usage: 6 | * var addWheelListener = require('wheel').addWheelListener; 7 | * var removeWheelListener = require('wheel').removeWheelListener; 8 | * addWheelListener(domElement, function (e) { 9 | * // mouse wheel event 10 | * }); 11 | * removeWheelListener(domElement, function); 12 | */ 13 | 14 | module.exports = addWheelListener; 15 | 16 | // But also expose "advanced" api with unsubscribe: 17 | module.exports.addWheelListener = addWheelListener; 18 | module.exports.removeWheelListener = removeWheelListener; 19 | 20 | 21 | function addWheelListener(element, listener, useCapture) { 22 | element.addEventListener('wheel', listener, useCapture); 23 | } 24 | 25 | function removeWheelListener( element, listener, useCapture ) { 26 | element.removeEventListener('wheel', listener, useCapture); 27 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "wheel", 3 | "version": "1.0.0", 4 | "description": "Mouse wheel event unified for all browsers", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "tap test/*.js" 8 | }, 9 | "keywords": [ 10 | "addWheelListener", 11 | "wheel", 12 | "mouse", 13 | "DOMMouseScroll" 14 | ], 15 | "author": "Andrei Kashcha", 16 | "license": "MIT", 17 | "repository": { 18 | "type": "git", 19 | "url": "https://github.com/anvaka/wheel" 20 | }, 21 | "devDependencies": { 22 | "tap": "^1.3.2" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | var test = require('tap').test; 2 | 3 | var api = require('../'); 4 | 5 | test('it exists', function(t) { 6 | t.ok(typeof api === 'function', 'Api is there'); 7 | t.ok(typeof api.addWheelListener === 'function', 'You can add wheel listener'); 8 | t.ok(typeof api.removeWheelListener === 'function', 'You can remove wheel listener'); 9 | 10 | t.end(); 11 | }); 12 | --------------------------------------------------------------------------------