Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions pal/screen-adapter/web/screen-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@
private _onFullscreenError?: () => void;
// We need to set timeout to handle screen event.
private _orientationChangeTimeoutId = -1;
private _resizeTimeoutId = -1;
private _cachedFrameSize = new Size(0, 0); // cache before enter fullscreen.
private _exactFitScreen = false;
private _isHeadlessMode = false;
Expand Down Expand Up @@ -383,10 +384,16 @@
});

window.addEventListener('resize', (): void => {
// if (!this.handleResizeEvent) {
// return;
// }
this._updateFrame();
if (!this.handleResizeEvent) {
return;
}
if (this._resizeTimeoutId !== -1) {
clearTimeout(this._resizeTimeoutId);
}
this._resizeTimeoutId = setTimeout((): void => {
this._updateFrame();
this._resizeTimeoutId = -1;
}, EVENT_TIMEOUT);
});

const notifyOrientationChange = (orientation): void => {
Expand Down Expand Up @@ -439,11 +446,17 @@
const mediaQueryResolution = window.matchMedia(`(resolution: ${dpr}dppx)`);
if (mediaQueryResolution.addEventListener) {
mediaQueryResolution.addEventListener('change', (): void => {
if (!this.handleResizeEvent) {
return;
}
this.emit('window-resize', this.windowSize.width, this.windowSize.height);
updateDPRChangeListener();
}, { once: true });
} else if (mediaQueryResolution.addListener) {
mediaQueryResolution.addListener((): void => {
if (!this.handleResizeEvent) {
return;
}
this.emit('window-resize', this.windowSize.width, this.windowSize.height);
});
}
Expand Down Expand Up @@ -530,7 +543,7 @@
} else {
const winWidth = window.innerWidth;
let winHeight = window.innerHeight;
//On certain android devices, window.innerHeight may not account for the height of the virtual keyboard, so dynamic calculation is necessary.

Check warning on line 546 in pal/screen-adapter/web/screen-adapter.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 153. Maximum allowed is 150
const inputHeight = document.body.scrollHeight - winHeight;
if (systemInfo.os === OS.ANDROID && winHeight < inputHeight) {
winHeight += inputHeight;
Expand Down
Loading