mirror of
https://github.com/AzuraCast/AzuraCast.git
synced 2024-06-15 05:36:37 +00:00
Add ResizeObserver to send updated messages to parent when main body size changes.
This commit is contained in:
parent
47c061bad6
commit
8b15a55bad
|
@ -40,17 +40,25 @@ ready(() => {
|
|||
|
||||
// If in a frame, notify the parent frame of the frame dimensions.
|
||||
if (window.self !== window.top) {
|
||||
window.top.postMessage({
|
||||
height: document.body.scrollHeight,
|
||||
width: document.body.scrollWidth
|
||||
}, "*");
|
||||
let docHeight = 0;
|
||||
let docWidth = 0;
|
||||
|
||||
document.addEventListener("vue-ready", () => {
|
||||
window.top.postMessage({
|
||||
height: document.body.scrollHeight,
|
||||
width: document.body.scrollWidth
|
||||
}, "*");
|
||||
});
|
||||
const postSizeToParent = () => {
|
||||
if (document.body.scrollHeight !== docHeight || document.body.scrollWidth !== docWidth) {
|
||||
docHeight = document.body.scrollHeight;
|
||||
docWidth = document.body.scrollWidth;
|
||||
|
||||
const message = {height: docHeight, width: docWidth};
|
||||
window.top.postMessage(message, "*");
|
||||
}
|
||||
}
|
||||
|
||||
postSizeToParent();
|
||||
document.addEventListener("vue-ready", postSizeToParent);
|
||||
|
||||
const mainElem = document.querySelector('main');
|
||||
const resizeObserver = new ResizeObserver(postSizeToParent);
|
||||
resizeObserver.observe(mainElem);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user