Another blind attemp to work around dblclicks on Edge (#5268)

* Another blind attemp to work around dblclicks on Edge

* Make linter happy, do not forget about IE11 & IE11 pointer events
This commit is contained in:
Iván Sánchez Ortega 2017-01-23 10:56:08 +01:00 committed by Per Liedman
parent f8bcccc24f
commit 2b5d401976
2 changed files with 11 additions and 9 deletions

View File

@ -17,9 +17,7 @@ L.extend(L.DomEvent, {
var count;
if (L.Browser.pointer) {
if ((!L.Browser.edge) || e.pointerType === 'mouse') {
return;
}
if ((!L.Browser.edge) || e.pointerType === 'mouse') { return; }
count = L.DomEvent._pointersCount;
} else {
count = e.touches.length;
@ -35,9 +33,11 @@ L.extend(L.DomEvent, {
last = now;
}
function onTouchEnd() {
function onTouchEnd(e) {
if (doubleTap && !touch.cancelBubble) {
if (L.Browser.pointer) {
if ((!L.Browser.edge) || e.pointerType === 'mouse') { return; }
// work around .type being readonly with MSPointer* events
var newTouch = {},
prop, i;
@ -65,12 +65,11 @@ L.extend(L.DomEvent, {
obj.addEventListener(touchstart, onTouchStart, false);
obj.addEventListener(touchend, onTouchEnd, false);
// On some platforms (notably, chrome on win10 + touchscreen + mouse),
// On some platforms (notably, chrome<55 on win10 + touchscreen + mouse),
// the browser doesn't fire touchend/pointerup events but does fire
// native dblclicks. See #4127.
if (!L.Browser.edge) {
obj.addEventListener('dblclick', handler, false);
}
// Edge 14 also fires native dblclicks, but only for pointerType mouse, see #5180.
obj.addEventListener('dblclick', handler, false);
return this;
},

View File

@ -77,7 +77,10 @@ L.DomEvent = {
if (L.Browser.pointer && type.indexOf('touch') === 0) {
this.addPointerListener(obj, type, handler, id);
} else if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) {
} else if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener &&
!(L.Browser.pointer && L.Browser.chrome)) {
// Chrome >55 does not need the synthetic dblclicks from addDoubleTapListener
// See #5180
this.addDoubleTapListener(obj, handler, id);
} else if ('addEventListener' in obj) {