MOBILE-3799 iframe: Fix fullscreen on rotate in new pages

main
Dani Palou 2022-02-16 11:05:01 +01:00
parent 97d7ec8045
commit 12cb62b7c2
1 changed files with 15 additions and 1 deletions

View File

@ -58,7 +58,7 @@ export class CoreIframeComponent implements OnChanges, OnDestroy {
protected orientationObs?: CoreEventObserver; protected orientationObs?: CoreEventObserver;
protected navSubscription?: Subscription; protected navSubscription?: Subscription;
constructor() { constructor(protected elementRef: ElementRef<HTMLElement>) {
this.loaded = new EventEmitter<HTMLIFrameElement>(); this.loaded = new EventEmitter<HTMLIFrameElement>();
} }
@ -104,6 +104,10 @@ export class CoreIframeComponent implements OnChanges, OnDestroy {
this.toggleFullscreen(CoreScreen.isLandscape); this.toggleFullscreen(CoreScreen.isLandscape);
this.orientationObs = CoreEvents.on(CoreEvents.ORIENTATION_CHANGE, (data) => { this.orientationObs = CoreEvents.on(CoreEvents.ORIENTATION_CHANGE, (data) => {
if (this.isInHiddenPage()) {
return;
}
this.toggleFullscreen(data.orientation == CoreScreenOrientation.LANDSCAPE); this.toggleFullscreen(data.orientation == CoreScreenOrientation.LANDSCAPE);
}); });
} }
@ -131,6 +135,16 @@ export class CoreIframeComponent implements OnChanges, OnDestroy {
} }
} }
/**
* Check if the element is in a hidden page.
*
* @return Whether the element is in a hidden page.
*/
protected isInHiddenPage(): boolean {
// If we can't find the parent ion-page, consider it to be hidden too.
return !this.elementRef.nativeElement.closest('.ion-page') || !!this.elementRef.nativeElement.closest('.ion-page-hidden');
}
/** /**
* Detect changes on input properties. * Detect changes on input properties.
*/ */