Skip to content

Commit

Permalink
Fix event target fallbacking to map after marker drag (fix #3971)
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanboniface committed Nov 11, 2015
1 parent c2a3dc9 commit 8a3506a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -668,7 +674,7 @@ L.Map = L.Evented.extend({
_handleDOMEvent: function (e) {
if (!this._loaded || L.DomEvent._skipped(e)) { return; }

// find the layer the event is propagating from and its parents
// Find the layer the event is propagating from and its parents.
var type = e.type === 'keypress' && e.keyCode === 13 ? 'click' : e.type;

if (e.type === 'click') {
Expand Down Expand Up @@ -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
};
Expand Down

0 comments on commit 8a3506a

Please sign in to comment.