davidjbradshaw / iframe-resizer

Keep iFrames sized to their content.
https://iframe-resizer.com
Other
6.65k stars 981 forks source link

fix: heightCalculationMethod lowestElement / taggedElement only calcu… #1172

Closed aniude closed 11 months ago

aniude commented 1 year ago

hi @davidjbradshaw. please review this PR. the zero heigh/width should not be calculated.

davidjbradshaw commented 1 year ago

Hi, Just trying to understand what the issue is that this is looking to fix, as it adds a lot of overhead to the one bit of the code where performance really matters.

aniude commented 1 year ago

this solution is just to fix if an element width or height is 0 px actually, it should not be calculated by lowestElement or taggedElement mode, although this element has large marginLeft or marginTop size.

for example, the page has a element marginTop is 1000px,but it's height is 0px, like the empty position, people can't see by eyes. it make confuses. the resize callback function will return the large length size and then the iframe also expand the large size.

So I think the more confortable way is ignore this element, or we can add the feature param as ignoreEmptyElement, I guess.

davidjbradshaw commented 11 months ago

I’m sorry I think that is too much of an edge case and your change has too large of a perf impact for something most people don’t need.

I would recommend using taggedEllement resize method in your usecase, or if you really want to do this you can use the API in the iFrame to add your own custom function.

https://github.com/davidjbradshaw/iframe-resizer/blob/master/docs/iframed_page/options.md#heightcalculationmethod--widthcalculationmethod