wheellistener – Cross-browser wheel event listener

If you ever wanted to use scroll events in your web app, you’ve probably found what a mess it is, I know I did when I was developing this the theme used on this website. There are snippets out there to try to resolve legacy browser issues, but all of 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.

We can do better! 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.

This library is available on GitHub, NPM, and Bower.

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

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you human? * Time limit is exhausted. Please reload the CAPTCHA.