Skip to content

Commit

Permalink
#422 Removed event blocking popup functions (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman authored Sep 5, 2023
1 parent d8d6350 commit 2f421aa
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/css/mmgis.css
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ body {
white-space: nowrap;
user-select: none;
cursor: pointer;
user-select: none;
transition: all 0.2s cubic-bezier(0.445, 0.05, 0.55, 0.95),
transform 0s ease-in-out;
}
Expand Down
42 changes: 42 additions & 0 deletions src/essence/Basics/Layers_/Layers_.js
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,8 @@ const L_ = {
closeOnClick: false,
autoPan: false,
offset: new L.point(0, 3),
interactive: true,
bubblingMouseEvents: true
})
.setLatLng(
new L.LatLng(
Expand All @@ -1371,6 +1373,11 @@ const L_ = {
'</div>'
)

if (popup?._contentNode?._leaflet_events)
Object.keys(popup._contentNode._leaflet_events).forEach((ev) => {
delete popup._contentNode._leaflet_events[ev]
})

popup._isAnnotation = true
popup._annotationParams = {
feature,
Expand All @@ -1386,13 +1393,48 @@ const L_ = {
popup.toGeoJSON = function () {
return feature
}

if (andAddToMap) {
popup.addTo(L_.Map_.map)
L_.removePopupStopPropogationFunctions(popup)
L_.layers.layer[layerId].push(popup)
} else {
setTimeout(() => {
L_.removePopupStopPropogationFunctions(popup)
}, 2000)
}

return popup
},
removePopupStopPropogationFunctions(popup) {
if (popup?._contentNode?._leaflet_events)
Object.keys(popup._contentNode._leaflet_events).forEach((ev) => {
document
.querySelectorAll('.leaflet-popup-content')
.forEach(function (elm) {
// Now do something with my button
elm.removeEventListener(
'wheel',
popup._contentNode._leaflet_events[ev]
)
})
})

if (popup?._container?.children?.[0]?._leaflet_events)
Object.keys(popup._container.children[0]._leaflet_events).forEach(
(ev) => {
document
.querySelectorAll('.leaflet-popup-content-wrapper')
.forEach(function (elm) {
// Now do something with my button
elm.removeEventListener(
ev.replace(/\d+$/, ''),
popup._container.children[0]._leaflet_events[ev]
)
})
}
)
},
setLayerOpacity: function (name, newOpacity) {
newOpacity = parseFloat(newOpacity)
if (L_.Globe_) L_.Globe_.litho.setLayerOpacity(name, newOpacity)
Expand Down
28 changes: 16 additions & 12 deletions src/essence/Tools/Draw/DrawTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -1361,18 +1361,22 @@ var DrawTool = {
$(
`#drawToolShapeLiItem_DrawTool_${fileId}_${index}`
).removeClass('temporallyHidden')
if (l.temporallyHidden) {
l.setStyle({
opacity: 0,
fillOpacity: 0,
})
if (l._path?.style) l._path.style.pointerEvents = 'none'
} else if (l.savedOptions) {
l.setStyle({
opacity: l.savedOptions.opacity,
fillOpacity: l.savedOptions.fillOpacity,
})
if (l._path?.style) l._path.style.pointerEvents = 'all'
if (l.setStyle) {
if (l.temporallyHidden) {
l.setStyle({
opacity: 0,
fillOpacity: 0,
})
if (l._path?.style)
l._path.style.pointerEvents = 'none'
} else if (l.savedOptions) {
l.setStyle({
opacity: l.savedOptions.opacity,
fillOpacity: l.savedOptions.fillOpacity,
})
if (l._path?.style)
l._path.style.pointerEvents = 'all'
}
}
}
})
Expand Down

0 comments on commit 2f421aa

Please sign in to comment.