Android Click, Dbl-Click Firing Extra Clicks

805
7
04-03-2014 02:13 PM
deleted-user-RAnWn8DDSd1P
New Contributor III
Nexus 5 & HTC One [4.4.2], Chrome [33.0.1750.170]

Using esri 3.8compact, on android phones noted, click fires click-click, dbl-click fires click-click-dbl-click
http://www.portlandmaps.com/arcmaps/fix/esri.click.htm
http://www.portlandmaps.com/arcmaps/fix/esri.click.fixed.htm (fix with e.stopImmediatePropagation())
http://www.portlandmaps.com/arcmaps/fix/esri.dbl-click.htm
http://www.portlandmaps.com/arcmaps/fix/esri.dbl-click.fixed.htm (fix with set|clearTimeout)

Using leaflet 0.8dev/esri-leaflet 0.0.1-beta.4, click is fine, however, any browser dbl-click fires click-dbl-click or click-click-dbl-click depending on browser.
http://www.portlandmaps.com/arcmaps/fix/leaflet.dbl-click.htm
http://www.portlandmaps.com/arcmaps/fix/leaflet.dbl-click.fixed.htm (fix with set|clearTimeout)

Sorry examples aren't fiddles.  dbl-click in desktop site confuses the situation by zooming page. 
Please fixie, thankie 🙂
0 Kudos
7 Replies
deleted-user-RAnWn8DDSd1P
New Contributor III
Should be mentioned that e.stopPropagation(), e.preventDefault() and return false all don't work to suppress the extra single click on android.  I've always trusted the latter to do the same as the two former.  Only e.stopImmediatePropagation() works for this.  Had to wrap the two former in try to suppress illegal invocation.
0 Kudos
PatrickArlt1
Esri Contributor
Leaflet is actually handling this weird and buggy behavior for you you can look at their code here. https://github.com/Leaflet/Leaflet/blob/v0.7.2/src/dom/DomEvent.js#L217-L234

You could probably take a similar approach with the JS API.
0 Kudos
deleted-user-RAnWn8DDSd1P
New Contributor III
this handles the extra single-click in leaflet nicely, however, the double-click firing single-click(s) as well was said to be by design which I understand is done to not delay any single-click but, given the absence of a delayedclick event to latch onto that only fires when double-click does not, it becomes difficult to support an app which needs double-click zoom and single-click identify and only one happening at any one time.  i feel the hacky set|clearTimeout deal will come back to bite me at some point.  i think it would be preferrable for the js api to make double-click fire no extra single-clicks or have an extra delayedclick event.
0 Kudos
PatrickArlt1
Esri Contributor
Since this behavior is specific to how you want your app to work and how to make identify calls I don't think its the responsibility of Esri Leaflet to handle this for you. Especially since it would involve modifying Leaflets default behavior.

I have posted a solution for a click-to-identify/double-click-to-zoom experience in this GitHub issue https://github.com/Esri/esri-leaflet/issues/233.

I will however look into integrating this into https://github.com/Esri/esri-leaflet/issues/28 when I do popup helpers for dynamic map layer.
0 Kudos
deleted-user-RAnWn8DDSd1P
New Contributor III
this does not work for me.  you can see the popup on the first click and then it disappears if it was a double-click, because a dblclick is firing click-dblclick.  not sure why it disappears. maybe because leaflet hides popups on zoom. but the point is if you see a popup at all when double-clicking you've fired a click as well, after the bailout param check.  http://www.portlandmaps.com/arcmaps/fix/leaflet.dbl-click2.htm  using chrome 33.0.1750.154 m
0 Kudos
PatrickArlt1
Esri Contributor
I updated the code on https://github.com/Esri/esri-leaflet/issues/233 it looks like the only way to do this.

The following is from the jQuery docs for double click http://api.jquery.com/dblclick/

[INDENT]It is inadvisable to bind handlers to both the click and dblclick events for the same element. The sequence of events triggered varies from browser to browser, with some receiving two click events before the dblclick and others only one. Double-click sensitivity (maximum time between clicks that is detected as a double click) can vary by operating system and browser, and is often user-configurable.[/INDENT]

As an alternative why not bind the identify to the
contextmenu
event on Leaflet? which is fired on right click (desktop) or long press (mobile)?
0 Kudos
deleted-user-RAnWn8DDSd1P
New Contributor III
i don't think that was written with maps in mind.  i consider it the most intuitive for the user in any mapping app on any platform to expect a double-click|tap zoom and a single-click|tap identify.  i know jquery has written that because they've probably seen wide variance in length between clicks that produce a double; a variance that will likely break my original 300ms solution at some point.  shouldn't be too hard to vary the ms by user agent in that case.  i'd much rather live with setTimeout than having to educate users on unexpected behavior.  thanks for confirming problem and workaround.
0 Kudos