Fix animation clamping issues
This commit is contained in:
@@ -273,6 +273,9 @@ private class ChatItemAnimation
|
|||||||
private double duration = 0.0;
|
private double duration = 0.0;
|
||||||
private Gdk.FrameClock frame_clock = null;
|
private Gdk.FrameClock frame_clock = null;
|
||||||
|
|
||||||
|
delegate double EaseFunction(double t);
|
||||||
|
private EaseFunction ease_function = ease_out_quart;
|
||||||
|
|
||||||
public ChatItemAnimation(Gdk.FrameClock frame_clock) {
|
public ChatItemAnimation(Gdk.FrameClock frame_clock) {
|
||||||
this.frame_clock = frame_clock;
|
this.frame_clock = frame_clock;
|
||||||
progress = 0.0f;
|
progress = 0.0f;
|
||||||
@@ -285,7 +288,9 @@ private class ChatItemAnimation
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void tick_animation() {
|
public void tick_animation() {
|
||||||
progress = ease_out_quart((frame_clock.get_frame_time() - start_time) / (duration * 1000000.0));
|
double t = (frame_clock.get_frame_time() - start_time) / (duration * 1000000.0);
|
||||||
|
t = double.min(1.0, double.max(0.0, t));
|
||||||
|
progress = ease_function(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double ease_out_quart(double t) {
|
private static double ease_out_quart(double t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user