Browse Source

Ensure #animationDOne is invoked if animation is stopped right away.

pull/222/head
weisj 4 years ago
parent
commit
a3f0ffa63e
  1. 15
      core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java

15
core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java

@ -138,8 +138,17 @@ public abstract class Animator {
this.enabled = enabled; this.enabled = enabled;
} }
private void stopAnimation() {
currentFrame = totalFrames - 1;
paint();
animationDone();
}
public void resume(final int startFrame, final JComponent target) { public void resume(final int startFrame, final JComponent target) {
if (!target.isVisible() || !target.isShowing()) return; if (!target.isVisible() || !target.isShowing()) {
stopAnimation();
return;
}
resume(startFrame); resume(startFrame);
} }
@ -148,9 +157,7 @@ public abstract class Animator {
throw new IllegalArgumentException("Starting frame must be non negative."); throw new IllegalArgumentException("Starting frame must be non negative.");
} }
if (cycleDuration == 0 || startFrame >= totalFrames || !animationsEnabled()) { if (cycleDuration == 0 || startFrame >= totalFrames || !animationsEnabled()) {
currentFrame = totalFrames - 1; stopAnimation();
paint();
animationDone();
} else if (ticker == null) { } else if (ticker == null) {
this.startFrame = startFrame; this.startFrame = startFrame;
ticker = scheduler.scheduleWithFixedDelay(new Runnable() { ticker = scheduler.scheduleWithFixedDelay(new Runnable() {

Loading…
Cancel
Save