-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
49 lines (48 loc) · 1.53 KB
/
main.js
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
38
39
40
41
42
43
44
45
46
47
48
49
let picSrc = [
"assets/pics/Lito.webp",
"assets/pics/Kala.jpg",
"assets/pics/Capheus.jpg",
"assets/pics/Nomi.jpg",
"assets/pics/Riley.webp",
"assets/pics/Sun.jpg",
"assets/pics/Wolfgang.jpg",
"assets/pics/Will.jpg",
"assets/pics/all.jpg",
];
function changePic() {
picSrc.forEach((el) => {
let dontTakeLast = picSrc.indexOf(el) == picSrc.indexOf(picSrc.at(-1));
if (dontTakeLast) return;
let topDiv = document.querySelector(".wrapper__top");
let topDivP = document.querySelector(".wrapper__top img");
let b = document.querySelector(".wrapper__bottom");
let wrapperBottomPics = document.createElement("div");
wrapperBottomPics.classList.add("wrapper__bottom__pics");
let p = document.createElement("img");
p.src = el;
wrapperBottomPics.append(p);
b.append(wrapperBottomPics);
wrapperBottomPics.addEventListener("mouseover", () => {
topDiv.innerHTML = wrapperBottomPics.innerHTML;
let topDivP = document.querySelector(".wrapper__top img");
topDivP.setAttribute(
"style",
"width: 600px;height: 280px;border-radius: 8px;"
);
wrapperBottomPics.setAttribute(
"style",
"transform: scale(0.9);transition: linear 0.5s;"
);
});
wrapperBottomPics.addEventListener("mouseout", () => {
wrapperBottomPics.setAttribute(
"style",
"transform: scale(1);transition: linear 0.5s;"
);
topDivP.src = `${picSrc.at(-1)}`;
topDiv.innerHTML = "";
topDiv.append(topDivP);
});
});
}
changePic();