Merge pull request #60 from gdevic/dev

Added zoom using the mouse wheel
This commit is contained in:
BigEd 2020-03-31 13:08:33 +01:00 committed by GitHub
commit badcf8e40b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -277,6 +277,15 @@ function handleKey(e){
else if(c=='p') stepBack(); 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 // handler for mousedown events over chip display
// must handle click-to-select (and focus), and drag to pan // must handle click-to-select (and focus), and drag to pan
function mouseDown(e){ function mouseDown(e){
@ -599,6 +608,7 @@ function setupChipLayoutGraphics(){
} }
// grant focus to the chip display to enable zoom keys // grant focus to the chip display to enable zoom keys
chipsurround.focus(); chipsurround.focus();
chipsurround.onwheel = function(e){handleWheelZoom(e);};
chipsurround.onmousedown = function(e){mouseDown(e);}; chipsurround.onmousedown = function(e){mouseDown(e);};
chipsurround.onkeypress = function(e){handleKey(e);}; chipsurround.onkeypress = function(e){handleKey(e);};
chipsurround.onmouseout = function(e){mouseLeave(e);}; chipsurround.onmouseout = function(e){mouseLeave(e);};