From 0dc6043dc72a68e16ef30de9edbd55b97392e58a 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 05df0afa..c7590b8c 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