d3 / d3-zoom

Pan and zoom SVG, HTML or Canvas using mouse or touch input.
https://d3js.org/d3-zoom
ISC License
505 stars 143 forks source link

Fix doubletap on Chrome on Android #129

Closed jurajmasar closed 5 years ago

jurajmasar commented 6 years ago

Hi there,

Thanks for this wonderful library!

I think I came across an unexpected behavior when testing it with latest Chrome 64.0.3282.137 on Google Pixel 2 XL, when a single tap generated one touchstart event, followed with upto 3 touchmove events.

I've tested this on iPhone 6s as well and only a single touchstart event was generated by a similar tap.

In order to make doubletap zoom work on Pixel, I had to prevent touchmove events from being triggered while touchstarting was true, and consequently decrease touchDelay to 250 to make touch panning less delayed.

This isn't a great solution since the value of touchDelay now essentially represents a compromise between the lag when panning starts and the permitted length of double-tap.

Unfortunately, with this sort of behavior occurring with the new Chrome on Android, I haven't thought of a better solution.

Thanks again!

mbostock commented 5 years ago

I expect we should be using zoom.clickDistance for this, and only canceling the dbltap if the touchmove moves more than a certain distance from the touchstart position.

mbostock commented 5 years ago

Refiled as #180.

mbostock commented 5 years ago

And thank you for the suggestion, and apologies for the delayed response. :)