Hi, great Project! Zooming the canvas in and out with the mouse wheel would feel a lot more natural, if the center of the zoom were the location of the mouse pointer. It's been a few years, but I've already implemented such a zoom in a project of mine. If you want to take a look it's linked below.
https://github.com/marvk/vatprism/blob/6dcdf04ba1f8c6fe67c5b2590ba4162009bde5f2/src/main/java/net/marvk/fs/vatsim/map/view/map/MapView.java#L317-L336
private void zoomMap(final double d) {
final double fScroll = Math.pow(viewModel.getScrollSpeed(), 1. / 4);
final boolean scrollingIn = d > 0;
final double delta = scrollingIn ? fScroll : 1.0 / fScroll;
final double oldScale = viewModel.scaleProperty().get();
final double newScale = Math.min(Math.max(oldScale * delta, MIN_SCALE), MAX_SCALE);
if (Double.compare(oldScale, newScale) == 0) {
return;
}
viewModel.scaleProperty().set(newScale);
final Point2D worldCenter = viewModel.getWorldCenter();
final Point2D mouseWorldPosition = viewModel.getMouseWorldPosition().multiply(-1);
final double f = oldScale / newScale;
viewModel.setWorldCenter(mouseWorldPosition.multiply(1 - f).add(worldCenter.multiply(f)));
}
P.S. I tried running the project locally to try and get a PR going, but I ran into some issues which I think might be related to Windows paths. If you're interested, I can share details.
Hi, great Project! Zooming the canvas in and out with the mouse wheel would feel a lot more natural, if the center of the zoom were the location of the mouse pointer. It's been a few years, but I've already implemented such a zoom in a project of mine. If you want to take a look it's linked below.
https://github.com/marvk/vatprism/blob/6dcdf04ba1f8c6fe67c5b2590ba4162009bde5f2/src/main/java/net/marvk/fs/vatsim/map/view/map/MapView.java#L317-L336
P.S. I tried running the project locally to try and get a PR going, but I ran into some issues which I think might be related to Windows paths. If you're interested, I can share details.