Skip to content

Commit ace0da7

Browse files
committed
fix: fixed dynamic scrollables content size with footer in place
1 parent 9468c9b commit ace0da7

File tree

4 files changed

+15
-24
lines changed

4 files changed

+15
-24
lines changed

src/components/bottomSheet/BottomSheet.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
212212
animatedContainerHeight,
213213
animatedContentHeight,
214214
animatedHandleHeight,
215+
animatedFooterHeight,
215216
enableDynamicSizing,
216217
maxDynamicContentSize
217218
);

src/components/bottomSheetScrollable/createBottomSheetScrollableComponent.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ export function createBottomSheetScrollableComponent<T, P>(
6666
animatedScrollableState,
6767
enableContentPanningGesture,
6868
} = useBottomSheetInternal();
69-
const { setContentSize } = useBottomSheetContentSizeSetter(
70-
enableFooterMarginAdjustment
71-
);
69+
const { setContentSize } = useBottomSheetContentSizeSetter();
7270
//#endregion
7371

7472
if (!draggableGesture && enableContentPanningGesture) {

src/components/bottomSheetScrollable/useBottomSheetContentSizeSetter.ts

+6-17
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,22 @@ import { useBottomSheetInternal } from '../../hooks';
44
/**
55
* A hook to set the content size properly into the bottom sheet,
66
* internals.
7-
*
8-
* @param enableFooterMarginAdjustment Adjust the scrollable bottom margin to avoid the animated footer.
9-
* @returns
107
*/
11-
export function useBottomSheetContentSizeSetter(
12-
enableFooterMarginAdjustment: boolean
13-
) {
8+
export function useBottomSheetContentSizeSetter() {
149
//#region hooks
15-
const { enableDynamicSizing, animatedContentHeight, animatedFooterHeight } =
10+
const { enableDynamicSizing, animatedContentHeight } =
1611
useBottomSheetInternal();
1712
//#endregion
1813

1914
//#region methods
2015
const setContentSize = useCallback(
2116
(contentHeight: number) => {
22-
if (enableDynamicSizing) {
23-
animatedContentHeight.value =
24-
contentHeight +
25-
(enableFooterMarginAdjustment ? animatedFooterHeight.value : 0);
17+
if (!enableDynamicSizing) {
18+
return;
2619
}
20+
animatedContentHeight.value = contentHeight;
2721
},
28-
[
29-
enableDynamicSizing,
30-
animatedContentHeight,
31-
animatedFooterHeight,
32-
enableFooterMarginAdjustment,
33-
]
22+
[enableDynamicSizing, animatedContentHeight]
3423
);
3524
//#endregion
3625

src/hooks/useAnimatedSnapPoints.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { normalizeSnapPoint } from '../utilities';
1818
* @param containerHeight BottomSheetContainer height.
1919
* @param contentHeight content size.
2020
* @param handleHeight handle size.
21+
* @param footerHeight footer size.
2122
* @param enableDynamicSizing
2223
* @param maxDynamicContentSize
2324
* @returns {Animated.SharedValue<number[]>}
@@ -27,6 +28,7 @@ export const useAnimatedSnapPoints = (
2728
containerHeight: SharedValue<number>,
2829
contentHeight: SharedValue<number>,
2930
handleHeight: SharedValue<number>,
31+
footerHeight: SharedValue<number>,
3032
enableDynamicSizing: BottomSheetProps['enableDynamicSizing'],
3133
maxDynamicContentSize: BottomSheetProps['maxDynamicContentSize']
3234
): [SharedValue<number[]>, SharedValue<number>, SharedValue<boolean>] => {
@@ -71,7 +73,7 @@ export const useAnimatedSnapPoints = (
7173
const dynamicSnapPoint =
7274
containerHeight.value -
7375
Math.min(
74-
contentHeight.value + handleHeight.value,
76+
contentHeight.value + handleHeight.value + footerHeight.value,
7577
maxDynamicContentSize !== undefined
7678
? maxDynamicContentSize
7779
: containerHeight.value
@@ -92,11 +94,12 @@ export const useAnimatedSnapPoints = (
9294

9395
return _normalizedSnapPoints;
9496
}, [
95-
containerHeight.value,
9697
snapPoints,
98+
containerHeight,
99+
handleHeight,
100+
contentHeight,
101+
footerHeight,
97102
enableDynamicSizing,
98-
handleHeight.value,
99-
contentHeight.value,
100103
maxDynamicContentSize,
101104
dynamicSnapPointIndex,
102105
]);

0 commit comments

Comments
 (0)