From da09aabbe81d2e08d707db925d35c057ea42dad9 Mon Sep 17 00:00:00 2001 From: Chris Waldon Date: Thu, 9 Sep 2021 15:07:56 -0400 Subject: [PATCH] widget/material: clamp fromListPosition end coordinate Previously, it was possible for fromListPosition to return an end coordinate greater than 1, which would make scroll indicators using those coordinates render beyond the boundaries of their scroll tracks. One could argue that this is a bug in the scroll indicator, but I don't think this method should return data outside of its documented range. Signed-off-by: Chris Waldon --- widget/material/list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/material/list.go b/widget/material/list.go index 220671e4..82f27a7f 100644 --- a/widget/material/list.go +++ b/widget/material/list.go @@ -35,7 +35,7 @@ func fromListPosition(lp layout.Position, elements int, majorAxisSize int) (star // Compute the location of the beginning of the viewport. viewportStart := (float32(lp.First)*meanElementHeight + listOffsetF) / lengthPx - return viewportStart, viewportStart + visibleFraction + return viewportStart, clamp1(viewportStart + visibleFraction) } // rangeIsScrollable returns whether the viewport described by start and end