mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-08 10:55:35 +00:00
widget: clicking on the scrollbar indicator shouldn't jump
Signed-off-by: Dominik Honnef <dominik@honnef.co>
This commit is contained in:
committed by
Elias Naur
parent
8f990a6fdc
commit
aea376fbaf
@@ -58,8 +58,12 @@ func (s *Scrollbar) Layout(gtx layout.Context, axis layout.Axis, viewportStart,
|
||||
Y: int(event.Position.Y),
|
||||
})
|
||||
normalizedPos := float32(pos.X) / trackHeight
|
||||
// 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.
|
||||
for _, event := range s.drag.Events(gtx.Metric, gtx, gesture.Axis(axis)) {
|
||||
|
||||
Reference in New Issue
Block a user