Skip to content

Commit

Permalink
Another blind attemp to work around dblclicks on Edge (#5268)
Browse files Browse the repository at this point in the history
* Another blind attemp to work around dblclicks on Edge

* Make linter happy, do not forget about IE11 & IE11 pointer events
  • Loading branch information
IvanSanchez authored and perliedman committed Jan 23, 2017
1 parent f8bcccc commit 2b5d401
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/dom/DomEvent.DoubleTap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
},
Expand Down
5 changes: 4 additions & 1 deletion src/dom/DomEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2b5d401

Please sign in to comment.