react-native-bottom-sheet-stack 1.5.3 → 1.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/commonjs/BottomSheetBackdrop.js.map +1 -1
- package/lib/commonjs/BottomSheetHost.js +103 -140
- package/lib/commonjs/BottomSheetHost.js.map +1 -1
- package/lib/commonjs/BottomSheetManaged.js +8 -9
- package/lib/commonjs/BottomSheetManaged.js.map +1 -1
- package/lib/commonjs/BottomSheetPortal.js +2 -10
- package/lib/commonjs/BottomSheetPortal.js.map +1 -1
- package/lib/commonjs/BottomSheetScaleView.js +13 -28
- package/lib/commonjs/BottomSheetScaleView.js.map +1 -1
- package/lib/commonjs/useBottomSheetContext.js +18 -11
- package/lib/commonjs/useBottomSheetContext.js.map +1 -1
- package/lib/commonjs/useBottomSheetControl.js.map +1 -1
- package/lib/commonjs/useScaleAnimation.js +25 -12
- package/lib/commonjs/useScaleAnimation.js.map +1 -1
- package/lib/typescript/src/BottomSheetBackdrop.d.ts.map +1 -1
- package/lib/typescript/src/BottomSheetHost.d.ts.map +1 -1
- package/lib/typescript/src/BottomSheetManaged.d.ts.map +1 -1
- package/lib/typescript/src/BottomSheetPortal.d.ts.map +1 -1
- package/lib/typescript/src/BottomSheetScaleView.d.ts.map +1 -1
- package/lib/typescript/src/useBottomSheetContext.d.ts +1 -2
- package/lib/typescript/src/useBottomSheetContext.d.ts.map +1 -1
- package/lib/typescript/src/useBottomSheetControl.d.ts.map +1 -1
- package/lib/typescript/src/useScaleAnimation.d.ts +2 -3
- package/lib/typescript/src/useScaleAnimation.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/BottomSheetBackdrop.tsx +0 -3
- package/src/BottomSheetHost.tsx +17 -31
- package/src/BottomSheetManaged.tsx +3 -9
- package/src/BottomSheetPortal.tsx +4 -6
- package/src/BottomSheetScaleView.tsx +2 -7
- package/src/useBottomSheetContext.ts +13 -11
- package/src/useBottomSheetControl.ts +0 -1
- package/src/useScaleAnimation.ts +4 -10
package/src/useScaleAnimation.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
useBottomSheetStore,
|
|
9
9
|
type BottomSheetStore,
|
|
10
10
|
} from './bottomSheet.store';
|
|
11
|
+
import { useBottomSheetManagerContext } from './BottomSheetManager.provider';
|
|
11
12
|
|
|
12
13
|
export interface ScaleConfig {
|
|
13
14
|
/** Scale factor when sheet is open (default: 0.92) */
|
|
@@ -39,12 +40,9 @@ export function useScaleDepth(groupId: string, sheetId?: string): number {
|
|
|
39
40
|
const scaleDepthSelector = (state: BottomSheetStore) => {
|
|
40
41
|
const { stackOrder, sheetsById } = state;
|
|
41
42
|
|
|
42
|
-
// For background: check if ANY scaleBackground sheet is active (binary 0/1)
|
|
43
|
-
// For a sheet: count scaleBackground sheets above it in the stack
|
|
44
43
|
const startIndex = sheetId ? stackOrder.indexOf(sheetId) + 1 : 0;
|
|
45
44
|
|
|
46
45
|
if (sheetId && startIndex === 0) {
|
|
47
|
-
// Sheet not found in stack, return previous value to avoid flicker
|
|
48
46
|
return prevDepthRef.current;
|
|
49
47
|
}
|
|
50
48
|
|
|
@@ -59,8 +57,6 @@ export function useScaleDepth(groupId: string, sheetId?: string): number {
|
|
|
59
57
|
sheet.status !== 'closing'
|
|
60
58
|
) {
|
|
61
59
|
depth++;
|
|
62
|
-
// For background wrapper (no sheetId), we only need to know if there's at least one
|
|
63
|
-
// Don't accumulate - background scales once, sheets below scale cumulatively
|
|
64
60
|
if (!sheetId) {
|
|
65
61
|
break;
|
|
66
62
|
}
|
|
@@ -78,10 +74,8 @@ export function useScaleDepth(groupId: string, sheetId?: string): number {
|
|
|
78
74
|
* Returns animated style for scale effect based on depth.
|
|
79
75
|
* Uses power scaling: scale^depth for cascading effect.
|
|
80
76
|
*/
|
|
81
|
-
export function useScaleAnimatedStyle(
|
|
82
|
-
{ groupId,
|
|
83
|
-
config?: ScaleConfig
|
|
84
|
-
) {
|
|
77
|
+
export function useScaleAnimatedStyle({ id }: { id?: string } = {}) {
|
|
78
|
+
const { groupId, scaleConfig } = useBottomSheetManagerContext();
|
|
85
79
|
const scaleDepth = useScaleDepth(groupId, id);
|
|
86
80
|
|
|
87
81
|
const {
|
|
@@ -89,7 +83,7 @@ export function useScaleAnimatedStyle(
|
|
|
89
83
|
translateY = DEFAULT_CONFIG.translateY,
|
|
90
84
|
borderRadius = DEFAULT_CONFIG.borderRadius,
|
|
91
85
|
duration = DEFAULT_CONFIG.duration,
|
|
92
|
-
} =
|
|
86
|
+
} = scaleConfig ?? {};
|
|
93
87
|
|
|
94
88
|
const progress = useDerivedValue(() => {
|
|
95
89
|
return withTiming(scaleDepth, { duration });
|