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

Loading…
Cancel
Save