From 22c97d1b3356a34cd9df1381ca778388de46f2e7 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Mon, 17 Nov 2014 15:06:48 +0200 Subject: [PATCH] use new event delegation API in ImageOverlay --- src/layer/ImageOverlay.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/layer/ImageOverlay.js b/src/layer/ImageOverlay.js index 5862e965..fdd80496 100644 --- a/src/layer/ImageOverlay.js +++ b/src/layer/ImageOverlay.js @@ -26,13 +26,20 @@ L.ImageOverlay = L.Layer.extend({ } } + if (this.options.interactive) { + L.DomUtil.addClass(this._image, 'leaflet-interactive'); + this.addInteractiveTarget(this._image); + } + this.getPane().appendChild(this._image); - this._initInteraction(); this._reset(); }, onRemove: function () { L.DomUtil.remove(this._image); + if (this.options.interactive) { + this.removeInteractiveTarget(this._image); + } }, setOpacity: function (opacity) { @@ -65,19 +72,6 @@ L.ImageOverlay = L.Layer.extend({ return this; }, - _initInteraction: function () { - if (!this.options.interactive) { return; } - L.DomUtil.addClass(this._image, 'leaflet-interactive'); - L.DomEvent.on(this._image, 'click dblclick mousedown mouseup mouseover mousemove mouseout contextmenu', - this._fireMouseEvent, this); - }, - - _fireMouseEvent: function (e, type) { - if (this._map) { - this._map._fireMouseEvent(this, e, type, true); - } - }, - setUrl: function (url) { this._url = url;