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

L.Browser.touch is incorrectly being set when on desktop (Chrome) #5266

Closed
jcarenza opened this issue Jan 18, 2017 · 3 comments
Closed

L.Browser.touch is incorrectly being set when on desktop (Chrome) #5266

jcarenza opened this issue Jan 18, 2017 · 3 comments

Comments

@jcarenza
Copy link

It appears that recent updates to Chrome (on Mac, at least) have changed their implementation of window.PointerEvent. This causes the current version of Leaflet (1.0.2) to misdiagnose the browser as a touch device and adds the leaflet-touch class.

This line seems to be the culprit:

pointer = window.PointerEvent || msPointer

...it can be found here: https://github.com/Leaflet/Leaflet/blob/v1.0.2/src/core/Browser.js#L33

The problem is that window.PointerEvent is a function, which will always return 'truthy'.

How to reproduce

  • Browser: Mac OSX El Capitan (10.11.6), Chrome Version 55.0.2883.95 (64-bit)
  • Go to www.leafletjs.com and look at the demo example...the Zoom In/Out buttons are enlarged, due to the leaflet-touch class being applied to the leaflet map container.
@rigoneri
Copy link

I can reproduce this as well...

@IvanSanchez
Copy link
Member

Duplicate of #3944. There is no way to know if the browser is running on a computer with a touchscreen or not, it's only possible to know if the browser supports touch/pointer events or not. See also http://www.stucox.com/blog/you-cant-detect-a-touchscreen/

@rigoneri
Copy link

So, what's the point of detecting touch if it's not going to accurately detect touch? Shouldn't that whole logic be removed from leaflet then?

basisbit added a commit to basisbit/Leaflet.draw that referenced this issue Oct 19, 2017
As discussed in Leaflet/Leaflet#5266 , modern web browsers like Chrome/Chromium/Opera support touch events. Thus, L.Browser.touch returns true even on non-touch screens. In any case, the _getTooltipText should display the distance if showLength is set to true. Without this change, showLength is broken in many browsers for Polyline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants