Layer add/removeInteractiveTarget methods
registers DOM elements for event delegation
This commit is contained in:
parent
4c8ffadf30
commit
b149f2d754
@ -25,6 +25,16 @@ L.Layer = L.Evented.extend({
|
|||||||
return this._map.getPane(name ? (this.options[name] || name) : this.options.pane);
|
return this._map.getPane(name ? (this.options[name] || name) : this.options.pane);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addInteractiveTarget: function (targetEl) {
|
||||||
|
this._map._targets[L.stamp(targetEl)] = this;
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
removeInteractiveTarget: function (targetEl) {
|
||||||
|
delete this._map._targets[L.stamp(targetEl)];
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
_layerAdd: function (e) {
|
_layerAdd: function (e) {
|
||||||
var map = e.target;
|
var map = e.target;
|
||||||
|
|
||||||
|
@ -557,6 +557,8 @@ L.Map = L.Evented.extend({
|
|||||||
'click dblclick mousedown mouseup mouseenter mouseleave mousemove contextmenu',
|
'click dblclick mousedown mouseup mouseenter mouseleave mousemove contextmenu',
|
||||||
this._handleMouseEvent, this);
|
this._handleMouseEvent, this);
|
||||||
|
|
||||||
|
this._targets = {};
|
||||||
|
|
||||||
if (this.options.trackResize) {
|
if (this.options.trackResize) {
|
||||||
L.DomEvent[onOff](window, 'resize', this._onResize, this);
|
L.DomEvent[onOff](window, 'resize', this._onResize, this);
|
||||||
}
|
}
|
||||||
@ -571,9 +573,11 @@ L.Map = L.Evented.extend({
|
|||||||
_handleMouseEvent: function (e) {
|
_handleMouseEvent: function (e) {
|
||||||
if (!this._loaded) { return; }
|
if (!this._loaded) { return; }
|
||||||
|
|
||||||
this._fireMouseEvent(this, e,
|
var target = this._targets[L.stamp(e.target || e.srcElement)];
|
||||||
|
|
||||||
|
this._fireMouseEvent(target || this, e,
|
||||||
e.type === 'mouseenter' ? 'mouseover' :
|
e.type === 'mouseenter' ? 'mouseover' :
|
||||||
e.type === 'mouseleave' ? 'mouseout' : e.type);
|
e.type === 'mouseleave' ? 'mouseout' : e.type, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
_fireMouseEvent: function (obj, e, type, propagate, latlng) {
|
_fireMouseEvent: function (obj, e, type, propagate, latlng) {
|
||||||
|
Loading…
Reference in New Issue
Block a user