FIX: calculate docking - include offset of main (#16079)

Include a calculation of offset in main - this allows docking
to be calculated (again) using global offsets, in case there is a
custom header outside of Discourse that pushes forum content down.
This commit is contained in:
Jeff Wong 2022-03-02 15:36:24 -10:00 committed by GitHub
parent 7f9c0e476f
commit 91cbd28fa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -196,7 +196,10 @@ const SiteHeaderComponent = MountWidget.extend(
document.documentElement.style.setProperty("--header-offset", newValue);
}
if (window.pageYOffset >= this.docAt) {
const main = document.querySelector("#main");
const offsetTop = main ? main.offsetTop : 0;
const offset = window.pageYOffset - offsetTop;
if (offset >= this.docAt) {
if (!this.dockedHeader) {
document.body.classList.add("docked");
this.dockedHeader = true;