diff options
author | dan <dan.abramov@gmail.com> | 2023-12-11 21:24:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-11 13:24:31 -0800 |
commit | 8929ff526fa7f81c23decaf05898f396e5fe0de9 (patch) | |
tree | e58c2e0722002d49f631f3676a87d41e7805d523 /src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts | |
parent | b82c5177b9987efe92a642e9619dde604dda3da0 (diff) | |
download | voidsky-8929ff526fa7f81c23decaf05898f396e5fe0de9.tar.zst |
Fix scroll on profile lists/feeds (#2168)
Diffstat (limited to 'src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts')
-rw-r--r-- | src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts b/src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts index 98e05a8ce..b94f49e42 100644 --- a/src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts +++ b/src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts @@ -1,44 +1,45 @@ import {useRef, useEffect} from 'react' import {useAnimatedScrollHandler as useAnimatedScrollHandler_BUGGY} from 'react-native-reanimated' -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) - } +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) + } + }, }, - 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, - ) -} + deps, + ) + } |