forked from platzi/curso-frontend-developer-practico
-
Notifications
You must be signed in to change notification settings - Fork 481
/
main.js
40 lines (30 loc) · 1.16 KB
/
main.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
const menuEmail = document.querySelector('.navbar-email');
const menuHamIcon = document.querySelector('.menu');
const menuCarritoIcon = document.querySelector('.navbar-shopping-cart');
const desktopMenu = document.querySelector('.desktop-menu');
const mobileMenu = document.querySelector('.mobile-menu');
const aside = document.querySelector('.product-detail');
menuEmail.addEventListener('click', toggleDesktopMenu);
menuHamIcon.addEventListener('click', toggleMobileMenu);
menuCarritoIcon.addEventListener('click', toggleCarritoAside);
function toggleDesktopMenu() {
const isAsideClosed = aside.classList.contains('inactive');
if (!isAsideClosed) {
aside.classList.add('inactive');
}
desktopMenu.classList.toggle('inactive');
}
function toggleMobileMenu() {
const isAsideClosed = aside.classList.contains('inactive');
if (!isAsideClosed) {
aside.classList.add('inactive');
}
mobileMenu.classList.toggle('inactive');
}
function toggleCarritoAside() {
const isMobileMenuClosed = mobileMenu.classList.contains('inactive');
if (!isMobileMenuClosed) {
mobileMenu.classList.add('inactive');
}
aside.classList.toggle('inactive');
}