-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
47 lines (40 loc) · 1.12 KB
/
main.js
File metadata and controls
47 lines (40 loc) · 1.12 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
44
45
46
47
// Intersection observer for the navbar
const header = document.querySelector("header");
const section = document.querySelector(".hero-section");
const sectionOptions = {
rootMargin: "-400px 0px 0px 0px",
};
const sectionObserver = new IntersectionObserver(function (
entries,
sectionObserver
) {
entries.forEach((entry) => {
if (!entry.isIntersecting) {
header.classList.add("nav-scrolled");
} else {
header.classList.remove("nav-scrolled");
}
});
},
sectionOptions);
sectionObserver.observe(section);
//scroll to the top
function scrolltop() {
window.scrollTo(0, 0);
}
// menu responsivness
let menu = document.getElementById("menu-bar");
let navbar = document.querySelector(".nav-container");
window.onscroll = function () {
menu.classList.remove("fa-times");
navbar.classList.remove("active");
};
menu.addEventListener("click", function () {
menu.classList.toggle("fa-times");
navbar.classList.toggle("active");
});
// Year updater
var currentYearElement = document.getElementById('currentYear');
if (currentYearElement) {
currentYearElement.innerText = new Date().getFullYear();
}