From 64484d5c745fef0b4f1f076dec8cbd851d68c8de Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 11 Nov 2015 23:08:32 +0100 Subject: [PATCH] Fix event target fallbacking to map after marker drag (fix #3971) --- src/map/Map.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/map/Map.js b/src/map/Map.js index 04eb1071..c116d96a 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -647,10 +647,16 @@ L.Map = L.Evented.extend({ var targets = [], target, isHover = type === 'mouseout' || type === 'mouseover', - src = e.target || e.srcElement; + src = e.target || e.srcElement, + dragging = false; while (src) { target = this._targets[L.stamp(src)]; + if (target && (type === 'click' || type === 'preclick') && !e._simulated && this._draggableMoved(target)) { + // Prevent firing click after you just dragged an object. + dragging = true; + break; + } if (target && target.listens(type, true)) { if (isHover && !L.DomEvent._isExternalTarget(src, e)) { break; } targets.push(target); @@ -659,7 +665,7 @@ L.Map = L.Evented.extend({ if (src === this._container) { break; } src = src.parentNode; } - if (!targets.length && !isHover && L.DomEvent._isExternalTarget(src, e)) { + if (!targets.length && !dragging && !isHover && L.DomEvent._isExternalTarget(src, e)) { targets = [this]; } return targets; @@ -699,9 +705,6 @@ L.Map = L.Evented.extend({ L.DomEvent.preventDefault(e); } - // prevents firing click after you just dragged an object - if ((e.type === 'click' || e.type === 'preclick') && !e._simulated && this._draggableMoved(target)) { return; } - var data = { originalEvent: e };