Skip to content

Commit

Permalink
Merge ae0d1f2 into 05eb89e
Browse files Browse the repository at this point in the history
  • Loading branch information
nscyclone committed Feb 15, 2017
2 parents 05eb89e + ae0d1f2 commit 4932eb9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions assets/js/sidebar.js
Expand Up @@ -54,21 +54,24 @@ function toggleSidebar () {
if (bodyClass.includes(sidebarClosedClass) ||
bodyClass.includes(sidebarClosingClass)) {
openSidebar()
} else if (bodyClass.includes(sidebarOpenedClass) ||
bodyClass.includes(sidebarOpeningClass)) {
closeSidebar()
// Otherwise check the width of window to know which action to invoke.
} else {
window.screen.width > breakpoint ? closeSidebar() : openSidebar()
closeSidebar()
}
}

function setDefaultSidebarState () {
body.removeClass()
body.addClass(window.innerWidth > breakpoint ? sidebarOpenedClass : sidebarClosedClass)
}

// Public Methods
// --------------

export {breakpoint, closeSidebar}

export function initialize () {
setDefaultSidebarState()
$(window).resize(setDefaultSidebarState)
$('.sidebar-toggle').click(function () {
toggleSidebar()
})
Expand Down

0 comments on commit 4932eb9

Please sign in to comment.