From 99e6743c01f704d5034c4c05eb9b2e015d209c48 Mon Sep 17 00:00:00 2001 From: kharhamel Date: Wed, 24 Mar 2021 17:35:59 +0100 Subject: [PATCH] FIX: resizing on wide screen on chrome now use the correct coordinates --- front/src/Phaser/Menu/MenuScene.ts | 2 +- front/src/WebRtc/CoWebsiteManager.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/front/src/Phaser/Menu/MenuScene.ts b/front/src/Phaser/Menu/MenuScene.ts index 6ed26730..58e7f0a6 100644 --- a/front/src/Phaser/Menu/MenuScene.ts +++ b/front/src/Phaser/Menu/MenuScene.ts @@ -140,7 +140,7 @@ export class MenuScene extends Phaser.Scene { this.warningContainer?.destroy(); this.warningContainer = null this.warningContainerTimeout = null - }, 2000); + }, 120000); } diff --git a/front/src/WebRtc/CoWebsiteManager.ts b/front/src/WebRtc/CoWebsiteManager.ts index d859a2a9..8297257f 100644 --- a/front/src/WebRtc/CoWebsiteManager.ts +++ b/front/src/WebRtc/CoWebsiteManager.ts @@ -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