[gtk/wip/carlosg/fix-accumulated-velocity: 10/10] gtkkineticscrolling: Do not take distance based shortcuts




commit f7d9ede82dca41241902d86e5ee7d1997c02f4a2
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 15 22:42:13 2022 +0100

    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

 gtk/gtkkineticscrolling.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
---
diff --git a/gtk/gtkkineticscrolling.c b/gtk/gtkkineticscrolling.c
index 8c697d54cd..1f02fe7993 100644
--- a/gtk/gtkkineticscrolling.c
+++ b/gtk/gtkkineticscrolling.c
@@ -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);
           }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]