wheellistener

Cross-browser wheel event listener.

Historically, scroll wheel event models have varied wildly across browsers. Existing solutions to try to resolve them are half-baked and missing basic functionality such as proper feature-detection and the ability to remove an event listener. All of these issues seems simple, but are actually quite complex to implement properly, and without memory leaks.

That’s why I created this library.

This library takes care of all the issues of feature detection and transparently passes the event callback straight into the native event listener for no loss in performance in modern browsers. For those older browsers that need a little help, the event callback is wrapped and a new event object is created to normalize the event properties, even in legacy IE. This library even emulates the capture and bubble phases for legacy IE, for a consistent API. It is even possible to attach events across window objects, so attaching events inside an iframe just works.

All of that is wrapped up in a UMD module ready to work with your favorite tools, and unit tested to ensure it works with you least-favorite (and favorite) browsers.

 

Downloads

  • GitHub
  • NPM: $ npm install wheellistener
  • Bower: $ bower install wheellistener