-15
src/lib/hooks/useAnimatedScrollHandler_FIXED.ts
-15
src/lib/hooks/useAnimatedScrollHandler_FIXED.ts
···
1
-
// Be warned. This Hook is very buggy unless used in a very constrained way.
2
-
// To use it safely:
3
-
//
4
-
// - DO NOT pass its return value as a prop to any user-defined component.
5
-
// - DO NOT pass its return value to more than a single component.
6
-
//
7
-
// In other words, the only safe way to use it is next to the leaf Reanimated View.
8
-
//
9
-
// Relevant bug reports:
10
-
// - https://github.com/software-mansion/react-native-reanimated/issues/5345
11
-
// - https://github.com/software-mansion/react-native-reanimated/issues/5360
12
-
// - https://github.com/software-mansion/react-native-reanimated/issues/5364
13
-
//
14
-
// It's great when it works though.
15
-
export {useAnimatedScrollHandler} from 'react-native-reanimated'
-44
src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts
-44
src/lib/hooks/useAnimatedScrollHandler_FIXED.web.ts
···
1
-
import {useEffect, useRef} from 'react'
2
-
import {useAnimatedScrollHandler as useAnimatedScrollHandler_BUGGY} from 'react-native-reanimated'
3
-
4
-
export const useAnimatedScrollHandler: typeof useAnimatedScrollHandler_BUGGY = (
5
-
config,
6
-
deps,
7
-
) => {
8
-
const ref = useRef(config)
9
-
useEffect(() => {
10
-
ref.current = config
11
-
})
12
-
return useAnimatedScrollHandler_BUGGY(
13
-
{
14
-
onBeginDrag(e, ctx) {
15
-
if (typeof ref.current !== 'function' && ref.current.onBeginDrag) {
16
-
ref.current.onBeginDrag(e, ctx)
17
-
}
18
-
},
19
-
onEndDrag(e, ctx) {
20
-
if (typeof ref.current !== 'function' && ref.current.onEndDrag) {
21
-
ref.current.onEndDrag(e, ctx)
22
-
}
23
-
},
24
-
onMomentumBegin(e, ctx) {
25
-
if (typeof ref.current !== 'function' && ref.current.onMomentumBegin) {
26
-
ref.current.onMomentumBegin(e, ctx)
27
-
}
28
-
},
29
-
onMomentumEnd(e, ctx) {
30
-
if (typeof ref.current !== 'function' && ref.current.onMomentumEnd) {
31
-
ref.current.onMomentumEnd(e, ctx)
32
-
}
33
-
},
34
-
onScroll(e, ctx) {
35
-
if (typeof ref.current === 'function') {
36
-
ref.current(e, ctx)
37
-
} else if (ref.current.onScroll) {
38
-
ref.current.onScroll(e, ctx)
39
-
}
40
-
},
41
-
},
42
-
deps,
43
-
)
44
-
}
+1
-1
src/view/com/composer/Composer.tsx
+1
-1
src/view/com/composer/Composer.tsx
···
32
32
runOnUI,
33
33
scrollTo,
34
34
useAnimatedRef,
35
+
useAnimatedScrollHandler,
35
36
useAnimatedStyle,
36
37
useDerivedValue,
37
38
useSharedValue,
···
65
66
SUPPORTED_MIME_TYPES,
66
67
type SupportedMimeTypes,
67
68
} from '#/lib/constants'
68
-
import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED'
69
69
import {useAppState} from '#/lib/hooks/useAppState'
70
70
import {useIsKeyboardVisible} from '#/lib/hooks/useIsKeyboardVisible'
71
71
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
+1
-1
src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx
+1
-1
src/view/com/lightbox/ImageViewing/components/ImageItem/ImageItem.ios.tsx
···
19
19
useAnimatedProps,
20
20
useAnimatedReaction,
21
21
useAnimatedRef,
22
+
useAnimatedScrollHandler,
22
23
useAnimatedStyle,
23
24
useSharedValue,
24
25
} from 'react-native-reanimated'
25
26
import {useSafeAreaFrame} from 'react-native-safe-area-context'
26
27
import {Image} from 'expo-image'
27
28
28
-
import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED'
29
29
import {
30
30
type Dimensions as ImageDimensions,
31
31
type ImageSource,
+1
-1
src/view/com/util/List.tsx
+1
-1
src/view/com/util/List.tsx
···
3
3
import {
4
4
type FlatListPropsWithLayout,
5
5
runOnJS,
6
+
useAnimatedScrollHandler,
6
7
useSharedValue,
7
8
} from 'react-native-reanimated'
8
9
import {updateActiveVideoViewAsync} from '@haileyok/bluesky-video'
9
10
10
-
import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED'
11
11
import {useDedupe} from '#/lib/hooks/useDedupe'
12
12
import {useScrollHandlers} from '#/lib/ScrollContext'
13
13
import {addStyle} from '#/lib/styles'