davidjbradshaw / iframe-resizer

Keep iFrames sized to their content.

Home Page:https://iframe-resizer.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Width does not shrink when heightCalculationMethod is 'bodyOffset'

WebVeteran opened this issue · comments

The only way I was able to get the frame width to shrink reliably was to set heightCalculationMethod: 'max'. That causes a bad flicker when the iframe disappears and the container's footer jumps up. To get around that I set the iframe's CSS min-height to 500px;
I suggest defaulting heightCalculationMethod to 'max'. And on init set the min-height css of the iframe to 500px. Make that a setting of course.
Also 'heightCalculationMethod' should probably be renamed as 'sizeCalculationMethod' as it also effects the width.

The point about the calculation method effecting the width is an interesting one that I will have to think about for a future version. I expect creating a forceResize flag rather than having it dependent on the height calc method is the way forward.

As for changing the minHeight, which is an option you can pass in the code and the default height calc method I think the current defaults are best for most users.

Thanks,
Dave.
PS good to hear someone is using this to do width resizing, it was added as a bit of a whim to this lib.

I can only get the width to adjust adjust wider but it does not shrink. I'm using the heightCalculationMethod set to max. If it does affect the width as well then the rename might make sense as mentioned above.

In looking at the code.. the width is calculated off of a fixed type.. so we cannot change it. It uses
Math.max(document.documentElement.scrollWidth, document.body.scrollWidth); .. I'm going to run a few use cases to see if I get better results using a different option.

Jake - something else might be going on. In my case the width does shrink when appropriate.

+1
We are seeing a similar "flicker" when setting the calculation method to 'max'. Not sure if it is the exact same issue though.
When clicking form fields inside the resized frame, the frame will grow a bit and then shrink again. In IE it's a bit different as it no longer shrinks after growing?

Fixed in v3.0.0. Beta version currently in the dev branch.

https://github.com/davidjbradshaw/iframe-resizer/tree/dev