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


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


source


$(document).ready(function() {
    $('html, body, *').mousewheel(function(e, delta) {
        this.scrollLeft -= (delta * 40);
        e.preventDefault();
    });
});

      



which work for all browsers

+1


source







All Articles