mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
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 <christopher.waldon.dev@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user