From 397b61e7c6cc185567bd816e453b3c88d1b843c7 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Wed, 23 Aug 2023 19:07:52 +0200 Subject: [PATCH] Fix returned `percent` when clicking the `Scrollbar` `track` --- data/core/scrollbar.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/core/scrollbar.lua b/data/core/scrollbar.lua index d2bb0562..5e64b19f 100644 --- a/data/core/scrollbar.lua +++ b/data/core/scrollbar.lua @@ -189,8 +189,9 @@ function Scrollbar:_on_mouse_pressed_normal(button, x, y, clicks) self.drag_start_offset = along - y return true elseif overlaps == "track" then + local nr = self.normal_rect self.drag_start_offset = - along_size / 2 - return (y - self.normal_rect.along - along_size / 2) / self.normal_rect.along_size + return common.clamp((y - nr.along - along_size / 2) / (nr.along_size - along_size), 0, 1) end end end