add Marker contextmenu event
This commit is contained in:
parent
eba4eb0a5c
commit
91aecd376b
@ -179,12 +179,13 @@ L.Marker = L.Class.extend({
|
||||
},
|
||||
|
||||
_initInteraction: function () {
|
||||
if (!this.options.clickable) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.options.clickable) { return; }
|
||||
|
||||
// TODO refactor into something shared with Map/Path/etc. to DRY it up
|
||||
|
||||
var icon = this._icon,
|
||||
events = ['dblclick', 'mousedown', 'mouseover', 'mouseout'];
|
||||
events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu'];
|
||||
|
||||
L.DomUtil.addClass(icon, 'leaflet-clickable');
|
||||
L.DomEvent.on(icon, 'click', this._onMouseClick, this);
|
||||
@ -204,20 +205,31 @@ L.Marker = L.Class.extend({
|
||||
|
||||
_onMouseClick: function (e) {
|
||||
var wasDragged = this.dragging && this.dragging.moved();
|
||||
|
||||
if (this.hasEventListeners(e.type) || wasDragged) {
|
||||
L.DomEvent.stopPropagation(e);
|
||||
}
|
||||
|
||||
if (wasDragged) { return; }
|
||||
|
||||
if (this._map.dragging && this._map.dragging.moved()) { return; }
|
||||
|
||||
this.fire(e.type, {
|
||||
originalEvent: e
|
||||
});
|
||||
},
|
||||
|
||||
_fireMouseEvent: function (e) {
|
||||
|
||||
this.fire(e.type, {
|
||||
originalEvent: e
|
||||
});
|
||||
|
||||
// TODO proper custom event propagation
|
||||
// this line will always be called if marker is in a FeatureGroup
|
||||
if (e.type === 'contextmenu' && this.hasEventListeners(e.type)) {
|
||||
L.DomEvent.preventDefault(e);
|
||||
}
|
||||
if (e.type !== 'mousedown') {
|
||||
L.DomEvent.stopPropagation(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user