From aea376fbafe9cc87ed67c2461379e36a9c372c67 Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Thu, 30 Jun 2022 01:21:03 +0200 Subject: [PATCH] widget: clicking on the scrollbar indicator shouldn't jump Signed-off-by: Dominik Honnef --- widget/list.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/widget/list.go b/widget/list.go index abf857f7..bd471782 100644 --- a/widget/list.go +++ b/widget/list.go @@ -58,7 +58,11 @@ func (s *Scrollbar) Layout(gtx layout.Context, axis layout.Axis, viewportStart, Y: int(event.Position.Y), }) normalizedPos := float32(pos.X) / trackHeight - s.delta += normalizedPos - viewportStart + // Clicking on the indicator should not jump to that position on the track. The user might've just intended to + // drag and changed their mind. + if !(normalizedPos >= viewportStart && normalizedPos <= viewportEnd) { + s.delta += normalizedPos - viewportStart + } } // Offset to account for any drags.