react-native-modalize icon indicating copy to clipboard operation
react-native-modalize copied to clipboard

Modal Jumping height after opening if I'm closing it with pan gesture

Open cristianrosu opened this issue 1 year ago • 10 comments

When I close the modal with a swipe-down pan gesture, if I open it again, right after opening, it "jumps" height to a random value. If I close the modal programatically using ref.current?.close(), opening it again performs as expected.

This reproduces no matter what props I use or not (headerComponent, adjustToContentHeight, modalHeight, snapPoint ). It also does not matter if I have anything inside the modal.

This happens on both IOS & Android

  • Create a demo on https://snack.expo.io to reproduce the issue.
  • Add gif screenshots to help explain your issue.

Dependencies

  • react-native-modalize: ^2.1.1
  • react-native: 0.73
  • react-native-gesture-handler: 2.14.0
  • @react-navigation/bottom-tabs: ^6.5.11
  • @react-navigation/native: ^6.1.9
  • @react-navigation/native-stack: ^6.9.17

cristianrosu avatar Jan 04 '24 16:01 cristianrosu

Same

wkirby avatar Jan 19 '24 18:01 wkirby

Same problem here with RN 0.73.2 and React native modalize ^2.1.1

Tonisg91 avatar Jan 25 '24 14:01 Tonisg91

Same here

unnft avatar Jan 26 '24 09:01 unnft

Facing the same issue after upgrading to RN 0.73.2

mireiarullmasdeu avatar Jan 26 '24 11:01 mireiarullmasdeu

Any solution?

andshonia avatar Jan 30 '24 09:01 andshonia

Any solution?

I had to change the package to https://github.com/gorhom/react-native-bottom-sheet

Tonisg91 avatar Jan 30 '24 09:01 Tonisg91

@cristianrosu

actually it's not a random value. It's the dragY value where you finished pan gesture. It is supposed to be reset in handleAnimateClose (Animated finish callback) but in newer versions of RN it's overriden down the road. A simple solution or a workaround: Add dragY.setValue(0) at the beginning of handleAnimateOpen method.

marcin-spotio avatar Feb 09 '24 13:02 marcin-spotio

@cristianrosu

actually it's not a random value. It's the dragY value where you finished pan gesture. It is supposed to be reset in handleAnimateClose (Animated finish callback) but in newer versions of RN it's overriden down the road. A simple solution or a workaround: Add dragY.setValue(0) at the beginning of handleAnimateOpen method.

It works, thank you!

diff --git a/node_modules/react-native-modalize/lib/index.js b/node_modules/react-native-modalize/lib/index.js
index 5d5edac..d7c88c3 100644
--- a/node_modules/react-native-modalize/lib/index.js
+++ b/node_modules/react-native-modalize/lib/index.js
@@ -147,6 +147,7 @@ onOpen, onOpened, onClose, onClosed, onBackButtonPress, onPositionChange, onOver
         setKeyboardHeight(0);
     };
     const handleAnimateOpen = (alwaysOpenValue, dest = 'default') => {
+        dragY.setValue(0)
         const { timing, spring } = openAnimationConfig;
         backButtonListenerRef.current = react_native_1.BackHandler.addEventListener('hardwareBackPress', handleBackPress);
         let toValue = 0;
         ```diff

Rolozuna avatar Feb 09 '24 16:02 Rolozuna

@Tonisg91 did you make gorhom package to work with react native 0.74 (or 73) ? my app crash on build ( not in dev mode ) when i install reanimated. did't found a working package number with react 74 and bottomsheeet & reanimated. thanks

alainib avatar Jun 17 '24 16:06 alainib