-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (32 loc) · 872 Bytes
/
script.js
File metadata and controls
37 lines (32 loc) · 872 Bytes
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
34
35
36
37
const images = document.querySelectorAll(".image-tile");
// Add loading animation
window.addEventListener("load", () => {
document.body.classList.add("loaded");
images.forEach((img, index) => {
setTimeout(() => {
img.style.opacity = "0.8";
img.style.transform = "translateY(0)";
}, index * 100);
});
});
images.forEach((img) => {
// Preload images
if (img.complete) {
img.classList.add("loaded");
} else {
img.addEventListener("load", () => {
img.classList.add("loaded");
});
}
img.addEventListener("click", () => {
const wasExpanded = img.classList.contains("expanded");
images.forEach((i) => {
i.classList.remove("expanded");
i.style.filter = "brightness(0.9)";
});
if (!wasExpanded) {
img.classList.add("expanded");
img.style.filter = "brightness(1.2)";
}
});
});