about summary refs log tree commit diff
path: root/src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2023-12-11 21:47:41 +0000
committerGitHub <noreply@github.com>2023-12-11 13:47:41 -0800
commitab04074197f8432a3d502ca2393beca3b8f6ca97 (patch)
tree6ee1a3af73b2afbc4a36300aab9561ebebbcffd6 /src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts
parent8929ff526fa7f81c23decaf05898f396e5fe0de9 (diff)
downloadvoidsky-ab04074197f8432a3d502ca2393beca3b8f6ca97.tar.zst
Fix scroll on native (#2170)
Diffstat (limited to 'src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts')
-rw-r--r--src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts81
1 files changed, 40 insertions, 41 deletions
diff --git a/src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts b/src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts
index b94f49e42..98e05a8ce 100644
--- a/src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts
+++ b/src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts
@@ -1,45 +1,44 @@
 import {useRef, useEffect} from 'react'
 import {useAnimatedScrollHandler as useAnimatedScrollHandler_BUGGY} from 'react-native-reanimated'
 
-export const useAnimatedScrollHandler_FIXED: typeof useAnimatedScrollHandler_BUGGY =
-  (config, deps) => {
-    const ref = useRef(config)
-    useEffect(() => {
-      ref.current = config
-    })
-    return useAnimatedScrollHandler_BUGGY(
-      {
-        onBeginDrag(e, ctx) {
-          if (typeof ref.current !== 'function' && ref.current.onBeginDrag) {
-            ref.current.onBeginDrag(e, ctx)
-          }
-        },
-        onEndDrag(e, ctx) {
-          if (typeof ref.current !== 'function' && ref.current.onEndDrag) {
-            ref.current.onEndDrag(e, ctx)
-          }
-        },
-        onMomentumBegin(e, ctx) {
-          if (
-            typeof ref.current !== 'function' &&
-            ref.current.onMomentumBegin
-          ) {
-            ref.current.onMomentumBegin(e, ctx)
-          }
-        },
-        onMomentumEnd(e, ctx) {
-          if (typeof ref.current !== 'function' && ref.current.onMomentumEnd) {
-            ref.current.onMomentumEnd(e, ctx)
-          }
-        },
-        onScroll(e, ctx) {
-          if (typeof ref.current === 'function') {
-            ref.current(e, ctx)
-          } else if (ref.current.onScroll) {
-            ref.current.onScroll(e, ctx)
-          }
-        },
+export const useAnimatedScrollHandler: typeof useAnimatedScrollHandler_BUGGY = (
+  config,
+  deps,
+) => {
+  const ref = useRef(config)
+  useEffect(() => {
+    ref.current = config
+  })
+  return useAnimatedScrollHandler_BUGGY(
+    {
+      onBeginDrag(e, ctx) {
+        if (typeof ref.current !== 'function' && ref.current.onBeginDrag) {
+          ref.current.onBeginDrag(e, ctx)
+        }
       },
-      deps,
-    )
-  }
+      onEndDrag(e, ctx) {
+        if (typeof ref.current !== 'function' && ref.current.onEndDrag) {
+          ref.current.onEndDrag(e, ctx)
+        }
+      },
+      onMomentumBegin(e, ctx) {
+        if (typeof ref.current !== 'function' && ref.current.onMomentumBegin) {
+          ref.current.onMomentumBegin(e, ctx)
+        }
+      },
+      onMomentumEnd(e, ctx) {
+        if (typeof ref.current !== 'function' && ref.current.onMomentumEnd) {
+          ref.current.onMomentumEnd(e, ctx)
+        }
+      },
+      onScroll(e, ctx) {
+        if (typeof ref.current === 'function') {
+          ref.current(e, ctx)
+        } else if (ref.current.onScroll) {
+          ref.current.onScroll(e, ctx)
+        }
+      },
+    },
+    deps,
+  )
+}