Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect the horizontal mousewheel

Tags:

jquery

I would like to make a differenciation between three cases :

e.preventDefault();
if(Mousewheel.direction = Left)
    base.goForward();
else if(Mousewheel.direction = Right)
    base.goBack();
else{   
    //Doing normal slide                            

But I can't find anything indicating if the mousewheel is horizontal or vertical, the only returns of the plugin Mousewheel, being delta and event.

If someone knows how i could make a differenciation between horizontal and vertical wheeling, thanks for sharing your tips.

like image 973
Thoma Biguères Avatar asked Nov 21 '11 13:11

Thoma Biguères


1 Answers

UPDATE: I tested it with my laptops pad and event.originalEvent.wheelDeltaX is indeed your answer.

Using some javascript debugging tools, place a breakpoint into the event handler and examine the event object.

enter image description here

There are some interesting properties there like event.originalEvent.wheelDeltaX and event.originalEvent.wheelDeltaY. I don't have a mouse with horizontal scrolling to test it but possibly this is your solution.

like image 182
lalibi Avatar answered Nov 01 '22 18:11

lalibi