Skip to content

Commit 1244130

Browse files
committed
Fix clip area when zoomed
1 parent 83b60c3 commit 1244130

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/main/java/com/brunomnsilva/smartgraph/containers/ContentZoomPane.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public ContentZoomPane(Node content) {
7676

7777
setCenter(this.content = content);
7878
enablePanAndZoom();
79+
enableResizeListener();
7980
}
8081

8182
public DoubleProperty scaleFactorProperty() {
@@ -100,6 +101,11 @@ private static double boundValue(double value, double min, double max) {
100101
return value;
101102
}
102103

104+
private void enableResizeListener() {
105+
this.widthProperty().addListener((observableValue, oldValue, newValue) -> clipArea());
106+
this.heightProperty().addListener((observableValue, oldValue, newValue) -> clipArea());
107+
}
108+
103109
private void enablePanAndZoom() {
104110

105111
setOnScroll((ScrollEvent event) -> {
@@ -175,15 +181,15 @@ private void clipArea() {
175181
setClip(new Rectangle(width,height));
176182
}
177183

178-
184+
/**
185+
* Keeps track of mouse drag action.
186+
*/
179187
private static class DragContext {
180-
181188
double mouseAnchorX;
182189
double mouseAnchorY;
183190

184191
double translateAnchorX;
185192
double translateAnchorY;
186-
187193
}
188194

189195
}

0 commit comments

Comments
 (0)