How to change direction of mouse scrolling on HTML page?
Is there a way to use Javascript or jQuery to change the scrolling direction on an HTML page (with mouse wheel) from top to bottom -> left to right?
+3
mohamad javidi
source
to share
2 answers
Here's a short function that makes your document scroll horizontally instead of vertically using the mouse wheel:
$(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.
Working JSFiddle example: https://jsfiddle.net/1zugp6w6/1/
Source
+2
Maximillian laumeister
source
to share
$(document).ready(function() {
$('html, body, *').mousewheel(function(e, delta) {
this.scrollLeft -= (delta * 40);
e.preventDefault();
});
});
which work for all browsers
+1
mohamad javidi
source
to share