Skip to content

Commit df7c11c

Browse files
committed
Add new preserveScrollMomentum prop
Mirrors gorhom@719252d
1 parent 096d88c commit df7c11c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/components/bottomSheetScrollable/createBottomSheetScrollableComponent.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export function createBottomSheetScrollableComponent<T, P>(
4343
onRefresh,
4444
progressViewOffset,
4545
refreshControl,
46+
preserveScrollMomentum,
4647
// events
4748
onScroll,
4849
onScrollBeginDrag,
@@ -74,13 +75,12 @@ export function createBottomSheetScrollableComponent<T, P>(
7475
//#region variables
7576
const scrollableAnimatedProps = useAnimatedProps(
7677
() => ({
77-
decelerationRate:
78-
SCROLLABLE_DECELERATION_RATE_MAPPER[animatedScrollableState.value],
78+
...(preserveScrollMomentum ? {} : {decelerationRate: SCROLLABLE_DECELERATION_RATE_MAPPER[animatedScrollableState.value]}),
7979
showsVerticalScrollIndicator: showsVerticalScrollIndicator
8080
? animatedScrollableState.value === SCROLLABLE_STATE.UNLOCKED
8181
: showsVerticalScrollIndicator,
8282
}),
83-
[animatedScrollableState, showsVerticalScrollIndicator]
83+
[animatedScrollableState, showsVerticalScrollIndicator, preserveScrollMomentum]
8484
);
8585

8686
const scrollableGesture = useMemo(

src/components/bottomSheetScrollable/types.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ export interface BottomSheetScrollableProps {
4747
* @default useScrollEventsHandlersDefault
4848
*/
4949
scrollEventsHandlersHook?: ScrollEventsHandlersHookType;
50+
51+
/**
52+
* Whether or not to preserve scroll momentum when expanding a scrollable bottom sheet component.Add commentMore actions
53+
*/
54+
preserveScrollMomentum?: boolean;
5055
}
5156

5257
export type ScrollableProps<T> =

0 commit comments

Comments
 (0)