-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (28 loc) · 1.01 KB
/
app.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
const burgerBtn = document.querySelector("#burgerBtn")
const nav = document.querySelector("#menu")
const header = document.querySelector("header")
const cartBtn = document.querySelector("#cartBtn")
const bar = document.querySelector(".bar")
const barContainer = document.querySelector(".barContainer")
const menuList = document.querySelector("#menu-list")
function toggleMenu() {
nav.classList.toggle("active")
if (nav.classList.contains("active")) {
burgerBtn.innerHTML = "<i class='fa-solid fa-xmark'></i>"
burgerBtn.style.color = "hsl(48, 100%, 52%)"
burgerBtn.style.zIndex = "101"
burgerBtn.style.position = "fixed"
burgerBtn.style.left = "92%"
} else {
burgerBtn.innerHTML = "<i class='fa-solid fa-bars'></i>"
burgerBtn.style.color = "hsl(21, 70%, 24%)"
burgerBtn.style.position = "static"
}
}
function floatingCartBtn() {
window.innerWidth < 1025
? bar.appendChild(cartBtn)
: menuList.appendChild(cartBtn)
}
window.addEventListener("resize", floatingCartBtn)
floatingCartBtn()