JedWatson / react-tappable

Tappable component for React
http://jedwatson.github.io/react-tappable/
MIT License
863 stars 90 forks source link

Adds onDrag / onRelease #22

Closed dcousens closed 9 years ago

dcousens commented 9 years ago

This pull request adds an onRelease event that is fired for both onTouchEnd and onMouseUp.

Edge cases are probably missing, but we'll figure it out as they come.

dcousens commented 9 years ago

For onDrag, I'm not sure if onPress should be necesary before or after

dcousens commented 9 years ago

Maybe onDrag should be ignored, simply because of the hacks necessary for the behaviour to be consistent (onMouseMove isn't as contextual as onTouchMove, and therefore needs a top-level div to catch the event)

nmn commented 9 years ago

I don't see any real value in onRelease, but it's just a simple event that doesn't really affect anything else so I don't mind it.

for onDrag, I have some thoughts:

  1. Just like the pinch events, I see no value in providing an onDrag event unless it also does the math for the calculation of displacement and velocity
  2. In real apps, dragging can happen in two contexts:
    • A simple swipe. This would fire anytime on any touchMove, and mouseMove while clicked
    • Specifically on touch-screens, there are often cases, when onDrag should only fire after a press event has fired. This is useful for re-arranging items in a scrollable list for example.

As a result, I think onDrag should be divided into two separate events: onDrag and onPressDrag. onPressDrag would only fire after a press event when dealing with touch. Both events would fire in the case of a mouse drag.

dcousens commented 9 years ago

This PR needs a lot more work. Closing.