I am using the jquery.mousewheel.js plugin (Github) to build a horizontal scrolling website. It works so far, but I am not able to figure out one problem:
If I am using a trackpad (e.g. on a MacBook Pro) and scroll horizontally with two fingers, depending on how parallel the fingers are positioned, the site will stuck or is confused in which direction it should scroll.
Is there a way to make this horizontal scroll also working smooth?
This is the code I use in the head part:
$(function () {
$("html, body, *").mousewheel(function (event, delta) {
this.scrollLeft -= (delta * 5);
this.scrollRight -= (delta * 5);
event.preventDefault();
});
});
Here my jsfiddle with the rebuilt situation: http://jsfiddle.net/mU24m/
even if this question is a couple of months old, I'll leave something that worked for me.
The idea is that trackpads usually move simultaneously on X and Y, so if we detect a horizontal movement in the scroll wheel listener it is likely a trackpad. Note that you only need to adjust left not both left and right.
You could also remember that there was a movement on X and then only respond to that axis for a second or so :