-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
44 lines (35 loc) · 1.23 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
import "./style.scss";
// getting the elements affected by the header menu clicking
const drawerMenu = document.querySelector(".drawer-menu");
const menuButton = document.querySelector(".menu-button");
const closeButton = document.querySelector(".close-button");
function OpenDrawerMenu() {
drawerMenu.style.transform = "translateY(0%)";
}
function closeDrawerMenu() {
drawerMenu.style.transform = "translateY(-100%)";
}
menuButton.addEventListener("click", OpenDrawerMenu);
closeButton.addEventListener("click", closeDrawerMenu);
const the_animation_left = document.querySelectorAll(".animation-left");
const the_animation_right = document.querySelectorAll(".animation-right");
export const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("scroll-animation");
} else {
entry.target.classList.remove("scroll-animation");
}
});
},
{ threshold: 0.2 }
);
for (let i = 0; i < the_animation_left.length; i++) {
const elements = the_animation_left[i];
observer.observe(elements);
}
for (let i = 0; i < the_animation_right.length; i++) {
const elements = the_animation_right[i];
observer.observe(elements);
}