10000 Zoom issue with touchstarted event · Issue #72 · d3/d3-zoom · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Zoom issue with touchstarted event #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dmacg opened this issue Nov 26, 2016 · 4 comments
Closed

Zoom issue with touchstarted event #72

dmacg opened this issue Nov 26, 2016 · 4 comments

Comments

@dmacg
Copy link
dmacg commented Nov 26, 2016

On iPhone 7, iOS 10, with both the mobile Chrome and Safari browsers, the zoom functionality will fail if the two pinch-zoom touches happen very close to the same time. This creates a usability issue, as normally when users pinch-zoom, their fingers do in fact hit the screen at nearly the same time.

Not all devices are affected. I was able to test a Windows 7 touch device, and I was not able to get it to exhibit the same behaviour.

On the iPhone, the issue is with the changedTouches and touches collections on the touchstarted event. When the issue occurs on the iPhone:

  1. Two touch events are received as expected, one for each finger.
  2. Also, as expected, each event has a single element in changedTouches
  3. However, both events have two elements in touches.
    (On the Windows device, behaviour differs in that the first event has only one element in touches.)

With the first event having two elements in touches on the iPhone, the zoom fails due to the if statement here (added in #17), as touches is of length 2 and changedTouches is of length 1, preventing the gesture start from being called:

if (event.touches.length === n) {
  touchstarting = setTimeout(function() { touchstarting = null; }, touchDelay);
  interrupt(this);
  g.start();
}

I tested commenting out this if condition, and confirmed that the iPhone started working again as expected. However, I don't know if removing this will cause any other issues. (I did test the double-tap to zoom with this line commented out, and it continued to work fine.)

Note that this may apply to other devices and versions as well, but I'm limited in what I can test. I did test a Windows 7 touch computer, and was not able to reproduce the issue (the first received touchstarted event always had a single touch value).

@dmacg
Copy link
Author
dmacg commented Nov 26, 2016

To clarify... the issue is with the two initial touches that should start the zoom. When the zoom start event is missed, moving one's fingers apart and together doesn't do anything.

@mbostock
Copy link
Member

Please test and review #74. If it works, I will merge and push a patch release. Thank you!

@dmacg
Copy link
Author
dmacg commented Nov 28, 2016

Tested #74 on iPhone 7, both the mobile Safari and Chrome browsers, and the fix worked perfectly!

@mbostock
Copy link
Member

Great. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants
0