From 0e60935856888c8cf377637307da7d84b19d31d4 Mon Sep 17 00:00:00 2001 From: Chris Waldon Date: Wed, 7 Jul 2021 09:46:10 -0400 Subject: [PATCH] widget/material: ensure scrollbars can be dragged from list end The scrollbar implementation prior to this change only adjusted list.Position.Offset. This works in all circumstances except when list.Position.BeforeEnd=false. If the position indicates that the scroll position is at the end of the list, the offset is ignored. This change ensures that manually dragging the scrollbar always causes BeforeEnd to be set to true. If the drag ends with the scrollbar at the end of the list, BeforeEnd will be set automatically by the next list.Layout call, so this doesn't prevent the list from optimizing for that case in general. Signed-off-by: Chris Waldon --- widget/material/list.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/widget/material/list.go b/widget/material/list.go index 71bfaabc..b30515af 100644 --- a/widget/material/list.go +++ b/widget/material/list.go @@ -279,6 +279,11 @@ func (l ListStyle) Layout(gtx layout.Context, length int, w layout.ListElement) // with the scrollbar. deltaPx := int(math.Round(float64(float32(l.state.Position.Length) * delta))) l.state.List.Position.Offset += deltaPx + + // Ensure that the list pays attention to the Offset field when the scrollbar drag + // is started while the bar is at the end of the list. Without this, the scrollbar + // cannot be dragged away from the end. + l.state.List.Position.BeforeEnd = true } return listDims