From 2eee3871a893c4e0bd61a6b9203316a43eb5b3b2 Mon Sep 17 00:00:00 2001 From: JL Date: Fri, 21 Apr 2023 15:57:11 +0900 Subject: [PATCH 1/2] update: add `SpringConfig` as props --- src/BottomSheet.tsx | 6 ++++-- src/types.ts | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/BottomSheet.tsx b/src/BottomSheet.tsx index 83234c94..da480be2 100644 --- a/src/BottomSheet.tsx +++ b/src/BottomSheet.tsx @@ -69,6 +69,7 @@ export const BottomSheet = React.forwardRef< onSpringEnd, reserveScrollBarGap = blocking, expandOnContentDrag = false, + springConfig, ...props }, forwardRef @@ -157,7 +158,7 @@ export const BottomSheet = React.forwardRef< // New utility for using events safely const asyncSet = useCallback( // @ts-expect-error - ({ onRest, config: { velocity = 1, ...config } = {}, ...opts }) => + ({ onRest, config: { velocity = 1,...config } = {}, ...opts }) => new Promise((resolve) => set({ ...opts, @@ -173,6 +174,7 @@ export const BottomSheet = React.forwardRef< friction, friction + (friction - friction * velocity) ), + ...springConfig, }, onRest: (...args) => { resolve(...args) @@ -180,7 +182,7 @@ export const BottomSheet = React.forwardRef< }, }) ), - [set] + [set, springConfig] ) const [current, send] = useMachine(overlayMachine, { devTools: debugging, diff --git a/src/types.ts b/src/types.ts index a572656b..576f0a76 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,3 +1,5 @@ +import { SpringConfig } from "react-spring"; + export type SnapPointProps = { /** * The height of the sticky header, if there's one @@ -150,7 +152,7 @@ export type Props = { * @default expandOnContentDrag === false */ expandOnContentDrag?: boolean, -} & Omit, 'children'> +} & Omit, 'children'> & { springConfig?: SpringConfig } export interface RefHandles { /** From f399e2b98607ebefa46f9f267bfea5ca1cfa1df5 Mon Sep 17 00:00:00 2001 From: JL Date: Fri, 21 Apr 2023 15:58:58 +0900 Subject: [PATCH 2/2] fix: typo in convention --- src/BottomSheet.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BottomSheet.tsx b/src/BottomSheet.tsx index da480be2..3f5556c7 100644 --- a/src/BottomSheet.tsx +++ b/src/BottomSheet.tsx @@ -158,7 +158,7 @@ export const BottomSheet = React.forwardRef< // New utility for using events safely const asyncSet = useCallback( // @ts-expect-error - ({ onRest, config: { velocity = 1,...config } = {}, ...opts }) => + ({ onRest, config: { velocity = 1, ...config } = {}, ...opts }) => new Promise((resolve) => set({ ...opts,