From d02b9f0c7453e7afc44ca40619cbfd0e0bbfb90d Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 19 Feb 2024 15:45:35 -0500 Subject: [PATCH] Keep fixing sidebar --- themes/red/assets/js/site.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/themes/red/assets/js/site.js b/themes/red/assets/js/site.js index f502221..26f121d 100644 --- a/themes/red/assets/js/site.js +++ b/themes/red/assets/js/site.js @@ -1,9 +1,21 @@ function checkWidth() { - if (!window.matchMedia('(max-device-width: 768px)').matches) { - document.getElementById("nav-menu").open = true; + let navmenu = document.getElementById("nav-menu"); + + // If the device somehow gains the stick sidebar, make sure it's open + if (window.matchMedia('(max-device-width: 768px)').matches) { + navmenu.open = true; } } window.onresize = function() { checkWidth(); }; + +checkWidth(); + +let navmenu = document.getElementById("nav-menu"); + +// Disable by default on mobile devices +if (window.matchMedia('(max-device-width: 768px)').matches) { + navmenu.open = false; +}