Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simultaneous is not simultaneous #1804

Closed
adelbeke opened this issue Jan 3, 2022 · 13 comments
Closed

Simultaneous is not simultaneous #1804

adelbeke opened this issue Jan 3, 2022 · 13 comments
Labels
Area: Gestures This issue is related to problems with gestures (v2.0 API) Close when stale The issue will be closed automatically if it remains inactive Gesture Handler 2

Comments

@adelbeke
Copy link

adelbeke commented Jan 3, 2022

Description

I am trying to reproduce a pinch and pan gesture on image like Instagram. In fact, each gesture works but not together, even with the Gesture.Simultaneous

Screenshots

gesture.mp4

Expected behavior

Pinch and pan in the same time.

Actual behavior

See video above.

Snack or minimal code example

const scale = useSharedValue(1)
    const translateX = useSharedValue(0)
    const translateY = useSharedValue(0)

    const pinchGesture = Gesture.Pinch()
        .onBegin(e => {
            runOnJS(props.onPinchImage)(props.postActivityId)
        })
        .onUpdate((e) => {
            scale.value = e.scale
        })
        .onEnd(() => {
            scale.value = withTiming(1)
        })

    const panGesture = Gesture.Pan()
    panGesture.enableTrackpadTwoFingerGesture(true)
    panGesture.minPointers(2)

    panGesture
        .onUpdate(e => {
            'worklet'
            translateX.value = e.translationX
            translateY.value = e.translationY
        })

    panGesture
        .onEnd(e => {
            'worklet'
            translateX.value = withTiming(0)
            translateY.value = withTiming(0)
        })

    const composed = Gesture.Simultaneous(pinchGesture, panGesture)

    const animatedStyle = useAnimatedStyle(() => {
        return {
            zIndex: 50,
            transform: [
                { scale: scale.value },
                { translateX: translateX.value },
                { translateY: translateY.value },
            ],
        }
    })

    return (
        <GestureDetector gesture={composed}>
            <Animated.View style={animatedStyle}>
                <Image
                    source={{ uri: props.uri }}
                    ratio={props.ratio}
                    style={[ tailwind.style('self-center') ]}
                />
            </Animated.View>
        </GestureDetector>
    )

Package versions

  • React: 17.0.1
  • React Native: 0.64.3
  • React Native Gesture Handler: ~2.1.0
@j-piasecki j-piasecki added Area: Gestures This issue is related to problems with gestures (v2.0 API) Gesture Handler 2 labels Jan 5, 2022
@j-piasecki
Copy link
Member

Hi, unfortunately I've been unable to reproduce this issue based on the snippet alone. Could you prepare a repository with a reproduction?

@adelbeke
Copy link
Author

@j-piasecki Hello !
Yep, you can find the repo here : https://github.com/adscud/simultaneous-issue.

You'll see that you are able to :

  • drag with two fingers
  • scale with two fingers

But you can't do theses gestures together.

@j-piasecki
Copy link
Member

Thanks! It seems like this problems occurs only on managed Expo workflow, I'll look into it.

@adelbeke
Copy link
Author

@j-piasecki Thanks!

@adelbeke
Copy link
Author

adelbeke commented Mar 3, 2022

@j-piasecki it will be in Expo 45 ?

@j-piasecki
Copy link
Member

I'm not sure, I've shared the issue with the Expo team but they are a bit tight on time.

@j-piasecki
Copy link
Member

Hi, we tried to reproduce it on locally built Expo Go but it worked fine on all configurations we tried. It seems that it's a problem with the build present in the AppStore. Could you check if it works after the next release of Expo Go, and it not tag me?

@adelbeke
Copy link
Author

Yes ok, the current version is the 2.23.2 so I wait the next one :)

@AbeerAhmad
Copy link

is it fixed or not ? i am having the same issue with pinch gesture and rotation gesture

@slytter
Copy link

slytter commented May 18, 2022

I have the same problem.
For me, Gesture.Simultaneous works as Gesture.Exclusive

Env
Expo go (SDK 45.0.0)

Versions
react-native-gesture-handler: ~2.2.1
react-native: 0.68.1
react: 17.0.2,

@XavierGeerinck
Copy link

Same issue here as above, same dependencies but not working on the latest App Store version.

@kesha-antonov
Copy link

Hi, guys
You can try my package https://github.com/kesha-antonov/react-native-zoom-reanimated
Or at least, you can look at the code. I managed to get it working simultaneously

@ammarfaris
Copy link

Hi, guys You can try my package https://github.com/kesha-antonov/react-native-zoom-reanimated Or at least, you can look at the code. I managed to get it working simultaneously

panning does not work with one finger in latest expo managed work flow @kesha-antonov

@j-piasecki j-piasecki added the Close when stale The issue will be closed automatically if it remains inactive label Dec 20, 2023
@github-actions github-actions bot closed this as completed Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Gestures This issue is related to problems with gestures (v2.0 API) Close when stale The issue will be closed automatically if it remains inactive Gesture Handler 2
Projects
None yet
Development

No branches or pull requests

7 participants