2

I am using the jQuery mousewheel plugin to allow the browser to perceive up and down scrolls as left and right. The code is simple:

$('body').bind('mousewheel', function(event, delta) {
     this.scrollLeft -= (delta * 5);
});

You can test out this functionality on a horizontal scrolling page: http://jsfiddle.net/Ema2B/13/

This works great in chrome. Scrolling down scrolls the content pane right. If you bring this into firefox, it DOES NOT work. I ran some tests, and firefox does see the correct delta value, but it does not understand scrollLeft for some reason. I set up a simple test to verfiy this:

$("a.logo").on("click", function(){
      $(body).scrollLeft(300);
});

Again, this works great in chrome, but not firefox. Why does firefox not allow for scrollLeft?

NOTE: Overflow:hidden is set for the body to disable scrollbars. Test out the fiddle in chrome and firefox to see.

JCHASE11
  • 3,901
  • 19
  • 69
  • 132

1 Answers1

8

To get it working on Firefox the selector must have $(“html”) in addition to body. See the snippet below:

$("html, body").mousewheel(function(event, delta) {
    this.scrollLeft -= (delta * 30);
});
JCHASE11
  • 3,901
  • 19
  • 69
  • 132