minor bugfix in screen scaling

This commit is contained in:
Elijah R 2024-04-10 19:03:17 -04:00
parent b87abde238
commit 3b4d6ce6df

View File

@ -416,11 +416,15 @@ export default class CollabVMClient {
}
private onWindowResize(e: Event) {
var t = setTimeout(() => {
if (!this.connectedToVM) return;
var copyctx = (this.actualScreenSize.width !== this.canvasScale.width || this.actualScreenSize.height !== this.canvasScale.height) ? this.unscaledCanvas : this.canvas;
this.recalculateCanvasScale(this.actualScreenSize.width, this.actualScreenSize.height);
this.canvas.width = this.canvasScale.width;
this.canvas.height = this.canvasScale.height;
this.ctx.drawImage(copyctx, 0, 0, this.actualScreenSize.width, this.actualScreenSize.height, 0, 0, this.canvas.width, this.canvas.height);
}, 500);
window.addEventListener('resize', () => clearTimeout(t), {once: true});
}
private recalculateCanvasScale(width: number, height: number) {