Permalink
Browse files

seems mousewheel implementation is a bit more complex, using code from

…@brandonaaron jquery-mousewheel to handle it
  • Loading branch information...
1 parent 77dc0fc commit 0eb05f596ce76767bfd00253165b485ad224b8a4 @eskimoblood eskimoblood committed May 10, 2012
Showing with 17 additions and 2 deletions.
  1. +17 −2 js/jquery.knob-1.0.1.js
View
@@ -146,8 +146,23 @@ $(function() {
$this.bind('mousewheel DOMMouseScroll', function(event){
var originalEvent = event.originalEvent;
- var deltaX = originalEvent.detail || originalEvent.wheelDeltaX;
- var deltaY = originalEvent.detail || originalEvent.wheelDeltaY;
+ var deltaY, deltaX;
+
+ if ( originalEvent.wheelDelta ) { delta = originalEvent.wheelDelta }
+ if ( originalEvent.detail ) { delta = -originalEvent.detail }
+
+ // New school multidimensional scroll (touchpads) deltas
+ deltaY = delta;
+
+ // Gecko
+ if ( originalEvent.axis !== undefined && originalEvent.axis === originalEvent.HORIZONTAL_AXIS ) {
+ deltaY = 0;
+ deltaX = -1*delta;
+ }
+
+ // Webkit
+ if (originalEvent.wheelDeltaY !== undefined ) { deltaY = originalEvent.wheelDeltaY; }
+ if (originalEvent.wheelDeltaX !== undefined ) { deltaX = -1*originalEvent.wheelDeltaX; }
setVal( deltaX > 0 || deltaY > 0 ? 1 : deltaX < 0 || deltaY < 0 ? -1 : 0);
event.preventDefault();
});

0 comments on commit 0eb05f5

Please sign in to comment.