Welcome to mirror list, hosted at ThFree Co, Russian Federation.

navbutton.js « js « static - github.com/saadnpq/npq-hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 588b78ca2c8db9efdc84c6d33ef79a557c954722 (plain)
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
function navToggle() {
  isNavOpen() ? navClose() : navOpen();
  }
  
  /* Set the width of the side navigation to 0 and the left margin of the page content to 0 */
function isNavOpen() {
    navStyle = window.getComputedStyle(document.getElementById("sidenav"));
    navWidth = navStyle.getPropertyValue('width')
    return  ( navWidth !== "0px" ) && (navWidth !== "");
}

function navOpen(){
  let navWidth = "200px"
  document.getElementById("sidenav").style.width = navWidth;
  document.getElementById("closebtn").style.left= navWidth;
  if (! window.matchMedia("(max-width: 650px)").matches){
    document.getElementById("main").style.marginLeft = navWidth;
  }
}

function navClose(){
  document.getElementById("sidenav").style.width = "0px";
  document.getElementById("main").style.marginLeft = "0px";
  document.getElementById("closebtn").style.left= "0px";
}