Skip to content

Commit

Permalink
Make sure we scroll far enough with variable heights
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Jun 3, 2023
1 parent 615560e commit 09f8ea7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion widget/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (l *List) scrollTo(id ListItemID) {

separatorThickness := theme.Padding()
y := float32(0)
lastItemHeight := l.itemMin.Height
if l.itemHeights == nil || len(l.itemHeights) == 0 {
y = (float32(id) * l.itemMin.Height) + (float32(id) * separatorThickness)
} else {
Expand All @@ -131,13 +132,14 @@ func (l *List) scrollTo(id ListItemID) {
}

y += height + separatorThickness
lastItemHeight = height
}
}

if y < l.scroller.Offset.Y {
l.scroller.Offset.Y = y
} else if y+l.itemMin.Height > l.scroller.Offset.Y+l.scroller.Size().Height {
l.scroller.Offset.Y = y + l.itemMin.Height - l.scroller.Size().Height
l.scroller.Offset.Y = y + lastItemHeight - l.scroller.Size().Height
}
l.offsetUpdated(l.scroller.Offset)
}
Expand Down

0 comments on commit 09f8ea7

Please sign in to comment.