Skip to content

Conversation

jerel
Copy link
Contributor

@jerel jerel commented Dec 21, 2012

This patch calls L.DomEvent.stop(event) on the second if two clicks are triggered within 400ms
of each other. Double click is unaffected however.

There are other workarounds that focus on _fireMouseEvent(), however I had to
resolve it at the click event level as my map, markers, controls, were all
affected.

… calls

L.DomEvent.stop(event) on the second if two clicks are triggered within 400ms
of each other. Double click is unaffected however.

There are other workarounds that focus on _fireMouseEvent(), however I had to
resolve it at the click event level as my map, markers, controls, were all
affected.
@@ -41,6 +41,13 @@ L.DomEvent = {

obj.addEventListener(newType, handler, false);

} else if (type === 'click') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you only do this for Android if it's not relevant for other browsers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good point. I've implemented and pushed a check for the Android UA so we're not affecting anybody else. From what I've read this bug seems to affect any and all Android WebViews at this point

Previously it was blocking when an element had multiple click listeners
because those events were fired rapidly. Since Android fires its second
click at approximately 300ms after the first we do a check to make sure
that at least 100ms has elapsed but not more than 400ms.
@Mathbl
Copy link

Mathbl commented Dec 27, 2012

Good job @jerel, it seems to work perfectly for me. I had this problem and was looking for a way to fix it. Your solution works!

Now, I only have a remaining problem with popup. I think it has to do with that click event firing twice.

I have a popup with a image inside. When clicking on the image inside the popup, it launch another activity in my android app. But when the popup is outside the screen, the map pans to show it but there seems to be another click fired and that launch the activity automatically.

Here's a video attached to show what i mean. Any idea what cause this?

http://dl.dropbox.com/u/26198358/VIDEO0018.3gp

Thank you guys!

@jerel
Copy link
Contributor Author

jerel commented Jan 3, 2013

@HooliganQC I've experimented here and don't see that behavior. Can you replace the image with a non image link of the same size and see if it still happens? It could possibly be caused by a pause between events that's caused by the image loading.

Other than that the only suggestion I have is to do some console.logs in the event handler and see what type of events are being triggered and by what. Doing an e.timeStamp will tell you what times they are being triggered

@skunkfu2
Copy link

He jerel, thanks for the fix!

However the patch does not fix the bug on a Galaxy Nexus 4.2 Jelly Bean within a WebView. I have to use buttons that call the zoomIn() and zoomOut() methods in the mean time.

I wish I could contribute a fix for this but I am not fluent in JavaScript.

If you need a tester just gives a shout.

Cheers!

@jerel
Copy link
Contributor Author

jerel commented Jan 11, 2013

skunkfu2, what behavior are you seeing? What do you expect to happen and what happens instead and when?

FWIW I'm running it on a device with Android 4.2.1 using a WebView that works fine

@skunkfu2
Copy link

Hey jerel,

Before applying the patch, and having zoomControl set to true, when touching either zoom in or zoom out buttons, it does zoom either in or out but with the whole double tapping bug, and the tiles of the custom map I'm using actually overlaps on its edges depending on the zoom level. This happens straight away when I touch on the zoom buttons.

After applying the patch, the buttons do not work at all.

If needed, I can upload the test .apk file I'm currently using for my app, as well as the source.

I can confirm that I'm using Android v4.2.1 on the Galaxy Nexus, and that it works fine on a HTC Desire Android v2.3.7 test device.

Cheers bud.

@skunkfu2
Copy link

Okay scratch that, the fix works for me in conjunction with the CSS fix for the bug here: #161

I can't explain that one.

Only problem with using the CSS fix is a considerable performance drop. Can't win them all!

Cheers.

mourner added a commit that referenced this pull request Feb 4, 2013
A bug in Android WebView triggers two clicks at once.
@mourner mourner merged commit 72ad691 into Leaflet:master Feb 4, 2013
mourner added a commit that referenced this pull request Feb 4, 2013
@mourner
Copy link
Member

mourner commented Feb 4, 2013

Thanks for the pull! Cleaned it up a bit, please check if it still works.

@mfk
Copy link

mfk commented Feb 4, 2013

Hi,

since i update my library to 0.5 i have this problem on Microsoft Surface with IE10 ... any ideas ?

BR,
Dragos

@danzel
Copy link
Member

danzel commented Feb 4, 2013

@mfk please open a separate bug and post some more details.
From my testing IE10 shouldn't have this bug at all.

@nhinze
Copy link

nhinze commented Feb 21, 2013

I'm using the latest LL build as of 2/21/13 (Leaflet-Leaflet-5558987) and I still see this bug in Android 4.1.1 WebView. It happens when I click the layer button, it right away selects another layer. A little annoying. I can see it also happen when I click a marker, but it doesn't make the popup flicker.

@m-misseri
Copy link

Same problem here. I'm using this leaflet version: https://gist.github.com/bedspax/5480985
Should I include some of this files?
https://github.com/Leaflet/Leaflet/tree/master/src/dom

The popup sometimes blinks, sometimes disapperas, sometimes just stays.

Here the video: http://cl.ly/143X2M3C1318 (Android 4.2.2, apk build) – Is this behavior OK?

@mourner
Copy link
Member

mourner commented Apr 29, 2013

You should download the master version here https://github.com/Leaflet/Leaflet/archive/master.zip and include the files in the dist folder instead of the ones you have included now.

@m-misseri
Copy link

Thanks @mourner now works like a charm

johnd0e pushed a commit to johnd0e/Leaflet0 that referenced this pull request Mar 12, 2020
Was introduced in 8b742a0 to fix* Leaflet#1694, caused by Leaflet#1201.
As we already removed related (Leaflet#1227) workarounds in Leaflet#7013, so this is just continuation.
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

Successfully merging this pull request may close these issues.

8 participants