MOBILE-4470 iframes: Fix loading and improve responsive styles

main
Pau Ferrer Ocaña 2024-05-23 12:20:49 +02:00
parent d2bb5c1b8f
commit 55428d5346
2 changed files with 7 additions and 4 deletions

View File

@ -876,7 +876,7 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec
if (iframe.contentDocument) { if (iframe.contentDocument) {
const css = document.createElement('style'); const css = document.createElement('style');
css.setAttribute('type', 'text/css'); css.setAttribute('type', 'text/css');
css.innerHTML = 'iframe {width: 100%;height: 100%;}'; css.innerHTML = 'iframe {width: 100%;height: 100%;position:absolute;top:0; left:0;}';
iframe.contentDocument.head.appendChild(css); iframe.contentDocument.head.appendChild(css);
} }
}); });

View File

@ -344,7 +344,8 @@ export class CoreIframeUtilsProvider {
element.classList.add('core-loading'); element.classList.add('core-loading');
const treatElement = (sendResizeEvent: boolean = false) => { const treatElement = (sendResizeEvent = false) => {
this.checkOnlineFrameInOffline(element, isSubframe); this.checkOnlineFrameInOffline(element, isSubframe);
const { window, document } = this.getContentWindowAndDocument(element); const { window, document } = this.getContentWindowAndDocument(element);
@ -361,11 +362,13 @@ export class CoreIframeUtilsProvider {
// Iframe content has been loaded. // Iframe content has been loaded.
// Send a resize events to the iframe so it calculates the right size if needed. // Send a resize events to the iframe so it calculates the right size if needed.
if (window && sendResizeEvent) { if (sendResizeEvent) {
element.classList.remove('core-loading'); element.classList.remove('core-loading');
if (window) {
setTimeout(() => window.dispatchEvent && window.dispatchEvent(new Event('resize')), 1000); setTimeout(() => window.dispatchEvent && window.dispatchEvent(new Event('resize')), 1000);
} }
}
}; };
treatElement(); treatElement();