question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Simultaneous is not simultaneous

See original GitHub issue

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

https://user-images.githubusercontent.com/34245352/147932838-24089c8e-7fd4-47d0-99cc-1bcf9224e8b6.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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
j-piaseckicommented, Jan 24, 2022

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

1reaction
j-piaseckicommented, Jan 19, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Relativity of simultaneity - Wikipedia
In physics, the relativity of simultaneity is the concept that distant simultaneity – whether two spatially separated events occur at the same time...
Read more >
What did Einstein mean when he said, 'events which ... - Quora
The point he was making is that the idea of simultaneous is not an absolute thing, but is dependent on your reference frame....
Read more >
Special Relativity Simultaneity - University of Pittsburgh
There is no absolute fact as to whether two spatially separated events are simultaneous. There is only a fact of simultaneity or its...
Read more >
Nonsimultaneous Definition & Meaning - Merriam-Webster
The meaning of NONSIMULTANEOUS is not existing or occurring at the same time : not simultaneous. How to use nonsimultaneous in a sentence....
Read more >
Simultaneous Events - UCR Math Department
If you find that they didn't happen at the same time for you, then no, they were not simultaneous in your frame.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found