fix bugs and glitches

finally
This commit is contained in:
Minecon724 2024-10-11 12:18:39 +02:00
parent 35ca8414e3
commit 7ce4b58dc3
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8

View file

@ -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 = `<strong>${node.city}</strong>`;
if (node.description != '') ele.innerHTML += `<br><small>${node.description.split('\n')[0]}</small>`;
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<br><strong>24ms</strong>");
line(de1t, nodes.nl1.location, "de1 - nl1<br><strong>10ms</strong>");
line(nodes.nl1.location, nodes.it1.location, "it1 - nl1<br><strong>25ms</strong>");
map.on("dragstart", function () {
/*map.on("dragstart", function () {
dismissPopup(false);
});
});*/