-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnavbar.js
53 lines (48 loc) · 2.13 KB
/
navbar.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
53
let menu_links = document.querySelector('.menu .links');
function styleNavbar() {
if (this.document.querySelector('.navbar').classList.contains('activated')) {
this.document.querySelector('.navbar').style.background = 'white';
this.document.querySelector('.navbar').style.backdropFilter = 'none';
this.document.querySelector('.menu-icon').style.background = '#6A6BF4';
}
else {
if (this.window.scrollY > 20) {
this.document.querySelector('.navbar').style.background = 'rgba(255,255,255,0.4)';
this.document.querySelector('.navbar').style.backdropFilter = 'blur(40px)';
this.document.querySelector('.menu-icon').style.background = '#6A6BF4';
}
else {
if (this.document.querySelector('.navbar').classList.contains('bg-nav')) {
this.document.querySelector('.navbar').style.background = 'rgba(255,255,255,0.4)';
this.document.querySelector('.navbar').style.backdropFilter = 'blur(40px)';
}
else {
this.document.querySelector('.navbar').style.background = 'none';
this.document.querySelector('.navbar').style.backdropFilter = 'none';
this.document.querySelector('.menu-icon').style.background = 'rgba(255,255,255,0.4)';
this.document.querySelector('.menu-icon').style.backdropFilter = 'blur(40px)';
}
}
}
}
window.addEventListener('scroll', function() {
styleNavbar();
})
function toggleMenu() {
document.querySelector('.navbar').classList.toggle('activated');
styleNavbar();
}
function goTo(section_name) {
lenis.scrollTo(section_name);
setTimeout(() => {
toggleMenu();
}, 300);
}
function toggleOptions(section_name) {
document.querySelectorAll('.options-activated').forEach(activated_item => {
if (activated_item.classList.contains(section_name) == false) {
activated_item.classList.toggle('options-activated');
}
})
document.querySelector('.' + section_name).classList.toggle('options-activated');
}