Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore bogus onScroll values #5499

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/view/com/pager/PagerWithHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,19 @@ 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 -
mozzius marked this conversation as resolved.
Show resolved Hide resolved
// in fact, I actually can't do it, so let's just ignore those.
// Let's only apply this hack if we've overscrolled by more than 300px
// so that it's not a false positive from overscrolling -sfn
const isPossiblyInvalid =
headerHeight > 0 && nextScrollY === -headerHeight
if (!isPossiblyInvalid) {
scrollY.value = nextScrollY
runOnJS(queueThrottledOnScroll)()
}
},
[scrollY, queueThrottledOnScroll],
[scrollY, queueThrottledOnScroll, headerHeight],
)

const onPageSelectedInner = React.useCallback(
Expand Down
Loading