feat: use ResizeObserver to detect changes in the size of .article-content (#1105)

* Use ResizeObserver to detect changes in the size of .article-content

This code is for handling changes in position caused by content rendered as part of post-processing, such as Mermaid diagrams

* Add debounced to resizeHandler
This commit is contained in:
Jerry Kim
2025-11-01 21:59:30 +01:00
committed by GitHub
parent d507f2ef7c
commit 145cda7d45
+8 -1
View File
@@ -127,7 +127,14 @@ function setupScrollspy() {
scrollHandler();
}
// Use ResizeObserver to detect changes in the size of .article-content
const articleContent = document.querySelector(".article-content");
if (articleContent) {
const resizeObserver = new ResizeObserver(debounced(resizeHandler));
resizeObserver.observe(articleContent);
}
window.addEventListener("resize", debounced(resizeHandler));
}
export { setupScrollspy };
export { setupScrollspy };