FIX: include header offset relative to window (#11114)

This commit is contained in:
Kris 2020-11-04 21:14:17 -05:00 committed by GitHub
parent fa12302e77
commit 3ee216c036
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,14 @@ export function minimumOffset() {
iPadNav = document.querySelector(".footer-nav-ipad .footer-nav"),
iPadNavHeight = iPadNav ? iPadNav.offsetHeight : 0;
return header ? header.offsetHeight + iPadNavHeight : 0;
// if the header has a positive offset from the top of the window, we need to include the offset
// this covers cases where a site has a custom header above d-header (covers fixed and unfixed)
const headerWrap = document.querySelector(".d-header-wrap"),
headerWrapOffset = headerWrap.getBoundingClientRect();
return header
? header.offsetHeight + headerWrapOffset.top + iPadNavHeight
: 0;
}
export default function offsetCalculator() {