Skip to content

Commit 63ae01f

Browse files
committed
adjust height of nav panel when activating, if necessary
1 parent 626b1a2 commit 63ae01f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/js/01-nav.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106

107107
function showNav (e) {
108108
if (navToggle.classList.contains('is-active')) return hideNav(e)
109+
var navBounds = nav.getBoundingClientRect()
110+
var expectedNavHeight = window.innerHeight - Math.round(navBounds.top)
111+
if (Math.round(navBounds.height) !== expectedNavHeight) nav.style.height = expectedNavHeight + 'px'
109112
var html = document.documentElement
110113
html.classList.add('is-clipped--nav')
111114
navToggle.classList.add('is-active')
@@ -142,7 +145,6 @@
142145

143146
function findNextElement (from, selector) {
144147
var el = from.nextElementSibling
145-
if (!el) return
146-
return selector ? el[el.matches ? 'matches' : 'msMatchesSelector'](selector) && el : el
148+
return el && selector ? el[el.matches ? 'matches' : 'msMatchesSelector'](selector) && el : el
147149
}
148150
})()

0 commit comments

Comments
 (0)