forked from waverly2004/portfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs
More file actions
43 lines (35 loc) · 1.35 KB
/
Copy pathjs
File metadata and controls
43 lines (35 loc) · 1.35 KB
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
const hamburger = document.querySelector(".hamburger");
const navMenu = document.querySelector(".link-list");
hamburger.addEventListener("click", () => {
hamburger.classList.toggle("hamburger_active");
navMenu.classList.toggle("link-list_active");
});
document.querySelectorAll(".nav-item").forEach(n => n.addEventListener("click",() => {
hamburger.classList.remove("hamburger_active");
navMenu.classList.remove("link-list_active");
}))
const navHome = document.querySelector(".nav-home");
const navWork = document.querySelector(".nav-work");
const homeSection = document.querySelector("#home");
const homeOptions = {
rootMargin: "-35px 0px 0px 0px"
}
const homeObserver = new IntersectionObserver(function(
entries, homeObserver
) { entries.forEach(entry => {
if (!entry.isIntersecting) {
navHome.classList.remove("underlined");
navHome.classList.add("underline");
navWork.classList.remove("underline");
navWork.classList.add("underlined");
}
else {
navHome.classList.remove("underline");
navHome.classList.add("underlined");
navWork.classList.remove("underlined");
navWork.classList.add("underline");
}
});
},
homeOptions);
homeObserver.observe(homeSection);