How are you measuring the content height when the paragraph is added or removed?
See original GitHub issueThis is such a great library, thank you!
I’d love to know how you’re measuring the height in your example when the “Toggle content” link is clicked.
I’m trying an iframe resizer script of my own, which sends a postMessage with the document.documentElement.offsetHeight
to the parent page on resize of the child window, and also when a MutationObserver
notices a change in the child DOM.
When I add nodes to the child page the window grows, and my script resizes the iframe to fit. But when I delete those nodes afterwards the child document stays the same height, so the iframe isn’t resized. It seems to be a browser behaviour that once a document has height, it doesn’t shrink back when nodes are removed.
I noticed your comment “document.documentElement.offsetHeight is not reliable”, so I tried measuring the document.body.offsetHeight
. But that doesn’t change either.
Am I right in thinking that in this situation your example’s using the getMaxElement
method to find the bottom of the bottom-most element on the child page?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
It’s combination of this: https://github.com/davidjbradshaw/iframe-resizer/blob/master/src/iframeResizer.contentWindow.js#L777
And resetting the height of the iFrame to zero before working out the new height.
https://github.com/davidjbradshaw/iframe-resizer/blob/master/src/iframeResizer.js#L778
This can cause screen flicker so I would recommend one of the other methods to work out the height.
Nice, thanks David.