diff --git a/src/core/components/iframe/iframe.ts b/src/core/components/iframe/iframe.ts index b80264904..522d46867 100644 --- a/src/core/components/iframe/iframe.ts +++ b/src/core/components/iframe/iframe.ts @@ -58,7 +58,7 @@ export class CoreIframeComponent implements OnChanges, OnDestroy { protected orientationObs?: CoreEventObserver; protected navSubscription?: Subscription; - constructor() { + constructor(protected elementRef: ElementRef) { this.loaded = new EventEmitter(); } @@ -104,6 +104,10 @@ export class CoreIframeComponent implements OnChanges, OnDestroy { this.toggleFullscreen(CoreScreen.isLandscape); this.orientationObs = CoreEvents.on(CoreEvents.ORIENTATION_CHANGE, (data) => { + if (this.isInHiddenPage()) { + return; + } + 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. */