@@ -273,36 +273,6 @@ export default forwardRef<ActionSheetRef, ActionSheetProps>(
273273 [ animated , props . openAnimationConfig ] ,
274274 ) ;
275275
276- // const keyboardAnimation = React.useCallback(
277- // (shown = true) => {
278- // const position = initialValue.current + actionSheetHeight.current;
279- // const value =
280- // position -
281- // ((dimensionsRef.current?.height || 0) - keyboard.keyboardHeight);
282- // if (!shown) {
283- // animations.translateY.setValue(initialValue.current);
284- // Animated.spring(animations.keyboardTranslate, {
285- // toValue: 0,
286- // friction: 10,
287- // useNativeDriver: true,
288- // }).start();
289- // } else {
290- // // animations.translateY.setValue(initialValue.current - value);
291- // Animated.spring(animations.keyboardTranslate, {
292- // toValue: -keyboard.keyboardHeight,
293- // friction: 10,
294- // useNativeDriver: true,
295- // }).start(() => {
296- // setTimeout(() => {
297- // animations.translateY.setValue(initialValue.current);
298- // }, 1);
299- // });
300- // }
301- // },
302- // // eslint-disable-next-line react-hooks/exhaustive-deps
303- // [animated, props.openAnimationConfig, keyboard],
304- // );
305-
306276 const opacityAnimation = React . useCallback (
307277 ( opacity : number ) => {
308278 Animated . timing ( animations . opacity , {
@@ -365,43 +335,41 @@ export default forwardRef<ActionSheetRef, ActionSheetProps>(
365335 isModal && ! props ?. backgroundInteractionEnabled ? Modal : Animated . View ;
366336
367337 useEffect ( ( ) => {
338+ let animationListener ;
368339 if ( drawUnderStatusBar || props . onChange ) {
369- animationListeners . current . translateY =
370- animations . translateY . addListener ( value => {
371- const correctedValue =
372- value . value > minTranslateValue . current ? value . value : 0 ;
373- props ?. onChange ?.( correctedValue , actionSheetHeight . current ) ;
374- if ( drawUnderStatusBar ) {
375- if ( lock . current ) return ;
376- const correctedHeight = keyboard . keyboardShown
377- ? dimensionsRef . current . height -
378- ( keyboard . keyboardHeight + safeAreaPaddings . current . bottom )
379- : dimensionsRef . current . height -
380- safeAreaPaddings . current . bottom ;
381- const correctedOffset = keyboard . keyboardShown
382- ? value . value - keyboard . keyboardHeight
383- : value . value ;
384-
385- if ( actionSheetHeight . current > correctedHeight - 1 ) {
386- if ( correctedOffset < 100 ) {
387- animations . underlayTranslateY . setValue (
388- Math . max ( correctedOffset - 20 , - 20 ) ,
389- ) ;
390- } else {
391- //@ts -ignore
392- if ( animations . underlayTranslateY . _value < 100 ) {
393- animations . underlayTranslateY . setValue ( 100 ) ;
394- }
340+ animationListener = animations . translateY . addListener ( value => {
341+ const correctedValue =
342+ value . value > minTranslateValue . current ? value . value : 0 ;
343+ props ?. onChange ?.( correctedValue , actionSheetHeight . current ) ;
344+ if ( drawUnderStatusBar ) {
345+ if ( lock . current ) return ;
346+ const correctedHeight = keyboard . keyboardShown
347+ ? dimensionsRef . current . height -
348+ ( keyboard . keyboardHeight + safeAreaPaddings . current . bottom )
349+ : dimensionsRef . current . height - safeAreaPaddings . current . bottom ;
350+ const correctedOffset = keyboard . keyboardShown
351+ ? value . value - keyboard . keyboardHeight
352+ : value . value ;
353+
354+ if ( actionSheetHeight . current > correctedHeight - 1 ) {
355+ if ( correctedOffset < 100 ) {
356+ animations . underlayTranslateY . setValue (
357+ Math . max ( correctedOffset - 20 , - 20 ) ,
358+ ) ;
359+ } else {
360+ //@ts -ignore
361+ if ( animations . underlayTranslateY . _value < 100 ) {
362+ animations . underlayTranslateY . setValue ( 100 ) ;
395363 }
396364 }
397365 }
398- } ) ;
366+ }
367+ } ) ;
399368 }
369+ animationListeners . current . translateY = animationListener ;
400370 return ( ) => {
401- animationListeners . current . translateY &&
402- animations . translateY . removeListener (
403- animationListeners . current . translateY ,
404- ) ;
371+ animationListener &&
372+ animations . translateY . removeListener ( animationListener ) ;
405373 } ;
406374 // eslint-disable-next-line react-hooks/exhaustive-deps
407375 } , [ props ?. id , keyboard . keyboardShown , keyboard . keyboardHeight ] ) ;
@@ -1125,7 +1093,6 @@ export default forwardRef<ActionSheetRef, ActionSheetProps>(
11251093 ] ) ;
11261094
11271095 const onTouch = ( event : GestureResponderEvent ) => {
1128- props . onTouchBackdrop ?.( event ) ;
11291096 onTouchBackdrop ?.( event ) ;
11301097 if ( enableRouterBackNavigation && router . canGoBack ( ) ) {
11311098 router . goBack ( ) ;
@@ -1148,7 +1115,6 @@ export default forwardRef<ActionSheetRef, ActionSheetProps>(
11481115
11491116 if ( orientationChanged ) isOrientationChanging . current = true ;
11501117
1151-
11521118 actionSheetHeight . current =
11531119 event . nativeEvent . layout . height > dimensionsRef . current . height
11541120 ? dimensionsRef . current . height
0 commit comments