-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathscript.ts
More file actions
27 lines (21 loc) · 761 Bytes
/
script.ts
File metadata and controls
27 lines (21 loc) · 761 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
const mob = window.innerWidth <= 800 && window.innerHeight <= 600;
const modal = document.getElementById('modal')!;
modal.addEventListener("click", event => {
if(event.target == modal)
modal.style.display='none'
})
const modalImg = document.getElementById("modalimg")! as HTMLImageElement;
const images = document.getElementsByClassName("zoomer") as HTMLCollectionOf<HTMLImageElement>;
for (const img of images) {
if(!mob) {
img.addEventListener("click", () => {
modal.style.display = "block";
modalImg.src = img.src;
modalImg.alt = img.alt;
})
}
}
const span = document.getElementsByClassName("close")[0];
span.addEventListener("click", () => {
modal.style.display = "none";
})