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 8f3d3ed commit 5fb5c9a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ui/page/components/items_scroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (s *Scroll[T]) fetchScrollData(isScrollUp bool, window app.WindowNavigator)
tempSize := s.pageSize
//Scroll up and down without load more
if s.data != nil {
temStartIdx := s.data.idxStart
if isScrollUp {
if s.data.idxStart <= 0 {
s.mu.Unlock()
Expand All @@ -145,7 +146,7 @@ func (s *Scroll[T]) fetchScrollData(isScrollUp bool, window app.WindowNavigator)
}
s.data.idxEnd = s.data.idxEnd - int(s.pageSize)
s.itemsCount = len(s.data.items)
if s.data.idxStart > 0 {
if temStartIdx > 0 {
s.list.Position.Offset = s.list.Position.Length / len(s.data.items) * (int(s.pageSize) - 4)
}
s.mu.Unlock()
Expand All @@ -158,7 +159,7 @@ func (s *Scroll[T]) fetchScrollData(isScrollUp bool, window app.WindowNavigator)
s.data.idxStart = s.data.idxStart + int(s.pageSize)
s.data.idxEnd = s.data.idxEnd + int(s.pageSize)
s.itemsCount = len(s.data.items)
if s.data.idxStart > 0 {
if temStartIdx > 0 {
s.list.Position.Offset = s.list.Position.Length / len(s.data.items) * (int(s.pageSize) - 4)
}
s.mu.Unlock()
Expand Down

0 comments on commit 5fb5c9a

Please sign in to comment.