question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How are you measuring the content height when the paragraph is added or removed?

See original GitHub issue

This 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:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
davidjbradshawcommented, Jan 29, 2018

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.

0reactions
andfinallycommented, Jan 29, 2018

Nice, thanks David.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the size of a picture, shape, text box, or WordArt in Word
Select the picture, shape, WordArt, or other object to resize. On the Size tab, under Scale, enter the percentages of the current height...
Read more >
How can you find the height of text on an HTML canvas?
The canvas spec doesn't give us a method for measuring the height of a string. However, you can set the size of your...
Read more >
Word 2016: Line and Paragraph Spacing - GCF Global
Select the paragraph or paragraphs you want to format. · On the Home tab, click the Line and Paragraph Spacing command. Click Add...
Read more >
Getting to the bottom of line height in Figma
We're altering the way we handle text in Figma. ... as a monolithic, unchangeable block, and line height could only be added, never...
Read more >
Support just-in-time measured content · Issue #6 - GitHub
This component could perform better if we removed the third constraint above, allowing random access (by either item index or scroll offset) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found