Skip to content

Commit

Permalink
Merge pull request #289 from BenTheElder/auto-hide
Browse files Browse the repository at this point in the history
site: handle resize
  • Loading branch information
BenTheElder authored Feb 9, 2019
2 parents a152a16 + d154e98 commit 9334b03
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions site/assets/js/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,24 @@ document.addEventListener("DOMContentLoaded", function () {
// note: the default state of the page on load is collapsed
var manualCollapsed = window.localStorage.getItem('sidebar-collapsed');
var width = getWidth();
// if we're now under 900px don't unhide it
// otherwise only unhide if the user has not yet manually toggled it
// or has toggled it back to visible
if (width > 900 && (manualCollapsed == 'false' || manualCollapsed == null)) {
showSideBar();
}
});

window.addEventListener("resize", function () {
// if we're now under 900px, hide it
if (getWidth() <= 900) {
hideSideBar();
} else {
// otherwise only unhide if the user has not yet manually toggled it
// or has toggled it back to visible
var manualCollapsed = window.localStorage.getItem('sidebar-collapsed');
if (manualCollapsed == 'false' || manualCollapsed == null) {
showSideBar();
}
}
});

0 comments on commit 9334b03

Please sign in to comment.