1.2.0 • Published 9 years ago
mouse-wheel v1.2.0
mouse-wheel
Consistent cross browser mouse wheel events. Test it out in your browser here.
Example
require('mouse-wheel')(function(dx, dy) {
document.body.innerHTML = '<p>Scroll:' + [dx,dy] + '</p>'
})Install
npm i mouse-wheelAPI
require('mouse-wheel')(element, callback, noScroll)
Hook an event handler for the mouse wheel on element.
elementis an optional DOM element, or if unspecified then is the window object.callback(dx, dy, dz, ev)is called whenever the mouse scrollsdx, dy, dzis the amount of scrolling vertically, horizontally and depth-wise in pixelsevis the MouseEvent object associated with the event
noScrollis an optional flag, which if set disables scrolling the page
Returns listener function listener so that it may be detached later with element.removeEventListener('wheel', listener)
License
(c) 2015 Mikola Lysenko. MIT License