-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
103 lines (91 loc) · 2.57 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
scrollAnimation();
const changeImages = (idOfParent) => {
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
return;
}
const imagesDivs = document.querySelectorAll(
`#${idOfParent} .img-container img`
);
let counter = 1;
let resetCounter = 0;
for (let i = imagesDivs.length - 1; i >= 0; i--) {
let delay = counter * 3000;
if (i <= 0) {
if (resetCounter > 50) {
continue;
}
resetCounter++;
i = imagesDivs.length - 1;
setTimeout(() => {
imagesDivs[0].style.opacity = 0;
}, delay - 100);
}
setTimeout(() => {
imagesDivs[i].style.opacity = "0";
}, delay - 100);
setTimeout(() => {
imagesDivs[i - 1].style.opacity = "1";
}, delay);
setTimeout(() => {
imagesDivs[i].style.opacity = "0";
}, delay + 100);
counter++;
}
};
const portfolioTelevision = document.querySelector("#television");
const observerThreshold =
window.innerHeight <= portfolioTelevision.offsetHeight / 2 ? 0.2 : 0.5;
const animationObserver = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("animation-start");
}
});
},
{ root: null, rootMargin: "0px", threshold: observerThreshold }
);
animationObserver.observe(portfolioTelevision);
portfolioTelevision.addEventListener("click", () => {
window.location.href = "./portfolio";
});
changeImages("television");
const acImgContent = document.querySelectorAll("#ac-art .img-container");
acImgContent.forEach((container) => {
container.addEventListener("click", () => {
const id = container.id;
switch (id) {
case "model":
window.location.href = "./ac-art#dress";
break;
case "byt":
window.location.href = "./ac-art/bytovy-design";
break;
case "moda":
window.location.href = "./ac-art/modni-doplnky";
break;
case "barvy":
window.location.href = "./ac-art/v-zajeti-barev";
break;
}
});
});
const publikaceImgContent = document.querySelectorAll(
"#publikace .img-container"
);
publikaceImgContent.forEach((container) => {
container.addEventListener("click", () => {
const id = container.id;
switch (id) {
case "fashion":
window.location.href = "./media/publikace/ac-art-fashion-katalog.pdf";
break;
case "cesta":
window.location.href = "./publikace";
break;
case "invence":
window.location.href = "./media/publikace/invence-katalog.pdf";
break;
}
});
});