Added zoom using the mouse wheel

This commit is contained in:
Goran Devic 2020-03-12 15:09:55 -05:00
parent 5b86a57c2c
commit 8097137323
1 changed files with 17 additions and 7 deletions

View File

@ -277,6 +277,15 @@ function handleKey(e){
else if(c=='p') stepBack();
}
// handler for zoom in/out using the mouse wheel
function handleWheelZoom(e){
chipsurround.focus();
e.preventDefault();
var n = e.deltaY / 100;
if(n>0 && zoom>1) setZoom(zoom/1.2);
if(n<0 && zoom<grMaxZoom) setZoom(zoom*1.2);
}
// handler for mousedown events over chip display
// must handle click-to-select (and focus), and drag to pan
function mouseDown(e){
@ -599,6 +608,7 @@ function setupChipLayoutGraphics(){
}
// grant focus to the chip display to enable zoom keys
chipsurround.focus();
chipsurround.onwheel = function(e){handleWheelZoom(e);};
chipsurround.onmousedown = function(e){mouseDown(e);};
chipsurround.onkeypress = function(e){handleKey(e);};
chipsurround.onmouseout = function(e){mouseLeave(e);};