Merge pull request #838 from thecodingmachine/fixChromeResize

FIX: resizing on wide screen on chrome now use the correct coordinates
This commit is contained in:
David Négrier 2021-03-25 18:52:15 +01:00 committed by GitHub
commit 30e12702eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -140,7 +140,7 @@ export class MenuScene extends Phaser.Scene {
this.warningContainer?.destroy();
this.warningContainer = null
this.warningContainerTimeout = null
}, 2000);
}, 120000);
}

View File

@ -73,7 +73,7 @@ class CoWebsiteManager {
private initResizeListeners() {
const movecallback = (event:MouseEvent) => {
this.verticalMode ? this.height -= event.movementY : this.width -= event.movementX;
this.verticalMode ? this.height -= event.movementY / this.getDevicePixelRatio() : this.width -= event.movementX / this.getDevicePixelRatio();
this.fire();
}
@ -91,6 +91,12 @@ class CoWebsiteManager {
this.resizing = false;
});
}
private getDevicePixelRatio(): number {
//on chrome engines, movementX and movementY return global screens coordinates while other browser return pixels
//so on chrome-based browser we need to adjust using 'devicePixelRatio'
return window.navigator.userAgent.includes('Firefox') ? 1 : window.devicePixelRatio;
}
private close(): void {
this.cowebsiteDiv.classList.remove('loaded'); //edit the css class to trigger the transition