Leaflet: "Touch" Events do not fire correctly on mobile browsers

Created on 19 Jul 2017  ยท  10Comments  ยท  Source: Leaflet/Leaflet

Check the following testcase and try to trigger the events using the blue square: https://playground-leaflet.rhcloud.com/rol/1/edit?html,output
https://pomf.pyonpyon.moe/jvlscs.html (identical content, new link)

Summary of the various browser:

ย  | IE | FF (PC) | Chrome (PC) | FF (Android) | Chrome (Android) | Safari (iPad)
-- | -- | -- | -- | -- | -- | --
click | โœ” | โœ” | โœ” | โœ” | โœ” | โœ”
dblclick | โœ” | โœ” | โœ” | โœ” | โŒ | โœ”
mousedown | โœ” | โœ” | โœ” | โœ” | โŒ | โœ”
mouseover | โœ” | โœ” | โœ” | โŒ | โœ” | โŒ
mousemove | โœ” | โœ” | โœ” | โœ” | โŒ | โœ”
mouseout | โœ” | โœ” | โœ” | โŒ | โœ” | โŒ
contextmenu | โœ” | โœ” | โœ” | โœ” | โŒ* | โœ”

* Event can fire, if dragging is set to true

Version for each browser is the latest stable, non-beta, version. Running Windows 7, Android 7.1.2 and iOS 10.3.2. Leaflet 1.1.0 is being used.

P.S. I am currently trying to fix my leaflet implementation with workarounds, but the current chrome behavior broke me mentally :-/

needs investigation

Most helpful comment

Is still no solution to get 'touch' events works with leaflet?

All 10 comments

I second this issue! Mouse events like "mousedown" or "mousemove" work perfect on Desktop browsers. But it's not possible to make them (or even the standard JS touch events like "touchstart" or "touchmove" reliable work on each Browser of mobile devices.
I think this is a big showstopper for Leaflet. Leaflet itself should provide methods to make scripts and plugins relying on these kind of usual Mouse+Click events work on Desktop browsers and Mobile Browsers as well. Without the use of external code or days of recherche to code some individual workarounds.

Ideal would be the us of just one eventname (e.b. "pointermove") which is handled on both types: on Desktop's Browsers using mouse-input as well as Mobile Browser's Touchinputs.

See also the questions here:
Question 1
Question 2

@Ceremony64 hm, odd. I do see mousedown and mousemove on Android 7.1.2/Chrome 59, but no dblclick.

I would think this is related to #5180 and Chrome's pointerevents, but not sure exactly how.

@ppete2 that _is_ more or less exactly how Leaflet is intended to work, and has worked for a very long time, although something is apparently broken right now.

@perliedman wow... that is weird. Back when I tested it to compile the table, I only used the rendered "output" view of it, which now isn't available anymore (freemium registration required bs). Who knew more events fire if its running in an iframe? Unfortunately, all other jsbin alternatives i tested do not offer an exclusive live view link, so i used a pomf hoster:
Direct: https://pomf.pyonpyon.moe/jvlscs.html
Within iframe: https://pomf.pyonpyon.moe/veoqth.html

Looks like touch events aren't fired in any browser.
But in Safari and FF it is possible to listen for mouse events, since those browsers fire mouse events instead.
In Chrome, for now there is no way to handle touch events.
I'll dig into this later.

This is something I just realized. I updated my library to work with the latest leaflet and noticed that when using the device mode on chrome the double click event stops working and thus we cannot zoom in by double clicking. This is something that used to work since I can repeat the same experiment on my app in both desktop and device and the zoom by double clicking works when using leaflet 1.0.2. You can see that this is broken in the main leaflet site:

gif

In the view I realize that it may look as if we reached the max zoom but I tried again this time starting with the minimum zoom and I get the same result.

Although it is not listed in the table above, this issue also applies to "mouseup" event.
This is breaking leaflet apps on mobiles :(

+1

Is still no solution to get 'touch' events works with leaflet?

Recent android Firefox fires all events named in the table.
Recent Chrome does not fire mousedown/mousemove and dblclick, and this is wrong.

But I see that sample uses outdated 1.1 version of leaflet, so..

Ok, I see no problem in recent leaflet, so this issue should be closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ttback picture ttback  ยท  4Comments

edmsgists picture edmsgists  ยท  3Comments

brambow picture brambow  ยท  3Comments

arminghm picture arminghm  ยท  3Comments

zdila picture zdila  ยท  3Comments