Skip to content

Commit

Permalink
fix topnav toggle button
Browse files Browse the repository at this point in the history
  • Loading branch information
yklcs committed Sep 7, 2019
1 parent 691f3df commit d52a60a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions js/nav.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
const $ = document.querySelector.bind(document);

let sideNavOpened = false;

function openSideNav() {
$('.sidenav').style.width = '15em';
$('.content').style.marginLeft = '15em';
console.log();
sideNavOpened = true;
}

function closeSideNav() {
$('.sidenav').style.width = '0';
$('.content').style.marginLeft = '0';
sideNavOpened = false;
}

function toggleSideNav() {
sideNavOpened ? closeSideNav() : openSideNav();
}

$('.topnav-menu').addEventListener('onclick', openSideNav);
$('.topnav-menu').addEventListener('click', toggleSideNav);

0 comments on commit d52a60a

Please sign in to comment.