Skip to content

Pinch Gesture conflicting with Nested Scroll View #2332

@rizwan92

Description

@rizwan92

Description

I want to make Google map smooth experience using react-native-reanimated and react-native gesture handler

where one View will have 1000 * 1000 size inside Nested Scroll View one for horizontal and another for vertical scroll behaviour

till now everything is fine but i am facing issue when i pinch the entire View using GestureDetector with pinchGesture Handler

Steps to reproduce


  function FamilyTree() {
  const scale = useSharedValue(1);
  const savedScale = useSharedValue(1);
  const pinchGesture = Gesture.Pinch()
    .onUpdate(e => {
      const chnage = savedScale.value * e.scale;
      scale.value = chnage;
    })
    .onEnd(() => {
      savedScale.value = scale.value;
    });

  const animatedStyle = useAnimatedStyle(() => ({
    transform: [{ scale: scale.value }],
  }));

  console.log('render', animatedStyle);

  return (
    <GestureDetector gesture={pinchGesture}>
      <View className="flex flex-1 bg-slate-300 p-10">
        <View className="flex flex-1 bg-white overflow-hidden border border-blue-600 p-10">
          <Animated.ScrollView
            contentContainerStyle={{
              borderWidth: 1,
              borderColor: '#000',
              padding: 2,
            }}>
            <Animated.ScrollView
              contentContainerStyle={{ borderWidth: 1, borderColor: 'red' }}
              horizontal>
              <Animated.View
                style={[
                  {
                    flex: 1,
                    width: 1000,
                    height: 1000,
                    backgroundColor: 'white',
                    borderWidth: 2,
                    borderColor: 'green',
                    justifyContent: 'center',
                    alignItems: 'center',
                    overflow: 'hidden',
                  },
                  animatedStyle,
                ]}>
                <CircleNode />
                <CircleNode />
                <CircleNode />
                <CircleNode />
              </Animated.View>
            </Animated.ScrollView>
          </Animated.ScrollView>
        </View>
      </View>
    </GestureDetector>
  );
}

Snack or a link to a repository

https://snack.expo.dev/@rizwan92/pinch-with-gesture

Gesture Handler version

2.8.0

React Native version

0.69.1

Platforms

Android

JavaScript runtime

No response

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

Real device

Device model

Xiomi 11 lite NE Android 12 SKQ1.211006.001

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Close when staleThe issue will be closed automatically if it remains inactivePlatform: AndroidThis issue is specific to AndroidRepro providedA reproduction with a snack or repo is provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions