-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript2.js
More file actions
35 lines (28 loc) · 1.12 KB
/
Copy pathscript2.js
File metadata and controls
35 lines (28 loc) · 1.12 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
34
35
"use strict";
const images = document.querySelectorAll(".gallery__second_img");
const openPopUpSec = function () {
const gallerySecImgSrc = this.getAttribute("src");
console.log(gallerySecImgSrc);
document.getElementById("popup_img").src = gallerySecImgSrc;
document.querySelector(".popup").style.visibility = "visible";
document.querySelector(".popup").style.opacity = 1;
document.querySelector(".popup__content").style.opacity = 1;
};
const closePopUpSec = function () {
document.getElementById("popup_img").src = "";
document.querySelector(".popup").style.visibility = "hidden";
document.querySelector(".popup").style.opacity = 0;
document.querySelector(".popup__content").style.opacity = 0;
};
images.forEach((image) => image.addEventListener("click", openPopUpSec));
document
.querySelector(".popup__close")
.addEventListener("click", closePopUpSec);
document.addEventListener("keydown", function (e) {
console.log(e.key);
if (e.key === "Escape" && !document.getElementById("popup_img").src == "") {
console.log("work");
closePopUpSec();
}
});
popup.addEventListener("click", closePopUpSec);