-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
52 lines (45 loc) · 1.28 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// header scrolling effect
/*$(window).on("scroll", function () {
if ($(window).scrollTop()) {
$("header").addClass("nav-show");
} else {
$("header").removeClass("nav-show");
}
});*/
let scroll_position = 0;
let scrollingUp;
let header = document.getElementById("header");
window.addEventListener("scroll", (e) => {
scrollingUp =
document.body.getBoundingClientRect().top > scroll_position ? false : true;
scroll_position = document.body.getBoundingClientRect().top;
if (scrollingUp) {
header.classList.add("nav-show");
} else {
if (header.classList) {
header.classList.remove("nav-show");
}
}
});
//hamburger
const navSlide = () => {
const hamburger = document.querySelector(".hamburger");
const navbar = document.querySelector(".nav-bar");
const navLinks = document.querySelectorAll(".nav-bar li");
hamburger.onclick = () => {
navbar.classList.toggle("nav-active");
//Animation links
navLinks.forEach((link, index) => {
if (link.style.animation) {
link.style.animation = "";
} else {
link.style.animation = `navLinkFade 0.5s ease forwards ${
index / 7 + 1
}s`;
}
});
//hamburger animation
hamburger.classList.toggle("toggle");
};
};
window.onload = () => navSlide();