react-native-gesture-handler icon indicating copy to clipboard operation
react-native-gesture-handler copied to clipboard

Not possible to manipulate the configuration of a gesture on the fly through its ref like in the old API

Open haibert opened this issue 2 years ago • 2 comments

@haibert Unfortunately, that's not possible at the moment. I know it's not an ideal replacement, but you could use state instead of shared value to accomplish a similar effect.

Originally posted by @j-piasecki in https://github.com/software-mansion/react-native-gesture-handler/issues/2052#issuecomment-1129665230

DESCRIPTION

is it possible to add the ability to do this with the new API?

USED TO WORK


panGestureHandlerRef.current?.setNativeProps({
            activeOffsetX: [-999, 0.1],
            failOffsetX: [-0.1, 999],
        })
        

I DONT THINK THIS WORKS ?


    const activeOffsetX = useSharedValue([])
    const failOffsetX = useSharedValue([])

    const lockScrollable = () => {
           activeOffsetX.value = [-999, 0.1]
           failOffsetX.value = [-0.1, 999]
    }

    const gesture = Gesture.Pan()
        .activeOffsetX(activeOffsetX.value)
        .failOffsetX(failOffsetX.value)
        .withRef(panGestureHandlerRef)
        .simultaneousWithExternalGesture(cardGestureHandlerRef)

Platforms

  • [X] iOS
  • [X] Android
  • [ ] Web

Steps To Reproduce

https://gist.github.com/haibert/c99861f8c02e7e0b701c83ff2b2317ff

Expected behavior

I want to change the configuration of the gesture imperatively on the fly.

Actual behavior

this functionality does not exist

Snack or minimal code example

https://gist.github.com/haibert/c99861f8c02e7e0b701c83ff2b2317ff

Package versions

    "react-native-gesture-handler": "2.4",
    "@react-navigation/stack": "^6.2.1",
    "react-native-reanimated": "~2.8.0",

haibert avatar Jun 02 '22 16:06 haibert

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Description section.

github-actions[bot] avatar Jun 02 '22 16:06 github-actions[bot]

At the moment we have no plans to add support for it, however you could accomplish a similar effect using the manual gestures (or manual activation) in combination with touch events. This may require a lot of boilerplate code though.

j-piasecki avatar Jun 24 '22 08:06 j-piasecki