Please refer the below code.
$(this.element).on("mousewheel", this.chartMouseWheel); chartMouseWheel:function(e) { if(e.originalEvent.wheelDelta /120 > 0) { alert('scrolling up !'); } else{ alert('scrolling down !'); } if (e.preventDefault) e.preventDefault(); e.returnValue = false; },
this event triggering properly in IE,chrome and not triggering in Firefox ?
The wheel event fires when the user rotates a wheel button on a pointing device (typically a mouse). This event replaces the non-standard deprecated mousewheel event. Note: Don't confuse the wheel event with the scroll event.
About Mousewheel JS Mousewheel is a jQuery plugin that adds cross-browser mouse wheel support. Also, Scroll distance can be measured using Delta normalization.
to generate scroll events, use the mouse_event method with MOUSEEVENTF_WHEEL. for other events, e.g. forward/back button, it depends on how the mouse is set up and which button will trigger it. see the msdn document on this for a list of possible values.
This is 2017 and the right answer is now:
$(window).on('wheel', function(event){ // deltaY obviously records vertical scroll, deltaX and deltaZ exist too if(event.originalEvent.deltaY < 0){ // wheeled up } else { // wheeled down } });
Works with current Firefox 51, Chrome 56, IE9+
Note: The value of the deltas will depend on the browser and the user settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With