Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the direction of mousewheel scrolling on an HTML page?

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?

like image 390
mohamad javidi Avatar asked Jul 31 '15 21:07

mohamad javidi


2 Answers

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/

Source

like image 134
Maximillian Laumeister Avatar answered Oct 21 '22 21:10

Maximillian Laumeister


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

that work for all browser

like image 27
mohamad javidi Avatar answered Oct 21 '22 22:10

mohamad javidi