Skip to content

Commit

Permalink
adding support for mousewheel and arrow keys
Browse files Browse the repository at this point in the history
  • Loading branch information
eskimoblood committed May 10, 2012
1 parent 7a4f59c commit de49560
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions js/jquery.knob-1.0.1.js
Expand Up @@ -116,6 +116,7 @@ $(function() {
}
);


k = new Knob( c, opt );
k.onRelease = opt.release;
k.val( parseInt($this.val()) || 0 );
Expand All @@ -135,6 +136,25 @@ $(function() {
}else{
$this.attr('readonly','readonly');
}

var keys={37: -1, 38:1, 39:1, 40: -1}

$this.keydown(function(event){
setVal( keys[event.keyCode])
});

$this.bind('mousewheel DOMMouseScroll', function(event){
var deltaX = event.originalEvent.wheelDeltaX;
var deltaY = event.originalEvent.wheelDeltaY;
event.preventDefault();
setVal( deltaX > 0 || deltaY > 0 ? 1 : deltaX < 0 || deltaY < 0 ? -1 : 0)
});

function setVal(dir){
if(dir){
k.val( parseInt($this.val()) + dir )
}
}
}
).parent();
}
Expand Down

0 comments on commit de49560

Please sign in to comment.