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:
@@ -127,6 +127,13 @@ 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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user