Reputation: 11107
I'm working on some code that detects when you are scrolling the mouse up or down. I want the user to scroll left and right, instead of up and down. My code detects the mouse movements and whether it is up and down. My question is, is there code in jQuery or Javascript that allows the user to scroll left or right based on when an event happens, aka the mouse scrolling up or down?
Upvotes: 1
Views: 844
Reputation: 204698
jQuery.mousewheel + jQuery.scrollTo.
.mousewheel(function(e, d, dx, dy) {
$(this).scrollTo((dy<0?'+':'-')+'='+10*Math.abs(dy)+'px', 0, {axis: 'x'});
e.preventDefault();
});
Demo.
Upvotes: 1
Reputation: 18301
Tie a function to your user mouse up movement and use jQuery's scrollTo plugin. Here's a tutorial detailing it: http://flesler.blogspot.com/2007/10/jqueryscrollto.html
Hope this helps!
Upvotes: 1