From 7ce4b58dc3c745d76087f07ccd557eaf8ee1ff6c Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Fri, 11 Oct 2024 12:18:39 +0200 Subject: [PATCH] fix bugs and glitches finally --- src/map/map.js | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/map/map.js b/src/map/map.js index 830717a..07d4e33 100644 --- a/src/map/map.js +++ b/src/map/map.js @@ -76,6 +76,7 @@ const sidebarContent = document.getElementById("sidebarContent"); const nodesElement = document.getElementById("nodes"); function dismissPopup(hideMarker) { + console.log('dismissing') if (opened == null) return; const popup = opened[0]; @@ -97,11 +98,17 @@ function dismissPopup(hideMarker) { }, 300); }; +//map.on('popupClose', dismissPopup); sidebarContent.onclick = dismissPopup; function onNodeClick(ev, node, clicked) { console.log('b') - if (opened != null) return; + console.log(opened) + if (opened != null) { + //if (ev instanceof MouseEvent) return; + //dismissPopup(); + return; + } const rect = clicked.getBoundingClientRect(); nodesElement.style.opacity = 0; @@ -126,7 +133,7 @@ function onNodeClick(ev, node, clicked) { sidebarContent.style.backgroundColor = "#111"; opened = [ele, clicked, node]; - ev.stopPropagation(); + console.log("opened") } for (let node of Object.values(nodes)) { @@ -135,14 +142,26 @@ for (let node of Object.values(nodes)) { let ele = document.createElement("div"); ele.innerHTML = `${node.city}`; if (node.description != '') ele.innerHTML += `
${node.description.split('\n')[0]}`; + ele.onclick = (ev) => { marker.openPopup(); map.panTo(node.location, { padding: [1000, 1000], // TODO I could use this to fix the small screen issue duration: 0.3 }); - onNodeClick(ev, node, ele); + //onNodeClick(ev, node, ele); + ev.stopPropagation(); }; + marker.on('popupopen', (ev) => { + console.log(ev) + console.log('popened'); + onNodeClick(ev, node, ele); + }); + marker.on('popupclose', () => { + console.log('closed') + dismissPopup() + }); + nodesElement.appendChild(ele); } @@ -151,6 +170,6 @@ line(de1t, nodes.pl1.location, "de1 - pl1
24ms"); line(de1t, nodes.nl1.location, "de1 - nl1
10ms"); line(nodes.nl1.location, nodes.it1.location, "it1 - nl1
25ms"); -map.on("dragstart", function () { +/*map.on("dragstart", function () { dismissPopup(false); -}); \ No newline at end of file +});*/ \ No newline at end of file