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

panGestureAnimatedValue is animated to 0 instead of 1 when calling open("top") with alwaysOpen option

Open Shaninnik opened this issue 3 years ago • 1 comments

Describe the bug I have a Modalize with alwaysOpen option and two absolutely positioned on top of each other views inside with animated opacity that changes depending on the position of panGestureAnimatedValue value: one view is visible when modalize is closed to alwaysOpen value and another view is visible when modalize is fully open. This works perfectly if I drag/pan modalize to open it - panGestureAnimatedValue value is 0 when modalize is closed and 1 when it is fully open. Unfortunately this does not work when I call .open("top"). Stepping in with debugger I can see that toPanValue is always set to 0 when panGestureAnimatedValue and alwaysOpenValue are true:

if (panGestureAnimatedValue && (alwaysOpenValue || snapPoint)) {
      toPanValue = 0;
    }

Not sure if it will cause any side effects, but changing pan gesture animation block to this seems to fix the issue:

panGestureAnimatedValue
        ? Animated.timing(panGestureAnimatedValue, {
            toValue: alwaysOpenValue && dest === 'default' ? toPanValue : 1,
            duration: PAN_DURATION,
            easing: Easing.ease,
            useNativeDriver,
          })
        : Animated.delay(0),

Reproduce Demo If you drag to open content will change from red to black, but if you tap "Open" button it will not change until you manually start to drag.

Dependencies:

  • react-native-modalize 2.0.8
  • react-native 0.63.3
  • react-native-gesture-handler 1.9.0

Shaninnik avatar May 03 '21 21:05 Shaninnik

@Shaninnik Did you find any workaround for this?

hk-skit avatar May 26 '22 09:05 hk-skit