feat: add lightbox for viewing forest and reward images fullscreen
- Click any forest element or reward image to see it large - Smooth zoom-in animation, click anywhere to close - Hover effect on clickable images - Works on both forest grid and reward screen Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+23
@@ -64,4 +64,27 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
};
|
||||
document.addEventListener("click", initAudioOnce);
|
||||
document.addEventListener("keydown", initAudioOnce);
|
||||
|
||||
// Lightbox: click on forest/reward images to view fullscreen
|
||||
const lightbox = document.getElementById("image-lightbox")!;
|
||||
const lightboxImg = document.getElementById("lightbox-img") as HTMLImageElement;
|
||||
|
||||
document.addEventListener("click", (e) => {
|
||||
const target = e.target as HTMLElement;
|
||||
// Open lightbox when clicking forest element or reward image
|
||||
if (
|
||||
(target.tagName === "IMG" && target.closest(".forest__element")) ||
|
||||
(target.tagName === "IMG" && target.closest(".reward__image-area"))
|
||||
) {
|
||||
lightboxImg.src = (target as HTMLImageElement).src;
|
||||
lightboxImg.alt = (target as HTMLImageElement).alt;
|
||||
lightbox.style.display = "flex";
|
||||
}
|
||||
});
|
||||
|
||||
// Close lightbox on click
|
||||
lightbox.addEventListener("click", () => {
|
||||
lightbox.style.display = "none";
|
||||
lightboxImg.src = "";
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user