gtkkineticscrolling: Do not take distance based shortcuts

The pixel distance could be small enough between tick() calls that
this kind of checks might potentially become a problem. Rely only on
the calculated velocity to trigger the STOPPED phase, and use a lower
threshold to avoid cutting the animation too early.

Related: https://gitlab.gnome.org/GNOME/gtk/-/issues/4725
This commit is contained in:
Carlos Garnacho 2022-03-15 22:42:13 +01:00
parent 65839f67f8
commit f7d9ede82d

View File

@ -181,8 +181,6 @@ gtk_kinetic_scrolling_tick (GtkKineticScrolling *data,
{ {
case GTK_KINETIC_SCROLLING_PHASE_DECELERATING: case GTK_KINETIC_SCROLLING_PHASE_DECELERATING:
{ {
double last_position = data->position;
double last_time = data->t;
double exp_part; double exp_part;
data->t += time_delta; data->t += time_delta;
@ -199,8 +197,7 @@ gtk_kinetic_scrolling_tick (GtkKineticScrolling *data,
{ {
gtk_kinetic_scrolling_init_overshoot(data, data->upper, data->position, data->velocity); gtk_kinetic_scrolling_init_overshoot(data, data->upper, data->position, data->velocity);
} }
else if (fabs(data->velocity) < 1 || else if (fabs(data->velocity) < 0.1)
(last_time != 0.0 && fabs(data->position - last_position) < 1))
{ {
gtk_kinetic_scrolling_stop (data); gtk_kinetic_scrolling_stop (data);
} }