getBoundingClientRect calculate wrong value on studio mode #3421
-
Hi, Thanks for this awesome tool. I used getBoundingClientRect function to calculate some object locations but the values are calculating wrong when I try to use studio command. It happened because the viewport and base div is different on Remotion studio but everything is OK when I run the render command. Is there any helper function to get the location (top, left, right, bottom) of an element correct on both studio and render? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
It's a good question! Let me get back to it tomorrow |
Beta Was this translation helpful? Give feedback.
-
I now created some documentation on how you can do it, and an example: https://www.remotion.dev/docs/measuring |
Beta Was this translation helpful? Give feedback.
-
Thanks @JonnyBurger for quick answer. One more question: |
Beta Was this translation helpful? Give feedback.
-
@JonnyBurger I still think there is some issue for the calculation, you can see even the ruler value from "studio" is not same as ruler from browser devtools: 🤔 The top right of the composition shows "1250" for x (or top) on studio ruler while it should be "0" or am I missed something for measuring? |
Beta Was this translation helpful? Give feedback.
-
@JonnyBurger I prepared a sample repo about the ruler and DOM measuring issue that I'm facing now: https://github.com/mnlbox/remotion-ruler-and-dom-measuring-issue I guess it's a bug on studio only because everything is working as expected after render the video. I even tried to use the measurer trick that you described in the docs here: |
Beta Was this translation helpful? Give feedback.
-
@JonnyBurger can you please take a look to the above repo to see if it's even an Remotion issue or not? |
Beta Was this translation helpful? Give feedback.
I now created some documentation on how you can do it, and an example: https://www.remotion.dev/docs/measuring