-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
42 lines (33 loc) · 998 Bytes
/
Copy pathscript.js
File metadata and controls
42 lines (33 loc) · 998 Bytes
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
const toggleButton = document.getElementsByClassName('toggle-button')[0];
const navbarLinks = document.getElementsByClassName('navbar-links')[0];
toggleButton.addEventListener('click', () => {
navbarLinks.classList.toggle('active')
});
navbarLinks.addEventListener('click', () => {
navbarLinks.classList.remove('active')
});
const menu = document.getElementById("menu");
menu.onclick = function(e) {
e.preventDefault();
menu.classList.toggle("open-menu");
}
const navbar = document.querySelector(".navbar");
const hero = document.querySelector(".hero");
const observerOneOptions = {
rootMargin: "-200px 0px 0px 0px"
};
const observerOne = new IntersectionObserver
(function(
entries,
observerOne
) {
entries.forEach(entry => {
if(!entry.isIntersecting) {
navbar.classList.add("nav-scrolled");
} else {
navbar.classList.remove("nav-scrolled");
}
});
},
observerOneOptions);
observerOne.observe(hero);