nprapps / pym.js

Resize an iframe responsively depending on the height of its content and the width of its container.
http://blog.apps.npr.org/pym.js/
MIT License
808 stars 114 forks source link

Iframe not adjusting height when content gets smaller #165

Closed ryanbmarx closed 5 years ago

ryanbmarx commented 7 years ago

I am using Pym to display a simple tab-switcher graphic. The tabs' content are not equally tall.

The iframe resizes fine when the taller tab is shown, but when switching to the shorter tab, the iframe remains at the taller height. Some console.logging shows that the body.offsetHeight is not changing. When running the child directly, the same javascript shows the body.offsetHeight values are correct.

I see this on Chrome 61 and Safari 11, but not Firefox 57.

Even with all the other code/analytics/extras/etc. removed, this simple demo still shows the same behavior.

(Also strange: If polling is enabled, then the iframe height attribute will animate down to the proper value over several seconds.)

Any insight would be much appreciated. Thanks!

eads commented 7 years ago

You might be able to use pymChild.sendHeight() on the tab change.

On Wed, Oct 11, 2017 at 3:07 PM, Ryan Marx notifications@github.com wrote:

I am using Pym to display a simple tab-switcher graphic. The tabs' content are not equally tall.

The iframe resizes fine when the taller tab is shown, but when switching to the shorter tab, the iframe remains at the taller height. Some console.logging shows that the body.offsetHeight is not changing. When running the child directly, the same javascript shows the body.offsetHeight values are correct.

I see this on Chrome 61 and Safari 11, but not Firefox 57.

Even with all the other code/analytics/extras/etc. removed, this simple demo http://graphics.chicagotribune.com/demo/ still shows the same behavior.

(Also strange: If polling is enabled, then the iframe height attribute will animate down to the proper value over several seconds.)

Any insight would be much appreciated. Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nprapps/pym.js/issues/165, or mute the thread https://github.com/notifications/unsubscribe-auth/AAmuzJ_Pywc1hCMNS58ucI-tQKHTKAk4ks5srR_ngaJpZM4P2DTL .

-- David Eads | http://recoveredfactory.net

"Medical statistics will be our standard of measurement: we will weigh life for life and see where the dead lie thicker, among the workers or among the privileged." -- Rudolf Virchow

ryanbmarx commented 7 years ago

I'm using pymChild.sendHeight() both on init and tab switch.