Move 'preclick' event handling around so it propagates before 'click'.
This commit is contained in:
parent
0d3448d494
commit
d1864cd138
@ -644,12 +644,19 @@ L.Map = L.Evented.extend({
|
|||||||
var target = this._findEventTarget(e.target || e.srcElement),
|
var target = this._findEventTarget(e.target || e.srcElement),
|
||||||
type = e.type === 'keypress' && e.keyCode === 13 ? 'click' : e.type;
|
type = e.type === 'keypress' && e.keyCode === 13 ? 'click' : e.type;
|
||||||
|
|
||||||
|
if (e.type === 'click') {
|
||||||
|
// Fire a synthetic 'preclick' event which propagates up (mainly for closing popups).
|
||||||
|
var synth = L.Util.extend({}, e);
|
||||||
|
synth.type = 'preclick';
|
||||||
|
this._handleDOMEvent(synth);
|
||||||
|
}
|
||||||
|
|
||||||
// special case for map mouseover/mouseout events so that they're actually mouseenter/mouseleave
|
// special case for map mouseover/mouseout events so that they're actually mouseenter/mouseleave
|
||||||
if (!target && (type === 'mouseover' || type === 'mouseout') &&
|
if (!target && (type === 'mouseover' || type === 'mouseout') &&
|
||||||
!L.DomEvent._checkMouse(this._container, e)) { return; }
|
!L.DomEvent._checkMouse(this._container, e)) { return; }
|
||||||
|
|
||||||
// prevents outline when clicking on keyboard-focusable element
|
|
||||||
if (type === 'mousedown') {
|
if (type === 'mousedown') {
|
||||||
|
// prevents outline when clicking on keyboard-focusable element
|
||||||
L.DomUtil.preventOutline(e.target || e.srcElement);
|
L.DomUtil.preventOutline(e.target || e.srcElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -663,7 +670,7 @@ L.Map = L.Evented.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_fireDOMEvent: function (target, e, type) {
|
_fireDOMEvent: function (target, e, type) {
|
||||||
if (!target.listens(type, true) && (type !== 'click' || !target.listens('preclick', true))) { return; }
|
if (!target.listens(type, true)) { return; }
|
||||||
|
|
||||||
if (type === 'contextmenu') {
|
if (type === 'contextmenu') {
|
||||||
L.DomEvent.preventDefault(e);
|
L.DomEvent.preventDefault(e);
|
||||||
@ -681,9 +688,6 @@ L.Map = L.Evented.extend({
|
|||||||
data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
|
data.layerPoint = this.containerPointToLayerPoint(data.containerPoint);
|
||||||
data.latlng = this.layerPointToLatLng(data.layerPoint);
|
data.latlng = this.layerPointToLatLng(data.layerPoint);
|
||||||
}
|
}
|
||||||
if (type === 'click') {
|
|
||||||
target.fire('preclick', data, true);
|
|
||||||
}
|
|
||||||
target.fire(type, data, true);
|
target.fire(type, data, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user