From 25648b8f35c7ea42d90843ac4439d7f5fdc93ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Thu, 7 Jan 2016 13:25:52 +0100 Subject: [PATCH 1/3] Possible fix for #4127, assume dblclick DOM event exists in touch-capable browsers --- src/dom/DomEvent.DoubleTap.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/dom/DomEvent.DoubleTap.js b/src/dom/DomEvent.DoubleTap.js index d3ec09ec..5be9097a 100644 --- a/src/dom/DomEvent.DoubleTap.js +++ b/src/dom/DomEvent.DoubleTap.js @@ -57,18 +57,27 @@ L.extend(L.DomEvent, { obj[pre + touchstart + id] = onTouchStart; obj[pre + touchend + id] = onTouchEnd; + obj[pre + 'dblclick' + id] = handler; obj.addEventListener(touchstart, onTouchStart, false); obj.addEventListener(touchend, onTouchEnd, false); + + // On some platforms (notably, chrome on win10 + touchscreen + mouse), + // the browser doesn't fire touchend/pointerup events but does fire native dblclicks + obj.addEventListener('dblclick', handler, false); + return this; }, removeDoubleTapListener: function (obj, id) { var pre = '_leaflet_', - touchend = obj[pre + this._touchend + id]; + touchstart = obj[pre + this._touchstart + id], + touchend = obj[pre + this._touchend + id], + dblclick = obj[pre + 'dblclick' + id]; - obj.removeEventListener(this._touchstart, obj[pre + this._touchstart + id], false); + obj.removeEventListener(this._touchstart, touchstart, false); obj.removeEventListener(this._touchend, touchend, false); + obj.removeEventListener('dblclick', dblclick, false); return this; } From ce0b28950479b4d36937869539c7ad1570a940a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Fri, 8 Jan 2016 13:07:01 +0100 Subject: [PATCH 2/3] Test webpage for dblclick/dbltap performance --- debug/tests/doubleclick-events-slowdown.html | 72 ++++++++++++++++++++ src/dom/DomEvent.DoubleTap.js | 3 +- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 debug/tests/doubleclick-events-slowdown.html diff --git a/debug/tests/doubleclick-events-slowdown.html b/debug/tests/doubleclick-events-slowdown.html new file mode 100644 index 00000000..2c282117 --- /dev/null +++ b/debug/tests/doubleclick-events-slowdown.html @@ -0,0 +1,72 @@ + + + + Leaflet debug page + + + + + + + + + + + + +

This test is meant for testing the performance of doubleclick event handler in IE. See #4127 and #2820

+ +
+
+ + + + diff --git a/src/dom/DomEvent.DoubleTap.js b/src/dom/DomEvent.DoubleTap.js index 5be9097a..f4d55989 100644 --- a/src/dom/DomEvent.DoubleTap.js +++ b/src/dom/DomEvent.DoubleTap.js @@ -63,7 +63,8 @@ L.extend(L.DomEvent, { obj.addEventListener(touchend, onTouchEnd, false); // On some platforms (notably, chrome on win10 + touchscreen + mouse), - // the browser doesn't fire touchend/pointerup events but does fire native dblclicks + // the browser doesn't fire touchend/pointerup events but does fire + // native dblclicks. See #4127. obj.addEventListener('dblclick', handler, false); return this; From 11ebda22d53ce27a93b9a641b45ea7dac25655ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Wed, 13 Jan 2016 14:44:33 +0100 Subject: [PATCH 3/3] Work around MS Edge duplicated dblclick on DomEvent.DoubleTap --- src/dom/DomEvent.DoubleTap.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/dom/DomEvent.DoubleTap.js b/src/dom/DomEvent.DoubleTap.js index f4d55989..6bccce48 100644 --- a/src/dom/DomEvent.DoubleTap.js +++ b/src/dom/DomEvent.DoubleTap.js @@ -65,7 +65,9 @@ L.extend(L.DomEvent, { // On some platforms (notably, chrome on win10 + touchscreen + mouse), // the browser doesn't fire touchend/pointerup events but does fire // native dblclicks. See #4127. - obj.addEventListener('dblclick', handler, false); + if (!L.Browser.edge) { + obj.addEventListener('dblclick', handler, false); + } return this; }, @@ -78,7 +80,9 @@ L.extend(L.DomEvent, { obj.removeEventListener(this._touchstart, touchstart, false); obj.removeEventListener(this._touchend, touchend, false); - obj.removeEventListener('dblclick', dblclick, false); + if (!L.Browser.edge) { + obj.removeEventListener('dblclick', dblclick, false); + } return this; }