@swmansion/react-native-bottom-sheet 0.5.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/BottomSheetBase.js +10 -13
- package/lib/module/BottomSheetBase.js.map +1 -1
- package/lib/module/BottomSheetContext.js.map +1 -1
- package/lib/module/BottomSheetFlatList.js +3 -42
- package/lib/module/BottomSheetFlatList.js.map +1 -1
- package/lib/module/BottomSheetScrollView.js +3 -43
- package/lib/module/BottomSheetScrollView.js.map +1 -1
- package/lib/module/bottomSheetScrollable.js +35 -0
- package/lib/module/bottomSheetScrollable.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/useBottomSheetPanGesture.js +33 -23
- package/lib/module/useBottomSheetPanGesture.js.map +1 -1
- package/lib/module/useBottomSheetScrollable.js +14 -17
- package/lib/module/useBottomSheetScrollable.js.map +1 -1
- package/lib/typescript/src/BottomSheetBase.d.ts.map +1 -1
- package/lib/typescript/src/BottomSheetContext.d.ts +6 -4
- package/lib/typescript/src/BottomSheetContext.d.ts.map +1 -1
- package/lib/typescript/src/BottomSheetFlatList.d.ts +7 -12
- package/lib/typescript/src/BottomSheetFlatList.d.ts.map +1 -1
- package/lib/typescript/src/BottomSheetScrollView.d.ts +7 -14
- package/lib/typescript/src/BottomSheetScrollView.d.ts.map +1 -1
- package/lib/typescript/src/bottomSheetScrollable.d.ts +9 -0
- package/lib/typescript/src/bottomSheetScrollable.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/useBottomSheetPanGesture.d.ts +4 -6
- package/lib/typescript/src/useBottomSheetPanGesture.d.ts.map +1 -1
- package/lib/typescript/src/useBottomSheetScrollable.d.ts +1 -1
- package/lib/typescript/src/useBottomSheetScrollable.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/BottomSheetBase.tsx +16 -14
- package/src/BottomSheetContext.tsx +7 -4
- package/src/BottomSheetFlatList.tsx +16 -58
- package/src/BottomSheetScrollView.tsx +17 -61
- package/src/bottomSheetScrollable.tsx +42 -0
- package/src/index.tsx +3 -9
- package/src/useBottomSheetPanGesture.ts +44 -53
- package/src/useBottomSheetScrollable.ts +16 -23
|
@@ -5,7 +5,9 @@ import { isWorkletFunction, scheduleOnRN } from 'react-native-worklets';
|
|
|
5
5
|
import {
|
|
6
6
|
type SharedValue,
|
|
7
7
|
useAnimatedProps,
|
|
8
|
+
useAnimatedRef,
|
|
8
9
|
useAnimatedScrollHandler,
|
|
10
|
+
useSharedValue,
|
|
9
11
|
} from 'react-native-reanimated';
|
|
10
12
|
|
|
11
13
|
import { useBottomSheetContext } from './BottomSheetContext';
|
|
@@ -16,14 +18,11 @@ export const useBottomSheetScrollable = (
|
|
|
16
18
|
baseScrollEnabled: boolean | SharedValue<boolean | undefined> = true,
|
|
17
19
|
onScroll?: ScrollHandler
|
|
18
20
|
) => {
|
|
19
|
-
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
isScrollableLocked,
|
|
25
|
-
panGesture,
|
|
26
|
-
} = useBottomSheetContext();
|
|
21
|
+
const { isScrollableLocked, registerScrollable, panGesture } =
|
|
22
|
+
useBottomSheetContext();
|
|
23
|
+
const scrollableRef = useAnimatedRef();
|
|
24
|
+
const scrollOffset = useSharedValue(0);
|
|
25
|
+
const isGestureActive = useSharedValue(false);
|
|
27
26
|
const isWorkletScrollHandler =
|
|
28
27
|
onScroll !== undefined ? isWorkletFunction(onScroll) : false;
|
|
29
28
|
const scrollHandler = useAnimatedScrollHandler({
|
|
@@ -42,11 +41,11 @@ export const useBottomSheetScrollable = (
|
|
|
42
41
|
.simultaneousWithExternalGesture(panGesture)
|
|
43
42
|
.onStart(() => {
|
|
44
43
|
'worklet';
|
|
45
|
-
|
|
44
|
+
isGestureActive.set(true);
|
|
46
45
|
})
|
|
47
46
|
.onFinalize(() => {
|
|
48
47
|
'worklet';
|
|
49
|
-
|
|
48
|
+
isGestureActive.set(false);
|
|
50
49
|
});
|
|
51
50
|
const animatedProps = useAnimatedProps(() => {
|
|
52
51
|
const resolvedScrollEnabled =
|
|
@@ -58,18 +57,12 @@ export const useBottomSheetScrollable = (
|
|
|
58
57
|
};
|
|
59
58
|
});
|
|
60
59
|
useEffect(() => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return () => {
|
|
69
|
-
hasScrollable.set(false);
|
|
70
|
-
isScrollableGestureActive.set(false);
|
|
71
|
-
isScrollableLocked.set(false);
|
|
72
|
-
};
|
|
73
|
-
}, [hasScrollable, isScrollableGestureActive, isScrollableLocked]);
|
|
60
|
+
const unregister = registerScrollable({
|
|
61
|
+
ref: scrollableRef,
|
|
62
|
+
scrollOffset,
|
|
63
|
+
isGestureActive,
|
|
64
|
+
});
|
|
65
|
+
return unregister;
|
|
66
|
+
}, [registerScrollable, scrollableRef, scrollOffset, isGestureActive]);
|
|
74
67
|
return { scrollHandler, scrollableRef, nativeGesture, animatedProps };
|
|
75
68
|
};
|