[DOM] Element position doesn't get computed properly when `iframe` gets scaled
See original GitHub issueI have an element inside an iframe, and I’m trying to compute its position from the parent window. However, when I give transform: scale(2)
to iframe element, scale doesn’t get counted.
https://codesandbox.io/s/floating-ui-dom-template-forked-gz4whh?file=/src/index.js
This is how the tooltip gets rendered:
Instead, I was expecting something like this:
Issue Analytics
- State:
- Created a year ago
- Comments:9
Top Results From Across the Web
Adjust width and height of iframe to fit with content in it
This works beautifully if the parent document and document in the iframe are both from the same domain.
Read more ><iframe>: The Inline Frame element - HTML - MDN Web Docs
Positioning and scaling As a replaced element, the position, alignment, and scaling of the embedded document within the <iframe> element's box, ...
Read more >How to Scale the Content of <iframe> Element - W3docs
Scaling the content of an may be needed if you want to display an object in the area not matching its original size....
Read more >Linearly Scale font-size with CSS clamp() Based on the Viewport
What we are trying to achieve with clamp() is called linear interpolation: getting intermediate information between two data points.
Read more >Embedded Content — SVG 2
Computation of automatically-sized values follows the Default Sizing Algorithm defined for replaced elements in CSS layout [css-images-3]. In particular, when ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, I just wanted to mention that I have the same issue with scaling. I get extra x-/y-shifting and the higher the position of the context elements the higher is the extra x-/y-shifting.
It seems that this use-case often comes with sections of a webapp that have a scaling feature. From my side an opportunity to feed the
computePosition
function with x-/y-scaling numbers is sufficient as I know where those scalings are applied. But there may be others cases for which it is not.Okay so at this point, scale issues are killing me 🥲, there were 5 releases (1.0.8-1.0.12) fixing various issues with transform/
scale
, but I did find a solution to this iframe issue with thegetScale
function we now have.Apply it to these values as @seahindeniz originally suggested:
https://github.com/floating-ui/floating-ui/blob/99d187876a42fbd7057952d3b273c0978d562770/packages/dom/src/utils/getBoundingClientRect.ts#L28-L37