Skip to content

Commit

Permalink
Ignore bogus onScroll values (#5499)
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzius authored Sep 27, 2024
1 parent dd2fedb commit 4553e6b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/view/com/pager/PagerWithHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,17 @@ export const PagerWithHeader = React.forwardRef<PagerRef, PagerWithHeaderProps>(
(e: NativeScrollEvent) => {
'worklet'
const nextScrollY = e.contentOffset.y
scrollY.value = nextScrollY
runOnJS(queueThrottledOnScroll)()
// HACK: onScroll is reporting some strange values on load (negative header height).
// Highly improbable that you'd be overscrolled by over 400px -
// in fact, I actually can't do it, so let's just ignore those. -sfn
const isPossiblyInvalid =
headerHeight > 0 && Math.round(nextScrollY * 2) / 2 === -headerHeight
if (!isPossiblyInvalid) {
scrollY.value = nextScrollY
runOnJS(queueThrottledOnScroll)()
}
},
[scrollY, queueThrottledOnScroll],
[scrollY, queueThrottledOnScroll, headerHeight],
)

const onPageSelectedInner = React.useCallback(
Expand Down

0 comments on commit 4553e6b

Please sign in to comment.