Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/mouse-wheel
Speed controlled mouse scrolling
https://github.com/mikolalysenko/mouse-wheel
Last synced: 5 days ago
JSON representation
Speed controlled mouse scrolling
- Host: GitHub
- URL: https://github.com/mikolalysenko/mouse-wheel
- Owner: mikolalysenko
- License: mit
- Created: 2015-02-17T21:56:31.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-01-26T19:49:53.000Z (almost 7 years ago)
- Last Synced: 2024-12-13T04:36:59.583Z (12 days ago)
- Language: JavaScript
- Homepage: https://mikolalysenko.github.io/mouse-wheel
- Size: 8.79 KB
- Stars: 51
- Watchers: 3
- Forks: 11
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
mouse-wheel
===========
Consistent cross browser mouse wheel events. [Test it out in your browser here](https://mikolalysenko.github.io/mouse-wheel/).# Example
```javascript
require('mouse-wheel')(function(dx, dy) {
document.body.innerHTML = 'Scroll:' + [dx,dy] + '
'
})
```# Install
```
npm i mouse-wheel
```# API
#### `require('mouse-wheel')(element, callback, noScroll)`
Hook an event handler for the mouse wheel on `element`.* `element` is an optional DOM element, or if unspecified then is the window object.
* `callback(dx, dy, dz, ev)` is called whenever the mouse scrolls
+ `dx, dy, dz` is the amount of scrolling vertically, horizontally and depth-wise in pixels
+ `ev` is the MouseEvent object associated with the event
* `noScroll` is an optional flag, which if set disables scrolling the pageReturns listener function `listener` so that it may be detached later with `element.removeEventListener('wheel', listener)`
# License
(c) 2015 Mikola Lysenko. MIT License