8339684: ResizeObserver callback interrupts smooth scrolling on Chrome

Reviewed-by: prappo
This commit is contained in:
Hannes Wallnöfer 2024-10-03 16:44:22 +00:00
parent ebb4759c3d
commit de12fc7a36

View File

@ -300,6 +300,7 @@ document.addEventListener("DOMContentLoaded", function(e) {
});
var expanded = false;
var windowWidth;
var bodyHeight;
function collapse(e) {
if (expanded) {
mainnav.removeAttribute("style");
@ -365,6 +366,7 @@ document.addEventListener("DOMContentLoaded", function(e) {
var scrollTimeoutNeeded;
var prevHash;
function initSectionData() {
bodyHeight = document.body.offsetHeight;
sections = [{ id: "", top: 0 }].concat(Array.from(main.querySelectorAll("section[id], h2[id], h2 a[id], div[id]"))
.filter((e) => {
return sidebar.querySelector("a[href=\"#" + encodeURI(e.getAttribute("id")) + "\"]") !== null
@ -469,7 +471,7 @@ document.addEventListener("DOMContentLoaded", function(e) {
expand();
}
}
if (sections) {
if (sections && document.body.offsetHeight !== bodyHeight) {
initSectionData();
prevHash = null;
handleScroll();