-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
38 lines (33 loc) · 1.19 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
const imageContainer = document.querySelector(".image-container");
//* On Click events, to let the browser know to scroll to the next image
const chevronLeft = document.querySelector(".chevron-left");
const chevronRight = document.querySelector(".chevron-right");
chevronRight.addEventListener("click", (e) => {
imageContainer.scrollLeft += imageContainer.clientWidth;
});
chevronLeft.addEventListener("click", (e) => {
imageContainer.scrollLeft -= imageContainer.clientWidth;
});
//* This is an observer, it will add a class of "show" to the element when it is in view
//* And the CSS will animate it in
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("show");
}
// Remove transition delay from social icons after their inital animation
if (entry.target.classList.contains("footer-social")) {
setTimeout(() => {
document
.querySelectorAll(".footer-social ul li")
.forEach((li) => {
li.style.transitionDelay = "0s";
});
}, 1000);
}
});
});
const hiddenElements = document.querySelectorAll(".hidden");
hiddenElements.forEach((element) => {
observer.observe(element);
});