Animation stagger delay
This commit is contained in:
@@ -42,7 +42,7 @@ public class Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void playAnimationFrame(long elapsed) {
|
public void playAnimationFrame(long elapsed) {
|
||||||
if (this.animation != null) {
|
if (this.animation != null && elapsed >= this.animation.delay) {
|
||||||
this.animation.tick(this.curve.apply(Math.min(1.0, (double) elapsed / this.animation.duration)), this);
|
this.animation.tick(this.curve.apply(Math.min(1.0, (double) elapsed / this.animation.duration)), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import org.saturnclient.ui2.Element;
|
|||||||
|
|
||||||
public abstract class Animation {
|
public abstract class Animation {
|
||||||
public int duration;
|
public int duration;
|
||||||
|
public int delay = 0;
|
||||||
|
|
||||||
Animation(int duration) {
|
Animation(int duration) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ import org.saturnclient.ui2.components.ElementRenderer;
|
|||||||
|
|
||||||
public class AnimationStagger extends Element {
|
public class AnimationStagger extends Element {
|
||||||
protected List<Element> children = new ArrayList<>();
|
protected List<Element> children = new ArrayList<>();
|
||||||
public int duration;
|
public int delay;
|
||||||
|
|
||||||
public AnimationStagger(int duration) {
|
public AnimationStagger(int delay) {
|
||||||
this.duration = duration;
|
this.delay = delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -30,7 +30,7 @@ public class AnimationStagger extends Element {
|
|||||||
|
|
||||||
public void draw(Element element) {
|
public void draw(Element element) {
|
||||||
if (element.animation != null) {
|
if (element.animation != null) {
|
||||||
element.animation.duration = duration * (children.size() + 1);
|
element.animation.delay = delay * (children.size() + 1);
|
||||||
}
|
}
|
||||||
children.add(element);
|
children.add(element);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user