1111</div >
1212
1313<script >
14-
1514 const popup = document.querySelector(".state-popup") as HTMLElement;
1615 const popupStateName = document.querySelector(".state-popup__name") as HTMLElement;
1716 const popupStateInfo = document.querySelector(".state-popup__info") as HTMLElement;
4544 const clickX = event.pageX;
4645 const clickY = event.pageY;
4746
48- let left = clickX - ( popupWidth / 2) ;
49- let top = clickY - ( popupHeight / 2) ;
47+ let left = clickX - popupWidth / 2;
48+ let top = clickY - popupHeight / 2;
5049
5150 if (left + popupWidth > viewportWidth + scrollX - 20) {
52- left = viewportWidth + scrollX - popupWidth - 20;
51+ left = viewportWidth + scrollX - popupWidth - 20;
5352 }
5453 if (left < scrollX + 20) {
55- left = scrollX + 20;
54+ left = scrollX + 20;
5655 }
5756
5857 if (top + popupHeight > viewportHeight + scrollY - 20) {
59- top = clickY - popupHeight - 20;
58+ top = clickY - popupHeight - 20;
6059 }
6160 if (top < scrollY + 20) {
62- top = scrollY + 20;
61+ top = scrollY + 20;
6362 }
6463
6564 popup.style.left = `${left}px`;
6665 popup.style.top = `${top}px`;
67-
6866
6967 requestAnimationFrame(() => {
70- popup.style.opacity = "1";
68+ popup.style.opacity = "1";
7169 });
72- }
73-
70+ }
7471
75- document.addEventListener("showStatePopup", ((e: CustomEvent) => {
72+ document.addEventListener("showStatePopup", ((e: CustomEvent) => {
7673 const { event, stateInfo } = e.detail;
7774 showPopup(event, stateInfo);
78- }) as EventListener);
75+ }) as EventListener);
7976
8077 closePopup?.addEventListener("click", () => {
8178 popup.style.display = "none";
@@ -102,7 +99,7 @@ document.addEventListener("showStatePopup", ((e: CustomEvent) => {
10299 const stateName = popupStateName.textContent;
103100 if (stateName) {
104101 const stateUrl = stateName.replace(/\s+/g, "").toLowerCase();
105- window.location.href = `/mapPages /${stateUrl}`;
102+ window.location.href = `/map /${stateUrl}`;
106103 }
107104 });
108105
0 commit comments