Skip to content

Make PanGestureHandler more compatible with ScrollView and FlatList by adding a "minDurationMs" prop to it #1095

@Fearnbuster

Description

@Fearnbuster

As has been mentioned in various other issues (issue #434 in particular), PanGestureHandler and ScrollView/FlatList don't work so well together.

I, for example, currently have a situation where a ScrollView is completely filled with multiple PanGesturehandlers which leaves no space to interact with the ScrollView.

While attempting to find a workaround, I noticed that the LongPressGestureHandler has almost the exact functionality that I need.

For example: by setting minDurationMs to a reasonable value, shouldCancelWhenOutside to false, and maxDist to an arbitrarily large value that would never be reached, I was able to simulate what would best be described as a PanGestureHandler that required you to hold your finger in place for the given amount of time before it became the ACTIVE handler.

If however, you moved your finger too much (I'm not sure what the built-in distance is) before the LongPressGestureHandler activated, whichever handler wrapped the LongPressGestureHandler (which was a ScrollView in my case) became the ACTIVE handler (which, in the case of a ScrollView, meant it was now able to be scrolled).

I wish I could just use the LongPressGestureHandler for my particular use-case, but unfortunately, it does not send the translationX and translationY properties through the onGestureEvent callback like the PanGesturehandler does.

If someone could add a minDurationMs prop to the PanGesturehandler that almost directly mirrored the same props from the LongPressGestureHandler, it would drastically increase how easy it is to use the PanGesturehandler within other handlers (ScrollView and FlatList being the two biggest and most pressing examples)

If this prop ever did get added, then it would probably be wise to enable developers to customize how far the user's finger could move during this initial "waiting" phase without canceling the handler.
Although it's important to note, that obviously this new "max distance" prop would apply to the PanGesturehandler only while it is in the "waiting" phase.

I would love to try to implement this feature myself, but unfortunately, I don't have a Mac, so I wouldn't be able to develop the iOS functionality.
I would be willing to try my hand at implementing the Android functionality if someone would be willing to help me with the iOS side, although I would prefer to have someone more competent than myself do it.

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