From: Dan Allen Date: Mon, 21 Dec 2020 00:20:27 +0000 (-0700) Subject: make correction for view height when opening navbar menu on mobile X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=fb55996a93616f4b1ce348a77c0fd74c96eade82;p=working%2Feg-antora.git make correction for view height when opening navbar menu on mobile --- diff --git a/src/js/05-mobile-navbar.js b/src/js/05-mobile-navbar.js index 17f0452..b718738 100644 --- a/src/js/05-mobile-navbar.js +++ b/src/js/05-mobile-navbar.js @@ -7,8 +7,14 @@ function toggleNavbarMenu (e) { e.stopPropagation() // trap event - this.classList.toggle('is-active') - document.getElementById(this.dataset.target).classList.toggle('is-active') document.documentElement.classList.toggle('is-clipped--navbar') + this.classList.toggle('is-active') + var menu = document.getElementById(this.dataset.target) + if (menu.classList.toggle('is-active')) { + menu.style.maxHeight = '' + var expectedMaxHeight = window.innerHeight - Math.round(menu.getBoundingClientRect().top) + var actualMaxHeight = parseInt(window.getComputedStyle(menu).maxHeight) + if (actualMaxHeight !== expectedMaxHeight) menu.style.maxHeight = expectedMaxHeight + 'px' + } } })()