From a699fb89ac2a45da138d903a2badeb12b95dd04b Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 30 Mar 2022 20:12:33 +0200 Subject: [PATCH] layout: default List scroll bounds to infinity Before, List would only report the remaining scrollable area of the visible children when positioned close to either end. Now, List always report infinite scroll bounds *unless* it is positioned at an extremum. Signed-off-by: Elias Naur --- layout/list.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/layout/list.go b/layout/list.go index aa78f1b5..8e451648 100644 --- a/layout/list.go +++ b/layout/list.go @@ -302,17 +302,19 @@ func (l *List) layout(ops *op.Ops, macro op.MacroOp) Dimensions { call := macro.Stop() defer clip.Rect(image.Rectangle{Max: dims}).Push(ops).Pop() - var min, max int - if o := l.Position.Offset; o > 0 { + min, max := int(-inf), int(inf) + if l.Position.First == 0 { // Use the size of the invisible part as scroll boundary. - min = -o - } else if l.Position.First > 0 { - min = -inf + min = -l.Position.Offset + if min > 0 { + min = 0 + } } - if o := l.Position.OffsetLast; o < 0 { - max = -o - } else if l.Position.First+l.Position.Count < l.len { - max = inf + if l.Position.First+l.Position.Count == l.len { + max = -l.Position.OffsetLast + if max < 0 { + max = 0 + } } scrollRange := image.Rectangle{ Min: l.Axis.Convert(image.Pt(min, 0)),