Skip to content

Commit

Permalink
update scroll condition
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeBoy committed Apr 16, 2024
1 parent 5fb5c9a commit 254bb23
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ui/page/components/items_scroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ func (s *Scroll[T]) FetchScrollData(isScrollUp bool, window app.WindowNavigator,
// s.data is not nil when moving from details page to list page.
if s.data != nil {
s.isLoadingItems = false
// offset will be added back so that the earlier page is recreated.
// s.offset -= s.pageSize
}

if isResetList {
Expand All @@ -105,8 +103,9 @@ func (s *Scroll[T]) FetchScrollData(isScrollUp bool, window app.WindowNavigator,
s.cacheData = nil
}
s.mu.Unlock()

s.fetchScrollData(isScrollUp, window)
if s.data == nil {
s.fetchScrollData(isScrollUp, window)
}
}

// fetchScrollData fetchs the scroll data and manages data returned depending on
Expand Down Expand Up @@ -210,7 +209,9 @@ func (s *Scroll[T]) fetchScrollData(isScrollUp bool, window app.WindowNavigator)
s.data.idxEnd += itemCount
s.offset += int32(itemCount)
s.itemsCount = len(s.data.items)
s.list.Position.Offset = s.list.Position.Length / len(s.data.items) * (int(s.pageSize) - 4)
if s.data.idxStart > 0 {
s.list.Position.Offset = s.list.Position.Length / len(s.data.items) * (int(s.pageSize) - 4)
}
if itemCount < int(s.pageSize) {
s.loadedAllItems = true
}
Expand Down

0 comments on commit 254bb23

Please sign in to comment.