[libadwaita/wip/exalm/fixes: 1/2] spring-animation: Fix clamp for in-place animations
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/fixes: 1/2] spring-animation: Fix clamp for in-place animations
- Date: Mon, 6 Dec 2021 19:32:54 +0000 (UTC)
commit adbc0d172a2417a5fb6efcf53b7571554e6f783b
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Dec 7 00:25:32 2021 +0500
spring-animation: Fix clamp for in-place animations
We initially went with clamping the side opposite the initial velocity.
Unfortunately, that doesn't really make sense when the user needs to just
prevent overshooting and doesn't specifically differentiate between regular
and in-place animations. So instead skip it altogether in this case.
Fix a logic error with incrementing as well.
src/adw-spring-animation.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/adw-spring-animation.c b/src/adw-spring-animation.c
index 7371164e..b9e48070 100644
--- a/src/adw-spring-animation.c
+++ b/src/adw-spring-animation.c
@@ -155,16 +155,13 @@ get_first_zero (AdwSpringAnimation *self)
* for in-place animations. */
guint i = 1;
double y = oscillate (self, i, NULL);
- gboolean in_place = G_APPROX_VALUE (self->value_to, self->value_from, FLT_EPSILON);
while ((self->value_to - self->value_from > FLT_EPSILON && self->value_to - y > self->epsilon) ||
- (self->value_from - self->value_to > FLT_EPSILON && y - self->value_to > self->epsilon) ||
- (in_place && (self->initial_velocity < 0.0) && (self->value_to - y > self->epsilon)) ||
- (in_place && (self->initial_velocity > 0.0) && (y -self->value_to > self->epsilon))) {
+ (self->value_from - self->value_to > FLT_EPSILON && y - self->value_to > self->epsilon)) {
if (i > MAX_ITERATIONS)
return 0;
- y = oscillate (self, i++, NULL);
+ y = oscillate (self, ++i, NULL);
}
return i;
@@ -188,8 +185,12 @@ calculate_duration (AdwSpringAnimation *self)
if (beta <= 0)
return ADW_DURATION_INFINITE;
- if (self->clamp)
+ if (self->clamp) {
+ if (G_APPROX_VALUE (self->value_to, self->value_from, FLT_EPSILON))
+ return 0;
+
return get_first_zero (self);
+ }
omega0 = sqrt (stiffness / mass);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]