Skip to content

Commit

Permalink
fix: dont double-check if shift is down on scroll-panning
Browse files Browse the repository at this point in the history
This solves issue #55
  • Loading branch information
sillydan1 committed Dec 7, 2022
1 parent fba26c3 commit 6ae4327
Showing 1 changed file with 2 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,10 @@ public CanvasPresentation() {

initializeGrid();

/*
// Center on the component
controller.component.heightProperty().addListener(observable -> {
setTranslateY(getHeight() / 2 - controller.component.getHeight() / 2);
setTranslateX(getWidth() / 2 - controller.component.getWidth() / 2);
});
// Move the component half a grid size to align it to the grid
controller.component.setLayoutX(GRID_SIZE / 2);
controller.component.setLayoutY(GRID_SIZE / 2);
*/
CanvasDragHelper.makeDraggable(this, mouseEvent -> mouseEvent.getButton().equals(MouseButton.SECONDARY));
setOnScroll(e -> {
var dx = getTranslateX() + e.getDeltaX();
var dy = getTranslateY() + e.getDeltaY();
if(e.isShiftDown()) { // shift enables you to scroll with one wheel to the side
dx = getTranslateX() + e.getDeltaY();
dy = getTranslateY() + e.getDeltaX();
}
setTranslateX(dx);
setTranslateY(dy);
setTranslateX(getTranslateX() + e.getDeltaX());
setTranslateY(getTranslateY() + e.getDeltaY());
});
// support trackpads
setOnZoom(e -> ZoomHelper.zoom(e.getZoomFactor()));
Expand Down

0 comments on commit 6ae4327

Please sign in to comment.