Skip to content

Commit 01b7a6b

Browse files
authored
Revert "修复 TransitionPane 动画被打断时节点状态异常的问题" (#4986)
Reverts #4957
1 parent a0593c0 commit 01b7a6b

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

HMCL/src/main/java/org/jackhuang/hmcl/ui/animation/TransitionPane.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
public class TransitionPane extends StackPane {
3232

3333
private Node currentNode;
34-
private Animation oldAnimation;
3534

3635
public TransitionPane() {
3736
FXUtils.setOverflowHidden(this);
@@ -51,11 +50,6 @@ public final void setContent(Node newView, AnimationProducer transition, Duratio
5150

5251
public void setContent(Node newView, AnimationProducer transition,
5352
Duration duration, Interpolator interpolator) {
54-
if (oldAnimation != null) {
55-
oldAnimation.stop();
56-
oldAnimation = null;
57-
}
58-
5953
Node previousNode = currentNode != newView && getWidth() > 0 && getHeight() > 0 ? currentNode : null;
6054
currentNode = newView;
6155

@@ -86,19 +80,15 @@ public void setContent(Node newView, AnimationProducer transition,
8680
previousNode,
8781
newView,
8882
duration, interpolator);
89-
newAnimation.statusProperty().addListener((observable, oldValue, newValue) -> {
90-
if (oldValue == Animation.Status.RUNNING && newValue != Animation.Status.RUNNING) {
91-
setMouseTransparent(false);
92-
getChildren().remove(previousNode);
93-
94-
if (cacheHint != null) {
95-
newView.setCache(false);
96-
}
83+
newAnimation.setOnFinished(e -> {
84+
setMouseTransparent(false);
85+
getChildren().remove(previousNode);
86+
87+
if (cacheHint != null) {
88+
newView.setCache(false);
9789
}
9890
});
99-
100-
oldAnimation = newAnimation;
101-
newAnimation.play();
91+
FXUtils.playAnimation(this, "transition_pane", newAnimation);
10292
});
10393

10494
}

0 commit comments

Comments
 (0)