-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
27 lines (23 loc) · 882 Bytes
/
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
const html = document.querySelector("html");
const btnIcon = document.querySelector(".btn-icon");
const body = document.querySelector("body");
const heroSection = document.querySelector(".hero-section");
const header = document.querySelector(".header");
btnIcon.addEventListener("click", (e) => {
if (e.target.getAttribute("name") === "menu-outline") {
e.target.setAttribute("name", "close-outline");
html.classList.add("header__active");
} else {
e.target.setAttribute("name", "menu-outline");
html.classList.remove("header__active");
}
});
function outOfView(entry, observer) {
if (entry[0].isIntersecting) header.classList.remove("header__active-nav");
if (!entry[0].isIntersecting) header.classList.add("header__active-nav");
}
const observer = new IntersectionObserver(outOfView, {
root: null,
threshold: 0,
});
observer.observe(heroSection);