Reputation: 83
Is there a way to use Javascript or jQuery to change the direction of scrolling on an HTML page (with mouse wheel) from up to down -> left to right?
Upvotes: 7
Views: 7708
Reputation: 20359
Here is a short function that makes your document scroll horizontally instead of vertically using the mousewheel:
$(function() {
$("html, body").mousewheel(function(event, delta) {
this.scrollLeft -= (delta * 30);
event.preventDefault();
});
});
You will need to include the jquery.mousewheel.min.js script in your page for it to work.
Working JSFiddle example: https://jsfiddle.net/1zugp6w6/1/
Upvotes: 3
Reputation: 83
$(document).ready(function() {
$('html, body, *').mousewheel(function(e, delta) {
this.scrollLeft -= (delta * 40);
e.preventDefault();
});
});
that work for all browser
Upvotes: 1