about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2024-09-27 10:09:00 +0100
committerGitHub <noreply@github.com>2024-09-27 10:09:00 +0100
commit4553e6b64955c32225cefbe14117e4d08a0520ca (patch)
tree3290aa8f15e3d491dc801f7998c1f111e814c8b4
parentdd2fedb2e68af57cac56b9019050af04119c7ff0 (diff)
downloadvoidsky-4553e6b64955c32225cefbe14117e4d08a0520ca.tar.zst
Ignore bogus onScroll values (#5499)
-rw-r--r--src/view/com/pager/PagerWithHeader.tsx13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/view/com/pager/PagerWithHeader.tsx b/src/view/com/pager/PagerWithHeader.tsx
index 528f7fdf2..6d601c289 100644
--- a/src/view/com/pager/PagerWithHeader.tsx
+++ b/src/view/com/pager/PagerWithHeader.tsx
@@ -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(