FIX: resizing on wide screen on chrome now use the correct coordinates

This commit is contained in:
kharhamel 2021-03-24 17:35:59 +01:00
parent dc1a5da175
commit 99e6743c01
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();
}
@ -92,6 +92,12 @@ class CoWebsiteManager {
});
}
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
this.cowebsiteDiv.classList.add('hidden');