Added: burger menu for mobile views
This commit is contained in:
		
							
								
								
									
										22
									
								
								static/js/mobile-navbar.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								static/js/mobile-navbar.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
const burger = document.querySelector(".hamburger")
 | 
			
		||||
const links = document.querySelector(".links")
 | 
			
		||||
const body = document.querySelector("body")
 | 
			
		||||
 | 
			
		||||
let shown = false
 | 
			
		||||
 | 
			
		||||
burger.addEventListener("click", (e) => {
 | 
			
		||||
  e.preventDefault()
 | 
			
		||||
  if (!shown) {
 | 
			
		||||
    links.style.display = "flex"
 | 
			
		||||
    body.classList.add("disable-scroll")
 | 
			
		||||
    burger.textContent = "x"
 | 
			
		||||
  } else {
 | 
			
		||||
    links.style.display = "none"
 | 
			
		||||
    body.classList.remove("disable-scroll")
 | 
			
		||||
    burger.textContent = "☰"
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  shown = !shown
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user