mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-05 05:46:44 +00:00
improve long fade out animation efficiency
This commit is contained in:
parent
97f312cb93
commit
a22f69e2c1
3 changed files with 29 additions and 9 deletions
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -86,10 +86,10 @@ public class ConfirmationProgressIndicator extends StackPane {
|
||||||
upTickLineTimeline.getKeyFrames().add(upTickLineFrame);
|
upTickLineTimeline.getKeyFrames().add(upTickLineFrame);
|
||||||
sequence.getChildren().add(upTickLineTimeline);
|
sequence.getChildren().add(upTickLineTimeline);
|
||||||
|
|
||||||
FadeTransition groupFadeOut = new FadeTransition(Duration.minutes(10), confirmationGroup);
|
Timeline groupFadeOut = AnimationUtil.getSlowFadeOut(confirmationGroup, Duration.minutes(10), 1.0, 10);
|
||||||
groupFadeOut.setFromValue(1);
|
|
||||||
groupFadeOut.setToValue(0);
|
|
||||||
sequence.getChildren().add(groupFadeOut);
|
sequence.getChildren().add(groupFadeOut);
|
||||||
|
|
||||||
|
confirmationsProperty().unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
sequence.play();
|
sequence.play();
|
||||||
|
|
|
@ -10,7 +10,7 @@ import com.sparrowwallet.sparrow.wallet.Entry;
|
||||||
import com.sparrowwallet.sparrow.wallet.UtxoEntry;
|
import com.sparrowwallet.sparrow.wallet.UtxoEntry;
|
||||||
import com.sparrowwallet.sparrow.whirlpool.Whirlpool;
|
import com.sparrowwallet.sparrow.whirlpool.Whirlpool;
|
||||||
import com.sparrowwallet.sparrow.whirlpool.WhirlpoolException;
|
import com.sparrowwallet.sparrow.whirlpool.WhirlpoolException;
|
||||||
import javafx.animation.FadeTransition;
|
import javafx.animation.Timeline;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
|
@ -84,13 +84,13 @@ public class MixStatusCell extends TreeTableCell<Entry, UtxoEntry.MixStatus> {
|
||||||
"\nTo prevent sleeping, use the " + getPlatformSleepConfig() + " or enable the function in the Tools menu.");
|
"\nTo prevent sleeping, use the " + getPlatformSleepConfig() + " or enable the function in the Tools menu.");
|
||||||
setTooltip(tt);
|
setTooltip(tt);
|
||||||
|
|
||||||
FadeTransition ft = new FadeTransition(Duration.millis(ERROR_DISPLAY_MILLIS - elapsed), failGlyph);
|
Duration fadeDuration = Duration.millis(ERROR_DISPLAY_MILLIS - elapsed);
|
||||||
ft.setFromValue(1.0 - ((double)elapsed / ERROR_DISPLAY_MILLIS));
|
double fadeFromValue = 1.0 - ((double)elapsed / ERROR_DISPLAY_MILLIS);
|
||||||
ft.setToValue(0.0);
|
Timeline timeline = AnimationUtil.getSlowFadeOut(failGlyph, fadeDuration, fadeFromValue, 10);
|
||||||
ft.setOnFinished(event -> {
|
timeline.setOnFinished(event -> {
|
||||||
setTooltip(null);
|
setTooltip(null);
|
||||||
});
|
});
|
||||||
ft.play();
|
timeline.play();
|
||||||
} else {
|
} else {
|
||||||
setGraphic(null);
|
setGraphic(null);
|
||||||
setTooltip(null);
|
setTooltip(null);
|
||||||
|
|
Loading…
Reference in a new issue