-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (29 loc) · 1.03 KB
/
script.js
File metadata and controls
33 lines (29 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const yearTarget = document.querySelector("#year");
if (yearTarget) {
yearTarget.textContent = new Date().getFullYear();
}
const modal = document.querySelector("#shot-modal");
const modalImage = document.querySelector("#shot-modal-image");
const modalTitle = document.querySelector("#shot-modal-title");
const shotCards = document.querySelectorAll("[data-shot]");
if (modal && modalImage && modalTitle && shotCards.length) {
shotCards.forEach((card) => {
card.addEventListener("click", () => {
modalImage.src = card.dataset.shot;
modalImage.alt = card.dataset.title || "Screenshot do Sushi Stack";
modalTitle.textContent = card.dataset.title || "";
modal.showModal();
});
});
modal.addEventListener("click", (event) => {
const bounds = modal.getBoundingClientRect();
const clickedOutside =
event.clientX < bounds.left ||
event.clientX > bounds.right ||
event.clientY < bounds.top ||
event.clientY > bounds.bottom;
if (clickedOutside) {
modal.close();
}
});
}