Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mousewheel event is not triggering in firefox browser

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 ?

like image 730
SivaRajini Avatar asked May 28 '13 09:05

SivaRajini


People also ask

What is Mousewheel event?

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.

What is Mousewheel JS?

About Mousewheel JS Mousewheel is a jQuery plugin that adds cross-browser mouse wheel support. Also, Scroll distance can be measured using Delta normalization.

How do you scroll with a mouse in Python?

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.


1 Answers

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.

like image 64
Louis Ameline Avatar answered Sep 22 '22 21:09

Louis Ameline