-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
48 lines (40 loc) · 1.6 KB
/
script.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
let bg = document.querySelector("body");
let content = document.querySelector(".content");
window.addEventListener("scroll", () => {
content.style["background-position"] = "0px "+(window.scrollY*0.75)+"px";
});
let bigImage = document.querySelector(".single-big img.front");
let bigImageBack = document.querySelector(".single-big img.back");
function switchImage(img, manualClick = false) {
if (manualClick) {
bigImageBack.src = img.src;
bigImage.src = img.src;
imagIntervalRunning = false;
clearInterval(imageInterval);
} else {
bigImageBack.src = img.src;
bigImage.classList.add("disappearing");
setTimeout(() => {
if (imageIntervalRunning) {
bigImage.src = bigImageBack.src;
bigImage.classList.remove("disappearing");
}
}, 500);
}
}
[...document.querySelectorAll(".single-small .overlay p")].forEach(p => {
p.innerText = p.innerText.slice("/assets/img/slider/".length);
p.innerText = p.innerText.slice(0,p.innerText.length - 4);
p.classList.remove("loading");
});
let imageIndex = 0;
let imageIntervalRunning = true;
let smallImages = [...document.querySelectorAll(".single-small img")];
smallImages[imageIndex].parentNode.classList.add("active");
let imageInterval = setInterval(() => {
imageIndex++;
if (imageIndex >= 3) imageIndex = 0;
if (imageIntervalRunning) switchImage(smallImages[imageIndex]);
document.querySelector(".single-small.active").classList.remove("active");
smallImages[imageIndex].parentNode.classList.add("active");
}, 4000);