-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscript.js
46 lines (35 loc) · 1.24 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
// sticky nav bar
window.onscroll = function() {myFunction()};
var navbar = document.getElementById('navbar');
var sticky = navbar.offsetTop;
let menuToggler = document.getElementById('menuToggler');
function myFunction() {
if ((window.scrollY >= sticky)) {
navbar.classList.add("sticky")
menuToggler.classList.add('menuDisplay');
} else {
navbar.classList.remove("sticky");
menuToggler.classList.remove('menuDisplay');
}
}
// nav bar back to normal position
let menuIcon = document.getElementById('menuIcon');
menuIcon.addEventListener('click',(event)=>{
navbar.classList.remove('sticky')
})
// burgor menu
let burgorIconDiv = document.getElementById('burgorIconDiv');
let burgorIcon = document.getElementById('burgorIcon')
let burgorMenuItems = document.getElementById('burgorMenuItems')
burgorIcon.addEventListener('click',(event)=>{
if(burgorIcon.classList.contains('fa-bars')){
burgorIcon.classList.remove('fa-bars');
burgorIcon.classList.add('fa-xmark');
}else{
burgorIcon.classList.remove('fa-xmark');
burgorIcon.classList.add('fa-bars');
}
burgorMenuItems.classList.toggle('burgorMenuItems')
burgorIconDiv.classList.toggle('burgorDivTranslate')
burgorIcon.classList.toggle('burgorTranslate')
})