Skip to content

Commit

Permalink
fix(content): fullscreen works when rotating device (#26782)
Browse files Browse the repository at this point in the history
resolves #26743
  • Loading branch information
liamdebeasi authored Feb 13, 2023
1 parent 3717dc4 commit 7b879fe
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions core/src/components/content/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class Content implements ComponentInterface {
private scrollEl?: HTMLElement;
private backgroundContentEl?: HTMLElement;
private isMainContent = true;
private resizeTimeout: ReturnType<typeof setTimeout> | null = null;

// Detail is used in a hot loop in the scroll event, by allocating it here
// V8 will be able to inline any read/write to it since it's a monomorphic class.
Expand Down Expand Up @@ -123,6 +124,35 @@ export class Content implements ComponentInterface {
this.resize();
}

/**
* Rotating certain devices can update
* the safe area insets. As a result,
* the fullscreen feature on ion-content
* needs to be recalculated.
*
* We listen for "resize" because we
* do not care what the orientation of
* the device is. Other APIs
* such as ScreenOrientation or
* the deviceorientation event must have
* permission from the user first whereas
* the "resize" event does not.
*
* We also throttle the callback to minimize
* thrashing when quickly resizing a window.
*/
@Listen('resize', { target: 'window' })
onResize() {
if (this.resizeTimeout) {
clearTimeout(this.resizeTimeout);
this.resizeTimeout = null;
}

this.resizeTimeout = setTimeout(() => {
this.resize();
}, 100);
}

private shouldForceOverscroll() {
const { forceOverscroll } = this;
const mode = getIonMode(this);
Expand Down

0 comments on commit 7b879fe

Please sign in to comment.