mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
widget: consider size of indicator when limiting scrollbar dragging
Signed-off-by: Dominik Honnef <dominik@honnef.co>
This commit is contained in:
committed by
Elias Naur
parent
aea376fbaf
commit
f229601e2d
@@ -89,6 +89,18 @@ func (s *Scrollbar) Layout(gtx layout.Context, axis layout.Axis, viewportStart,
|
|||||||
s.oldDragPos = normalizedDragOffset
|
s.oldDragPos = normalizedDragOffset
|
||||||
}
|
}
|
||||||
s.delta += normalizedDragOffset - s.oldDragPos
|
s.delta += normalizedDragOffset - s.oldDragPos
|
||||||
|
|
||||||
|
if viewportStart+s.delta < 0 {
|
||||||
|
// Adjust normalizedDragOffset - and thus the future s.oldDragPos - so that futile dragging up has to be
|
||||||
|
// countered with dragging down again. Otherwise, dragging up would have no effect, but dragging down would
|
||||||
|
// immediately start scrolling. We want the user to undo their ineffective drag first.
|
||||||
|
normalizedDragOffset -= viewportStart + s.delta
|
||||||
|
// Limit s.delta to the maximum amount scrollable
|
||||||
|
s.delta = -viewportStart
|
||||||
|
} else if viewportEnd+s.delta > 1 {
|
||||||
|
normalizedDragOffset += (1 - viewportEnd) - s.delta
|
||||||
|
s.delta = 1 - viewportEnd
|
||||||
|
}
|
||||||
s.oldDragPos = normalizedDragOffset
|
s.oldDragPos = normalizedDragOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user