Linked Questions

Popular Questions

Mousepad firing too many "wheel" events in JavaScript

Asked by At

I'm trying to detect "wheel" events on a web page to intercept these and implement a page-by-page scroll instead.

This works fine with a mouse - using the wheel seems to trigger a single "wheel" event, which I'm able to intercept.

I have an issue with mousepad however, which seems to fire multiple successive "wheel" events. I have tried throttling my custom scroll function using underscoreJS and disabling trailing end, but somehow the subsequent events are still fired..

wheelHandlerThrottled: _.throttle(function(e, pageNum) {
  // My scrolling code
}, 500, {leading: true, trailing: false})

When on page 1 and scrolling down with mousepad, I'll get the following behavior:

Scroll to page 2 500 ms pause Scroll to page 3 500 ms pause Scroll to page 4

Logging events in the console shows me that 3 "wheel" events are fired and processed.. so it's like my throttling is not working, but instead a pause is inserted between every event.

Related Questions