Thoma Biguères
Thoma Biguères

Reputation: 1136

Detect the horizontal mousewheel

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.

Upvotes: 5

Views: 4611

Answers (3)

robocat
robocat

Reputation: 5413

You can do this in IE9, IE10, Firefox, Safari and Chrome. The different browsers currently each have a different event you need to register (although they will all eventually converge upon the new W3C standard onwheel event).

In another answer I put a bunch of detail about detecting x-axis scrolling.

Upvotes: 0

lalibi
lalibi

Reputation: 3078

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.

Upvotes: 8

Blazemonger
Blazemonger

Reputation: 92913

Most scrollwheel drivers have an option that changes vertical scrolling to horizontal when the shift key is held down. Try detecting that instead.

Upvotes: 0

Related Questions