Skip to content

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

@haibert

Description

@haibert

@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 #2052 (comment)

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

  • iOS
  • 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",

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions