forked from platzi/curso-frontend-developer-practico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
46 lines (30 loc) · 1.19 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
const menuEmail = document.querySelector(".navbar-email");
const desktopMenu = document.querySelector(".desktop-menu");
const menuHamIcon = document.querySelector(".menu")
const mobileMenu = document.querySelector(".mobile-menu")
const menuShopCarIcon = document.querySelector(".navbar-shopping-cart")
const aside = document.querySelector(".product-detail")
menuEmail.addEventListener('click', toggleDesktopMenu);
menuHamIcon.addEventListener('click', toggleMobileMenu);
menuShopCarIcon.addEventListener('click',toggleSoppingCart)
function toggleDesktopMenu() {
if(!aside.classList.contains("hide-menu-cart")){
aside.classList.add("hide-menu-cart")
}
desktopMenu.classList.toggle('inactive');
}
function toggleMobileMenu() {
if(!aside.classList.contains("hide-menu-cart")){
aside.classList.add("hide-menu-cart")
}
mobileMenu.classList.toggle('hide-menu');
};
function toggleSoppingCart() {
if(!mobileMenu.classList.contains("hide-menu")){
mobileMenu.classList.add("hide-menu")
};
if(!desktopMenu.classList.contains("inactive")){
desktopMenu.classList.add("inactive")
}
aside.classList.toggle('hide-menu-cart');
};