react-draggable icon indicating copy to clipboard operation
react-draggable copied to clipboard

Reconcile handling of mouse and touch drag start events

Open szakharchenko opened this issue 4 years ago • 4 comments
trafficstars

Attach the mousedown event handler to the node, likewise to the touchstart, so that it may be cancelled if needed and otherwise handled more uniformly

szakharchenko avatar Mar 05 '21 11:03 szakharchenko

Hmm, this is interesting. Can you point me to a use case / example code where this change makes a difference for you?

STRML avatar Mar 05 '21 13:03 STRML

I'm not sure I can. Having different code paths for mouse and touch events just looks inelegant (e.g. one receives a browser event and another a synthetic event). I made this change as part of handling click-vs-drag issues like https://github.com/react-grid-layout/react-draggable/issues/531, https://github.com/react-grid-layout/react-draggable/issues/419 and https://github.com/react-grid-layout/react-draggable/issues/409 . It seems like I've made things to work even without this change though, so I can't say it's absolutely necessary, it just looks like it would make things a bit cleaner. This is a merge offer, not a pull request;)

szakharchenko avatar Mar 05 '21 13:03 szakharchenko

The comment would need to be reworded though; this doesn't by itself make it possible to cancel the click event after drag.

szakharchenko avatar Mar 05 '21 14:03 szakharchenko

That makes sense. I'll test it and see if this changes anything upstream.

STRML avatar Mar 05 '21 14:03 STRML