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,7 +127,14 @@ function setupScrollspy() {
|
|||||||
scrollHandler();
|
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));
|
window.addEventListener("resize", debounced(resizeHandler));
|
||||||
}
|
}
|
||||||
|
|
||||||
export { setupScrollspy };
|
export { setupScrollspy };
|
||||||
|
|||||||
Reference in New Issue
Block a user