Skip to content

Commit

Permalink
add OnScroll event to list
Browse files Browse the repository at this point in the history
  • Loading branch information
csturiale committed Dec 17, 2024
1 parent d2fde27 commit 8050e24
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions widget/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type List struct {
UpdateItem func(id ListItemID, item fyne.CanvasObject) `json:"-"`
OnSelected func(id ListItemID) `json:"-"`
OnUnselected func(id ListItemID) `json:"-"`
OnScroll func(id ListItemID) `json:"-"`

// HideSeparators hides the separators between list rows
//
Expand Down Expand Up @@ -186,6 +187,11 @@ func (l *List) scrollTo(id ListItemID) {
l.scroller.Offset.Y = y + lastItemHeight - l.scroller.Size().Height
}
l.offsetUpdated(l.scroller.Offset)
defer func() {
if f := l.OnScroll; f != nil {
f(id)
}
}()
}

// Resize is called when this list should change size. We refresh to ensure invisible items are drawn.
Expand Down

0 comments on commit 8050e24

Please sign in to comment.