Ignore bogus onScroll values (#5499)
This commit is contained in:
@@ -161,10 +161,17 @@ export const PagerWithHeader = React.forwardRef<PagerRef, PagerWithHeaderProps>(
|
|||||||
(e: NativeScrollEvent) => {
|
(e: NativeScrollEvent) => {
|
||||||
'worklet'
|
'worklet'
|
||||||
const nextScrollY = e.contentOffset.y
|
const nextScrollY = e.contentOffset.y
|
||||||
scrollY.value = nextScrollY
|
// HACK: onScroll is reporting some strange values on load (negative header height).
|
||||||
runOnJS(queueThrottledOnScroll)()
|
// 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(
|
const onPageSelectedInner = React.useCallback(
|
||||||
|
|||||||
Reference in New Issue
Block a user