Browse Source

Keep the scrolling state closer to where it's actually used

rexim 8 months ago
parent
commit
d0a2acbbcf
1 changed files with 5 additions and 5 deletions
  1. 5 5
      src/plug.c

+ 5 - 5
src/plug.c

@@ -723,11 +723,6 @@ static void tracks_panel_with_location(const char *file, int line, Rectangle pan
 
     Vector2 mouse = GetMousePosition();
 
-    static float dt = 0;
-    static uint64_t hovered_label_id = 0;
-    static int px_shift = 0;
-    static bool scroll_left = true;
-
     float scroll_bar_width = panel_boundary.width*0.03;
     float item_size = panel_boundary.width*0.2;
     float visible_area_size = panel_boundary.height;
@@ -806,6 +801,11 @@ static void tracks_panel_with_location(const char *file, int line, Rectangle pan
             BeginScissorMode(position.x, position.y, max_width, item_boundary.height);
 
             if (state & BS_HOVEROVER) { // <-- Current item is being hovered on and needs scrolling
+                static float dt = 0;
+                static uint64_t hovered_label_id = 0;
+                static int px_shift = 0;
+                static bool scroll_left = true;
+
                 dt += GetFrameTime();
                 if (item_id != hovered_label_id) { // <-- But it is not same as the last hovered item, so reset the shift
                     px_shift = 0;