diff --git a/src/main/java/com/sparrowwallet/sparrow/control/AnimationUtil.java b/src/main/java/com/sparrowwallet/sparrow/control/AnimationUtil.java new file mode 100644 index 00000000..c7ea2092 --- /dev/null +++ b/src/main/java/com/sparrowwallet/sparrow/control/AnimationUtil.java @@ -0,0 +1,20 @@ +package com.sparrowwallet.sparrow.control; + +import javafx.animation.KeyFrame; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + +public class AnimationUtil { + public static Timeline getSlowFadeOut(Node node, Duration duration, double fromValue, int numIncrements) { + Timeline fadeTimeline = new Timeline(); + Duration incrementDuration = duration.divide(numIncrements); + for(int i = 0; i < numIncrements; i++) { + double normalized = ((double)numIncrements - i - 1) / numIncrements; + double opacity = normalized * fromValue; + fadeTimeline.getKeyFrames().add(new KeyFrame(incrementDuration.multiply(i+1), event -> node.setOpacity(opacity))); + } + + return fadeTimeline; + } +} diff --git a/src/main/java/com/sparrowwallet/sparrow/control/ConfirmationProgressIndicator.java b/src/main/java/com/sparrowwallet/sparrow/control/ConfirmationProgressIndicator.java index f0d4647a..784ec9e7 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/ConfirmationProgressIndicator.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/ConfirmationProgressIndicator.java @@ -86,10 +86,10 @@ public class ConfirmationProgressIndicator extends StackPane { upTickLineTimeline.getKeyFrames().add(upTickLineFrame); sequence.getChildren().add(upTickLineTimeline); - FadeTransition groupFadeOut = new FadeTransition(Duration.minutes(10), confirmationGroup); - groupFadeOut.setFromValue(1); - groupFadeOut.setToValue(0); + Timeline groupFadeOut = AnimationUtil.getSlowFadeOut(confirmationGroup, Duration.minutes(10), 1.0, 10); sequence.getChildren().add(groupFadeOut); + + confirmationsProperty().unbind(); } sequence.play(); diff --git a/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java b/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java index 4d9cc8a1..b1ffe010 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/MixStatusCell.java @@ -10,7 +10,7 @@ import com.sparrowwallet.sparrow.wallet.Entry; import com.sparrowwallet.sparrow.wallet.UtxoEntry; import com.sparrowwallet.sparrow.whirlpool.Whirlpool; import com.sparrowwallet.sparrow.whirlpool.WhirlpoolException; -import javafx.animation.FadeTransition; +import javafx.animation.Timeline; import javafx.geometry.Pos; import javafx.scene.control.*; import javafx.util.Duration; @@ -84,13 +84,13 @@ public class MixStatusCell extends TreeTableCell { "\nTo prevent sleeping, use the " + getPlatformSleepConfig() + " or enable the function in the Tools menu."); setTooltip(tt); - FadeTransition ft = new FadeTransition(Duration.millis(ERROR_DISPLAY_MILLIS - elapsed), failGlyph); - ft.setFromValue(1.0 - ((double)elapsed / ERROR_DISPLAY_MILLIS)); - ft.setToValue(0.0); - ft.setOnFinished(event -> { + Duration fadeDuration = Duration.millis(ERROR_DISPLAY_MILLIS - elapsed); + double fadeFromValue = 1.0 - ((double)elapsed / ERROR_DISPLAY_MILLIS); + Timeline timeline = AnimationUtil.getSlowFadeOut(failGlyph, fadeDuration, fadeFromValue, 10); + timeline.setOnFinished(event -> { setTooltip(null); }); - ft.play(); + timeline.play(); } else { setGraphic(null); setTooltip(null);