Skip to content

Commit

Permalink
Merge pull request #4010 from Leaflet/dragend-click
Browse files Browse the repository at this point in the history
Fix event target fallbacking to map after marker drag (fix #3971)
  • Loading branch information
IvanSanchez committed Jan 8, 2016
2 parents 6a28329 + 64484d5 commit 88fa86a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,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);
Expand All @@ -660,7 +666,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;
Expand Down Expand Up @@ -700,9 +706,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
};
Expand Down

0 comments on commit 88fa86a

Please sign in to comment.