Add event listener for focus so elements hidden behind the footer will scroll to the center of the screen

This commit is contained in:
leigh-mil
2019-01-23 10:58:13 -05:00
parent ffb05bbc74
commit 6fbb49d74e
2 changed files with 26 additions and 0 deletions

15
js/lib/viewport.js Normal file
View File

@@ -0,0 +1,15 @@
export const isNotInVerticalViewport = (el) => {
const bounds = el.getBoundingClientRect()
if (bounds.top < 0) {
return true
}
if (bounds.bottom > ((window.innerHeight - 50))) {
// 50 is a magic number to offset for the sticky footer
// see variables.scss for $footer-height
return true
}
return false
}