I've seen numerous examples of code that listens to mousewheel
and DOMMouseEvent
that assume it can only move up and down. But many mouse wheels can also move side to side. All the example code I've seen shows the same values for side to side as up and down and can't tell if it's horizontal vs vertical. Is there a way to tell?
This cannot tell horizontal vs vertical
$('#abs').bind('mousewheel DOMMouseScroll', function(e) {
var scrollTo = 0;
e.preventDefault();
if (e.type == 'mousewheel') {
scrollTo = (e.originalEvent.wheelDelta * -1);
alert("w"+e.originalEvent.wheelDelta);
}
else if (e.type == 'DOMMouseScroll') {
scrollTo = 40 * e.originalEvent.detail;
alert("d"+e.originalEvent.detail);
}
//Assumes vertical
$(this).scrollTop(scrollTo + $(this).scrollTop());
});