forked from rammcodes/Dopefolio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (34 loc) · 1.32 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
// ---
const hamMenuBtn = document.querySelector('.header__main-ham-menu-cont')
const smallMenu = document.querySelector('.header__sm-menu')
const headerHamMenuBtn = document.querySelector('.header__main-ham-menu')
const headerHamMenuCloseBtn = document.querySelector(
'.header__main-ham-menu-close'
)
const headerSmallMenuLinks = document.querySelectorAll('.header__sm-menu-link')
hamMenuBtn.addEventListener('click', () => {
if (smallMenu.classList.contains('header__sm-menu--active')) {
smallMenu.classList.remove('header__sm-menu--active')
} else {
smallMenu.classList.add('header__sm-menu--active')
}
if (headerHamMenuBtn.classList.contains('d-none')) {
headerHamMenuBtn.classList.remove('d-none')
headerHamMenuCloseBtn.classList.add('d-none')
} else {
headerHamMenuBtn.classList.add('d-none')
headerHamMenuCloseBtn.classList.remove('d-none')
}
})
for (let i = 0; i < headerSmallMenuLinks.length; i++) {
headerSmallMenuLinks[i].addEventListener('click', () => {
smallMenu.classList.remove('header__sm-menu--active')
headerHamMenuBtn.classList.remove('d-none')
headerHamMenuCloseBtn.classList.add('d-none')
})
}
// ---
const headerLogoConatiner = document.querySelector('.header__logo-container')
headerLogoConatiner.addEventListener('click', () => {
location.href = 'index.html'
})