Browse Source

Only start animations if target component is visible.

pull/214/head
weisj 4 years ago
parent
commit
3754d8378e
  1. 5
      core/src/main/java/com/github/weisj/darklaf/graphics/Animator.java
  2. 4
      core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java
  3. 2
      core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonListener.java

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

@ -138,6 +138,11 @@ public abstract class Animator {
this.enabled = enabled;
}
public void resume(final int startFrame, final JComponent target) {
if (!target.isVisible() || !target.isShowing()) return;
resume(startFrame);
}
public void resume(final int startFrame) {
if (startFrame < 0) {
throw new IllegalArgumentException("Starting frame must be non negative.");

4
core/src/main/java/com/github/weisj/darklaf/ui/scrollpane/DarkScrollBarListener.java

@ -200,14 +200,14 @@ public class DarkScrollBarListener extends MouseAdapter implements AdjustmentLis
if (scrollbar != null && (scrollbar.getValueIsAdjusting() || overAnimatedComponent)) {
fadeOutAnimator.suspend();
int startFrame = (int) ((currentAlpha / maxAlpha) * fadeInAnimator.getTotalFrames());
fadeInAnimator.resume(startFrame);
fadeInAnimator.resume(startFrame, scrollbar);
} else {
fadeInAnimator.suspend();
int startFrame = 0;
if (currentAlpha < maxAlpha) {
startFrame = (int) ((1.0 - currentAlpha / maxAlpha) * (fadeOutAnimator.getTotalFrames()));
}
fadeOutAnimator.resume(startFrame);
fadeOutAnimator.resume(startFrame, scrollbar);
}
}

2
core/src/main/java/com/github/weisj/darklaf/ui/togglebutton/DarkToggleButtonListener.java

@ -85,7 +85,7 @@ public class DarkToggleButtonListener extends DarkButtonListener<DarkToggleButto
animator.suspend();
animator.setForward(sel);
animator.setEndValue(endState);
animator.resume(startFrame);
animator.resume(startFrame, button);
}
}

Loading…
Cancel
Save