mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 03:42:37 +02:00
fix: fix contextmenu positionning when map is not full screen (#2198)
This commit is contained in:
commit
16f80beffa
6 changed files with 18 additions and 13 deletions
|
@ -1,7 +1,7 @@
|
||||||
.umap-contextmenu {
|
.umap-contextmenu {
|
||||||
background-color: var(--background-color);
|
background-color: var(--background-color);
|
||||||
padding: calc(var(--box-padding) / 2) var(--box-padding);
|
padding: calc(var(--box-padding) / 2) var(--box-padding);
|
||||||
position: absolute;
|
position: fixed;
|
||||||
z-index: var(--zindex-contextmenu);
|
z-index: var(--zindex-contextmenu);
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
box-shadow: var(--block-shadow);
|
box-shadow: var(--block-shadow);
|
||||||
|
|
|
@ -88,10 +88,7 @@ const FeatureMixin = {
|
||||||
DomEvent.stop(event)
|
DomEvent.stop(event)
|
||||||
const items = this._map.getContextMenuItems(event)
|
const items = this._map.getContextMenuItems(event)
|
||||||
items.push('-', ...this.feature.getContextMenuItems(event))
|
items.push('-', ...this.feature.getContextMenuItems(event))
|
||||||
this._map.contextmenu.open(
|
this._map.contextmenu.open(event.originalEvent, items)
|
||||||
[event.originalEvent.clientX, event.originalEvent.clientY],
|
|
||||||
items
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onCommit: function () {
|
onCommit: function () {
|
||||||
|
|
|
@ -64,7 +64,7 @@ export default class TableEditor extends WithTemplate {
|
||||||
action: () => this.deleteProperty(property),
|
action: () => this.deleteProperty(property),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.contextmenu.open([event.clientX, event.clientY], actions)
|
this.contextmenu.open(event, actions)
|
||||||
}
|
}
|
||||||
|
|
||||||
renderHeaders() {
|
renderHeaders() {
|
||||||
|
|
|
@ -15,7 +15,13 @@ export default class ContextMenu extends Positioned {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
open([left, top], items) {
|
open(event, items) {
|
||||||
|
const left = event.clientX
|
||||||
|
const top = event.clientY
|
||||||
|
this.openAt([left, top], items)
|
||||||
|
}
|
||||||
|
|
||||||
|
openAt([left, top], items) {
|
||||||
this.container.innerHTML = ''
|
this.container.innerHTML = ''
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
if (item === '-') {
|
if (item === '-') {
|
||||||
|
@ -36,7 +42,12 @@ export default class ContextMenu extends Positioned {
|
||||||
this.container.appendChild(li)
|
this.container.appendChild(li)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document.body.appendChild(this.container)
|
// When adding contextmenu below the map container, clicking on any link will send the
|
||||||
|
// "focusout" element on link click, preventing to trigger the click action
|
||||||
|
const parent = document
|
||||||
|
.elementFromPoint(left, top)
|
||||||
|
.closest('.leaflet-container').parentNode
|
||||||
|
parent.appendChild(this.container)
|
||||||
if (this.options.fixed) {
|
if (this.options.fixed) {
|
||||||
this.setPosition({ left, top })
|
this.setPosition({ left, top })
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -663,7 +663,7 @@ const ControlsMixin = {
|
||||||
button.addEventListener('click', () => {
|
button.addEventListener('click', () => {
|
||||||
const x = button.offsetLeft
|
const x = button.offsetLeft
|
||||||
const y = button.offsetTop + button.offsetHeight
|
const y = button.offsetTop + button.offsetHeight
|
||||||
menu.open([x, y], actions)
|
menu.openAt([x, y], actions)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.help.getStartedLink(rightContainer)
|
this.help.getStartedLink(rightContainer)
|
||||||
|
|
|
@ -1772,10 +1772,7 @@ U.Map = L.Map.extend({
|
||||||
|
|
||||||
onContextMenu: function (event) {
|
onContextMenu: function (event) {
|
||||||
const items = this.getContextMenuItems(event)
|
const items = this.getContextMenuItems(event)
|
||||||
this.contextmenu.open(
|
this.contextmenu.open(event.originalEvent, items)
|
||||||
[event.originalEvent.clientX, event.originalEvent.clientY],
|
|
||||||
items
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
editInOSM: function (e) {
|
editInOSM: function (e) {
|
||||||
|
|
Loading…
Reference in a new issue