Skip to content

Commit

Permalink
Improve scrolling performance for List
Browse files Browse the repository at this point in the history
  • Loading branch information
zetavg committed May 19, 2024
1 parent 3ca671d commit d8b2721
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/view/com/util/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,22 @@ function ListImpl<ItemT>(
onScrolledDownChange?.(didScrollDown)
}

const {
onBeginDrag: onBeginDragFromContext,
onEndDrag: onEndDragFromContext,
onScroll: onScrollFromContext,
onMomentumEnd: onMomentumEndFromContext,
} = contextScrollHandlers

const scrollHandler = useAnimatedScrollHandler({
onBeginDrag(e, ctx) {
contextScrollHandlers.onBeginDrag?.(e, ctx)
onBeginDragFromContext?.(e, ctx)
},
onEndDrag(e, ctx) {
contextScrollHandlers.onEndDrag?.(e, ctx)
onEndDragFromContext?.(e, ctx)
},
onScroll(e, ctx) {
contextScrollHandlers.onScroll?.(e, ctx)
onScrollFromContext?.(e, ctx)

const didScrollDown = e.contentOffset.y > SCROLLED_DOWN_LIMIT
if (isScrolledDown.value !== didScrollDown) {
Expand All @@ -72,7 +79,7 @@ function ListImpl<ItemT>(
// Note: adding onMomentumBegin here makes simulator scroll
// lag on Android. So either don't add it, or figure out why.
onMomentumEnd(e, ctx) {
contextScrollHandlers.onMomentumEnd?.(e, ctx)
onMomentumEndFromContext?.(e, ctx)
},
})

Expand Down

0 comments on commit d8b2721

Please sign in to comment.