Skip to content
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

Default zoom.touchable should use navigator.maxTouchPoints, if supported? #162

Closed
lojjic opened this issue Nov 27, 2018 · 3 comments
Closed

Comments

@lojjic
Copy link

lojjic commented Nov 27, 2018

As of Chrome 70, d3-zoom no longer works out of the box when using touch on desktop touchscreens. This is because Chrome has removed the ontouch* element properties on desktop OSes, and d3-zoom's defaultTouchable implementation relies on the presence of the ontouchstart element property as its feature detection. It therefore thinks touch events are unsupported, even though they still are.

See https://www.chromestatus.com/feature/4764225348042752 for their explanation.

We can work around this on a case-by-case basis by overriding the touchable config with our own implementation via zoom().touchable(...), but it would be nice to have a more reliable feature detection in defaultTouchable. It sounds like checking for the presence of window.TouchEvent should work ok but it would need proper cross-browser testing.

Alternative solutions might be: removing the filter altogether and just letting it attach unused touch event handlers in all cases, or adding a PointerEvents-based code path since that's apparently the recommended long-term approach.

@mbostock
Copy link
Member

See also d3/d3-drag#47 (comment).

@mbostock
Copy link
Member

mbostock commented Jul 22, 2019

We can’t remove the filter; that was added in 34c2657 to avoid a [Violation] warning in Chrome.

I considered switching to pointer events, but it still isn’t supported in Safari, so it doesn’t seem ready. (Plus, I imagine it’ll be a pain to rewrite in terms of pointer events, and an even bigger pain to try to support mouse and touch in addition to pointer events.)

I think using navigator.maxTouchPoints > 0 as the default touchable implementation sounds good, though. Never mind, that’s also not supported in Safari.

@mbostock mbostock changed the title Touch support broken in Chrome 70 on desktop Default zoom.touchable should use navigator.maxTouchPoints, if supported. Aug 5, 2019
@mbostock
Copy link
Member

mbostock commented Aug 5, 2019

We could still use navigator.maxTouchPoints if not undefined, though.

@mbostock mbostock changed the title Default zoom.touchable should use navigator.maxTouchPoints, if supported. Default zoom.touchable should use navigator.maxTouchPoints, if supported? Aug 5, 2019
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