contextmenu, manchmal geht manchmal nicht, Timing Problem
This commit is contained in:
21
utils/polylines/monitorContextMenu.js
Normal file
21
utils/polylines/monitorContextMenu.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// utils/polylines/monitorContextMenu.js
|
||||
import { closePolylineSelectionAndContextMenu } from "./contextMenu";
|
||||
|
||||
export function monitorContextMenu(map) {
|
||||
function checkAndClose() {
|
||||
const isContextMenuExpired = localStorage.getItem("contextMenuExpired") === "true";
|
||||
|
||||
if (isContextMenuExpired) {
|
||||
if (map && map.contextmenu && typeof map.contextmenu.hide === "function") {
|
||||
closePolylineSelectionAndContextMenu(map);
|
||||
localStorage.removeItem("contextMenuExpired");
|
||||
} else {
|
||||
console.warn("Kontextmenü war nicht verfügbar und konnte nicht geschlossen werden.");
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(checkAndClose, 1000); // **Recursive Timeout statt Intervall**
|
||||
}
|
||||
|
||||
checkAndClose();
|
||||
}
|
||||
Reference in New Issue
Block a user