File tree Expand file tree Collapse file tree
package/src/components/UIComponents Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,6 +109,23 @@ export const BottomSheetModal = (props: PropsWithChildren<BottomSheetModalProps>
109109 }
110110 } ) ;
111111
112+ const closeFromGesture = useStableCallback ( ( ) => {
113+ requestAnimationFrame ( ( ) => {
114+ isOpen . value = false ;
115+ isOpening . value = false ;
116+
117+ sheetTranslateY . value = withTiming (
118+ maxHeight ,
119+ { duration : 250 , easing : Easing . out ( Easing . cubic ) } ,
120+ ( finished ) => {
121+ if ( finished ) {
122+ runOnJS ( onClose ) ( ) ;
123+ }
124+ } ,
125+ ) ;
126+ } ) ;
127+ } ) ;
128+
112129 const close = useStableCallback ( ( closeAnimationFinishedCallback ?: ( ) => void ) => {
113130 if ( ! visible || ! isOpen . value ) {
114131 return ;
@@ -274,20 +291,7 @@ export const BottomSheetModal = (props: PropsWithChildren<BottomSheetModalProps>
274291 const shouldClose = isAtTopSnap ? shouldCloseFromTopSnap : shouldCloseFromLowerSnap ;
275292
276293 if ( shouldClose ) {
277- isOpen . value = false ;
278- isOpening . value = false ;
279-
280- sheetTranslateY . value = withTiming (
281- maxHeight ,
282- { duration : 250 , easing : Easing . out ( Easing . cubic ) } ,
283- ( finished ) => {
284- if ( ! finished ) {
285- return ;
286- }
287-
288- runOnJS ( onClose ) ( ) ;
289- } ,
290- ) ;
294+ runOnJS ( closeFromGesture ) ( ) ;
291295 } else {
292296 isOpen . value = true ;
293297 let nearestIndex = 0 ;
@@ -320,9 +324,8 @@ export const BottomSheetModal = (props: PropsWithChildren<BottomSheetModalProps>
320324 [
321325 currentSnapIndex ,
322326 isOpen ,
323- isOpening ,
324327 maxHeight ,
325- onClose ,
328+ closeFromGesture ,
326329 panStartTranslateY ,
327330 renderContent ,
328331 snapPoints ,
You can’t perform that action at this time.
0 commit comments