Merge pull request #4010 from Leaflet/dragend-click

Fix event target fallbacking to map after marker drag (fix #3971)
This commit is contained in:
Iván Sánchez Ortega 2016-01-08 13:43:11 +01:00
commit 88fa86a692

View File

@ -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);
@ -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;
@ -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
};