msand / zoomable-svg

Pinch to pan-n-zoom react-native-svg components using a render prop.
38 stars 14 forks source link

doubleTapThreshold prop breaks touch events on SVG. #5

Open rrrhys opened 6 years ago

rrrhys commented 6 years ago

When the doubleTapThreshold prop is set, touch events never get passed through to the underlying SVG.

shouldRespond returns a truthy value when doubleTapThreshold is set, causing the view to always set the pan responder.

        !lock &&
        (evt.nativeEvent.touches.length === 2 ||
          dx * dx + dy * dy >= moveThreshold ||
          doubleTapThreshold)

In my case I removed doubleTapThreshold from ZoomableSvg props.

If this is by design, could you add to the homepage docs?

Thanks for your great work @msand, saved me many hours!

msand commented 6 years ago

Oh, I see. Hadn't thought about this interaction. Should probably document it, or figure out a better solution. I guess you're not in need of the double tap function. I'll look around a bit for how or if this has been solved in other contexts to allow both double tap to zoom and interact with ancestors, I guess it might be enough to move the check for double taps into shouldRespond, just feels like the wrong place to add side-effects.

BabakSamimi commented 5 years ago

Is the double tap zoom a thing or how would I implement it?

msand commented 5 years ago

Well, if you only need double tap zoom, it should be enough to give a non-zero value to doubleTapThreshold, and if you want events to go to the underlying svg content you need to set it to zero. Otherwise, the shouldRespond logic needs to be adapted to the needs.

nksazonov commented 3 years ago

Oh, I see. Hadn't thought about this interaction. Should probably document it, or figure out a better solution. I guess you're not in need of the double tap function. I'll look around a bit for how or if this has been solved in other contexts to allow both double tap to zoom and interact with ancestors, I guess it might be enough to move the check for double taps into shouldRespond, just feels like the wrong place to add side-effects.

@msand, could you describe how to move the check for the double taps into shouldRespond or other methods to make children elements recieve touches while doubleTapThreshold is set?

Your help would be very appreciated!