-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (33 loc) · 1.11 KB
/
index.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
// Navigation Menu
const navSlide = () => {
const burger = document.querySelector('.nav-icon');
const nav = document.querySelector('.nav-links');
const navLinks = document.querySelectorAll('.nav-links li');
burger.addEventListener('click', () => {
// Toggle Nav
nav.classList.toggle('active');
// Animate Links
navLinks.forEach((link, index) => {
if (link.style.animation) {
link.style.animation = '';
} else {
link.style.animation = `navLinkFade 0.5s ease forwards ${index / 7 + 0.5}s`;
}
});
// Burger Animation
burger.classList.toggle('toggle');
});
};
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("home").style.top = "0";
document.getElementById("home").style.backgroundColor = "black";
document.getElementById("home").style.colour = "white";
} else {
document.getElementById("home").style.top = "-70px";
}
prevScrollpos = currentScrollPos;
}
navSlide();