move higlight() into Marker class
options.icon pointer is invalid after hide() show() cycle.
This commit is contained in:
parent
5778c4ff65
commit
88746d593c
2 changed files with 10 additions and 11 deletions
|
@ -549,6 +549,14 @@ L.U.Marker = L.Marker.extend({
|
|||
this.setIcon(this.getIcon())
|
||||
},
|
||||
|
||||
highlight: function () {
|
||||
L.DomUtil.addClass(this.options.icon.elements.main, 'umap-icon-active')
|
||||
},
|
||||
|
||||
resetHighlight: function () {
|
||||
L.DomUtil.removeClass(this.options.icon.elements.main, 'umap-icon-active')
|
||||
},
|
||||
|
||||
addInteractions: function () {
|
||||
L.U.FeatureMixin.addInteractions.call(this)
|
||||
this.on(
|
||||
|
@ -562,10 +570,8 @@ L.U.Marker = L.Marker.extend({
|
|||
if (!this.isReadOnly()) this.on('mouseover', this._enableDragging)
|
||||
this.on('mouseout', this._onMouseOut)
|
||||
this._popupHandlersAdded = true // prevent Leaflet from binding event on bindPopup
|
||||
this.once('add', () => {
|
||||
this.on('popupopen', this.options.icon.highlight, this.options.icon)
|
||||
this.on('popupclose', this.options.icon.resetHighlight, this.options.icon)
|
||||
})
|
||||
this.on('popupopen', this.highlight)
|
||||
this.on('popupclose', this.resetHighlight)
|
||||
},
|
||||
|
||||
hasGeom: function () {
|
||||
|
|
|
@ -38,13 +38,6 @@ L.U.Icon = L.DivIcon.extend({
|
|||
formatUrl: function (url, feature) {
|
||||
return L.Util.greedyTemplate(url || '', feature ? feature.extendedProperties() : {})
|
||||
},
|
||||
|
||||
highlight: function () {
|
||||
L.DomUtil.addClass(this.elements.main, 'umap-icon-active')
|
||||
},
|
||||
resetHighlight: function () {
|
||||
L.DomUtil.removeClass(this.elements.main, 'umap-icon-active')
|
||||
},
|
||||
})
|
||||
|
||||
L.U.Icon.Default = L.U.Icon.extend({
|
||||
|
|
Loading…
Reference in a new issue