mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-02-06 11:53:31 +08:00
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
This commit is contained in:
parent
087989e427
commit
d166b24d59
@ -125,6 +125,15 @@ 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(() => {
|
||||
resizeHandler();
|
||||
});
|
||||
resizeObserver.observe(articleContent);
|
||||
}
|
||||
|
||||
window.addEventListener("resize", debounced(resizeHandler));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user