house9 / jquery-iframe-auto-height

jQuery plugin to set the height of an iframe to its contents height
https://github.com/house9/jquery-iframe-auto-height
453 stars 211 forks source link

Awful double refresh effect #29

Closed federico-bellucci closed 12 years ago

federico-bellucci commented 12 years ago

Anyone can tell me how to remove the awful double refresh effect of this plugin? e.g. http://arthub.hyperborea.com/arthub-container/patrimonio/foto

house9 commented 12 years ago

the plugin cannot resize until the content in the iframe is completely loaded, otherwise it does not know what the height should be; some options 1) set an initial height on your plugin 2) hack the plugin to use jquery animate (someone sent me a code snippet for this in the past, have not integrated it into the codebase)

federico-bellucci commented 12 years ago

I took a look at the code and the problem of double refresh seems to be present only for Chrome/Safari in which the iframe height is first set to 0. I will check if it can work anyway without this hack...

federico-bellucci commented 12 years ago

I modified the source code removing the line:

iframe.style.height = '0px';

It apparently works on my Chromium browser (version 18.0.1025.151) but there is a little price to pay: if the iframe original height is greater than minHeight, then minHeight will not be set.