Skip to content

Commit 230a79c

Browse files
committed
💄 ui improvements
1 parent d50c01c commit 230a79c

File tree

2 files changed

+405
-32
lines changed

2 files changed

+405
-32
lines changed

assets/scripts.js

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ if (volumeSlider)
3131
localStorage.setItem("vol", e.target.value);
3232
});
3333

34+
// Gestion du volume sur mobile
35+
const volumeControl = document.querySelector('.volume-control');
36+
if (volumeControl && 'ontouchstart' in window) {
37+
volumeControl.addEventListener('click', (e) => {
38+
if (e.target === volumeControl || e.target === volumeIcon) {
39+
volumeControl.classList.toggle('active');
40+
}
41+
});
42+
}
43+
3444
/* =========================
3545
MAP / ZOOM
3646
========================= */
@@ -58,7 +68,6 @@ function zoomToRegion(regionEl) {
5868
const bbox = regionEl.getBBox();
5969
const { scale, tx, ty } = computeZoomToBBox(bbox);
6070
panzoom.style.transform = `translate(${tx}px, ${ty}px) scale(${scale})`;
61-
// Reveal island info AFTER the zoom finishes
6271
setTimeout(() => {
6372
regionEl.classList.add("active");
6473
activeRegion = regionEl;
@@ -71,23 +80,56 @@ function resetZoom() {
7180
if (activeRegion) activeRegion.classList.remove("active");
7281
activeRegion = null;
7382
backBtn.classList.remove("show");
83+
closeInfoPanel();
7484
}
7585

76-
/* Enable: clicking island zooms + reveals in-island info (About/Contact);
77-
Projects also zooms, and only then cities become clickable */
86+
const infoPanel = document.getElementById("info-panel");
87+
const panelTitle = document.getElementById("panel-title");
88+
const panelClose = document.getElementById("panel-close");
89+
const aboutContent = document.getElementById("about-content");
90+
const contactContent = document.getElementById("contact-content");
91+
92+
function openInfoPanel(regionKey, title) {
93+
panelTitle.textContent = title;
94+
95+
aboutContent.style.display = "none";
96+
contactContent.style.display = "none";
97+
98+
if (regionKey === "about") {
99+
aboutContent.style.display = "block";
100+
} else if (regionKey === "contact") {
101+
contactContent.style.display = "block";
102+
}
103+
104+
infoPanel.classList.add("open");
105+
}
106+
107+
function closeInfoPanel() {
108+
infoPanel.classList.remove("open");
109+
}
110+
111+
panelClose.addEventListener("click", closeInfoPanel);
112+
78113
document.querySelectorAll(".region").forEach((region) => {
79114
region.addEventListener("click", () => {
80-
// If already active -> do nothing (let Back handle zoom out)
81115
if (activeRegion === region) return;
82-
// Reset current active region first
83116
if (activeRegion) {
84117
activeRegion.classList.remove("active");
85118
}
119+
120+
closeInfoPanel();
121+
closeModal();
122+
86123
zoomToRegion(region);
124+
125+
if (region.classList.contains("panel-region")) {
126+
setTimeout(() => {
127+
openInfoPanel(region.dataset.key, region.dataset.title);
128+
}, 700);
129+
}
87130
});
88131
});
89132

90-
/* Cities: only clickable when Projects island is the active region */
91133
const modal = document.getElementById("modal");
92134
const modalTitle = document.getElementById("modal-title");
93135
const modalBody = document.getElementById("modal-body");
@@ -112,7 +154,6 @@ document.querySelectorAll(".city").forEach((city) => {
112154

113155
modalClose.addEventListener("click", closeModal);
114156

115-
/* Global handlers */
116157
backBtn.addEventListener("click", () => {
117158
closeModal();
118159
resetZoom();

0 commit comments

Comments
 (0)