Hamster.js

github.com/monospaced/hamster.js

A standalone javascript library for cross-browser mouse wheel support.

In addition to normalising the wheel event, the event callback receives 3 extra arguments which are the normalized “deltas” of the mouse wheel.

Hamster(el).wheel(function(event, delta, deltaX, deltaY){
  console.log(delta, deltaX, deltaY);
});
    

No jQuery or other libraries required, but an adapter for AngularJS is available. Tested in these core browsers.

Tests

  1. Plain wheel() with a function passed in, does not prevent default. (Also logs the value of pageX and pageY event properties.)
  2. Should prevent the default action.
  3. Should not log an event. Testing unwheel().
  4. Has two handlers.
  5. Is like 2. but has children. The children should not scroll until mousing over them.
  6. Is like 5. but should not scroll children or parents.
  7. Is like 6. but has no children. It will propagate the event and scroll 6. as well.

Monospaced Labs

1.

2.

3.

4.

5.

6.

7.