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

Prepare for DragGestureHandler

Open ShaMan123 opened this issue 5 years ago • 2 comments

This is the first PR preparing the repo for #963 It enhances the registry and the interaction controller for simultaneous drag gestures which are a UI/UX standard and opens the door for simultaneous gestures across different views. Build passes. Once this will be merged I'll create the next.

Motivation

Making drag and drop in react-native match not only UI/UX standards but DevX as well, making it very simple to create a complex drag and drop UX with no overhead and complicated js. Please refer to this example to get a feeling of how simple it can be! It is the code behind the gif below.

sim-drag

In Depth

GestureHandlerRegistry

In order to prepare a handler for gestures GestureHandlerOrchestrator calls GestureHandler.prepare via GestureHandlerOrchestrator.recordHandlerIfNotPresent. This is done via complex logic once a touch is being recorded by the system by traversing the view tree. In order to support logic for simultaneous dragging there's a need to prepare the drag/drop handlers differently by calling recordHandlerIfNotPresent once a drag gesture begins (not leaning on logic that searches the top most view that contains the pointer). Hence a need to have a method getViewForHandler to obtain the views attached to the simultaneous handlers that should run with the drag gesture's main handler.

GestureHandlerInteractionManager

Exposed getSimultaneousRelations method and moved logic from RNGestureHandlerInteractionManager to GestureHandlerInteractionManager for clarity, logic separation and for the android library (which now I know to be deprecated - I have updated it in the main PR and it is more than fantastic)

ShaMan123 avatar Apr 15 '20 10:04 ShaMan123

updated PR description

ShaMan123 avatar Oct 08 '20 09:10 ShaMan123

Hey all, is there any intention to continue this PR? Drag and drop is something that RN is really missing, so I'd love to see an addition like this, especially now that Reanimated 2 is out. Thanks so much!

nandorojo avatar Mar 29 '21 17:03 nandorojo