Related: #519
Problems
Currently slide-content-overflow diagnostic detects the size of slide contents only when Markdown preview was updated by editting. However, it may not apply diagnostic correctly in following cases:
- Remote images: The size of image elements is not known until they are fully loaded.
- CSS animations: If the slide is including CSS animations, the size of slide content may change during the animation.
Limitations
For following reasons, we are not using ResizeObserver for now (v3.3.0):
- ResizeObserver cannot detect changing the size of inner contents.
- If the wrapper element were injected to each slide page for making ResizeObserver work, CSS styling by Marp theme and inline styles may break.
Solutions
To observe resize slide contents in each page, we might take either one:
- Mix
MutationObserver with ResizeObserver: MutationObserver observes subtree changes, and ResizeObserver observes all of children for each page detected by MutationObserver.
- Polling: Regularly check the size of slide contents.
scrollHeight and scrollWidth to get the size of contents in a page will force reflow and bring performance degradation, so we have to minimize frequency to check the overflow.
https://gist.github.com/paulirish/5d52fb081b3570c81e3a
So I think it's better to trigger the throttled overflow detection by MutationObserver + ResizeObserver.
https://developer.mozilla.org/en-US/docs/Glossary/Throttle
Related: #519
Problems
Currently
slide-content-overflowdiagnostic detects the size of slide contents only when Markdown preview was updated by editting. However, it may not apply diagnostic correctly in following cases:Limitations
For following reasons, we are not using
ResizeObserverfor now (v3.3.0):Solutions
To observe resize slide contents in each page, we might take either one:
MutationObserverwithResizeObserver: MutationObserver observes subtree changes, and ResizeObserver observes all of children for each page detected by MutationObserver.scrollHeightandscrollWidthto get the size of contents in a page will force reflow and bring performance degradation, so we have to minimize frequency to check the overflow.https://gist.github.com/paulirish/5d52fb081b3570c81e3a
So I think it's better to trigger the throttled overflow detection by
MutationObserver+ResizeObserver.https://developer.mozilla.org/en-US/docs/Glossary/Throttle