防止执行平移动画时组件溢出面板

This commit is contained in:
yushijinhun 2018-06-02 20:09:36 +08:00
parent 3408a8ffcf
commit efe22ca613
No known key found for this signature in database
GPG Key ID: 5BC167F73EA558E4

View File

@ -22,6 +22,7 @@ import javafx.animation.Timeline;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;
public final class TransitionHandler implements AnimationHandler {
@ -36,6 +37,12 @@ public final class TransitionHandler implements AnimationHandler {
public TransitionHandler(StackPane view) {
this.view = view;
currentNode = view.getChildren().stream().findFirst().orElse(null);
// prevent content overflow
Rectangle clip = new Rectangle();
clip.widthProperty().bind(view.widthProperty());
clip.heightProperty().bind(view.heightProperty());
view.setClip(clip);
}
@Override