This commit is contained in:
James Lyne 2021-05-24 18:24:15 +01:00
parent 025ecf6148
commit 6dfaaabf70

View File

@ -51,7 +51,7 @@ export default defineComponent({
currentZoom = computed(() => store.state.currentZoom), currentZoom = computed(() => store.state.currentZoom),
location = computed(() => { location = computed(() => {
if(!event.value) { if (!event.value) {
return {x: 0, y: 0, z: 0} return {x: 0, y: 0, z: 0}
} }
@ -70,7 +70,7 @@ export default defineComponent({
//Url to copy //Url to copy
url = computed(() => { url = computed(() => {
if(!currentWorld.value || !currentMap.value) { if (!currentWorld.value || !currentMap.value) {
return ''; return '';
} }
@ -81,14 +81,14 @@ export default defineComponent({
}), }),
style = computed(() => { style = computed(() => {
if(!menuElement.value || !event.value) { if (!menuElement.value || !event.value) {
return {}; return {};
} }
//Don't position offscreen //Don't position offscreen
const x = Math.min( const x = Math.min(
window.innerWidth - menuElement.value.offsetWidth - 10, window.innerWidth - menuElement.value.offsetWidth - 10,
event.value.originalEvent.clientX event.value.originalEvent.clientX
), ),
y = Math.min( y = Math.min(
window.innerHeight - menuElement.value.offsetHeight - 10, window.innerHeight - menuElement.value.offsetHeight - 10,
@ -101,7 +101,6 @@ export default defineComponent({
}); });
const handleEsc = (e: KeyboardEvent) => { const handleEsc = (e: KeyboardEvent) => {
console.log(e);
if (e.key === "Escape") { if (e.key === "Escape") {
closeContextMenu(); closeContextMenu();
} }
@ -110,13 +109,13 @@ export default defineComponent({
event.value = null; event.value = null;
}, },
pan = () => { pan = () => {
if(event.value) { if (event.value) {
props.leaflet.panTo(event.value.latlng); props.leaflet.panTo(event.value.latlng);
} }
}; };
watch(menuVisible, visible => { watch(menuVisible, visible => {
if(visible) { if (visible) {
requestAnimationFrame(() => locationButton.value && locationButton.value.focus()); requestAnimationFrame(() => locationButton.value && locationButton.value.focus());
} }
}); });