gtkkineticscrolling: Do not take distance based shortcuts
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 15 Mar 2022 21:42:13 +0000 (22:42 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Sat, 19 Mar 2022 11:35:11 +0000 (12:35 +0100)
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

gtk/gtkkineticscrolling.c

index 8c697d54cdaa824a10115f9cf3538077720cbaba..1f02fe79931ec10c9dc7ebbdd66836f99043fef3 100644 (file)
@@ -181,8 +181,6 @@ gtk_kinetic_scrolling_tick (GtkKineticScrolling *data,
     {
     case GTK_KINETIC_SCROLLING_PHASE_DECELERATING:
       {
-        double last_position = data->position;
-        double last_time = data->t;
         double exp_part;
 
         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);
           }
-        else if (fabs(data->velocity) < 1 ||
-                 (last_time != 0.0 && fabs(data->position - last_position) < 1))
+        else if (fabs(data->velocity) < 0.1)
           {
             gtk_kinetic_scrolling_stop (data);
           }