That works kind of. It only gets the first viewport size, but if I change the size at all the numbers still stay the same. Is there any way to consistently get the bounding box on resizing?
Yes.
the question is you wish to detect changes in the iframe size or the parent window size.
If it’s the iframe, put this part in the iframe html script:
addEventListener("resize", (event) => {
let width = event.currentTarget.outerHeight;//or innerHeight depends on what you need
let height = event.currentTarget.outerWidth;
});
If you need the parent page size,
You will have to create a custom element, add an eventListener to detect change, the dispatch the event to the page and post it to the iframe.