From 2687b29d4dd1e02374c3b74e985d293fc7daa4d7 Mon Sep 17 00:00:00 2001 From: Tomas Kulhanek <tomaton@centrum.cz> Date: Wed, 17 Mar 2021 07:46:41 +0000 Subject: [PATCH] FIX molstar/molstar#147 offsetWidth/offsetHeight is correct size of element when css transform:scale is used --- src/mol-canvas3d/util.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mol-canvas3d/util.ts b/src/mol-canvas3d/util.ts index 94dc92215..a3955e5a1 100644 --- a/src/mol-canvas3d/util.ts +++ b/src/mol-canvas3d/util.ts @@ -12,13 +12,13 @@ export function setCanvasSize(canvas: HTMLCanvasElement, width: number, height: } /** Resize canvas to container element taking `devicePixelRatio` into account */ -export function resizeCanvas (canvas: HTMLCanvasElement, container: Element, scale = 1) { +export function resizeCanvas (canvas: HTMLCanvasElement, container: HTMLElement, scale = 1) { let width = window.innerWidth; let height = window.innerHeight; if (container !== document.body) { - let bounds = container.getBoundingClientRect(); - width = bounds.right - bounds.left; - height = bounds.bottom - bounds.top; + // fixes issue #molstar/molstar#147, offsetWidth/offsetHeight is correct size when css transform:scale is used + width = container.offsetWidth; + height = container.offsetHeight; } setCanvasSize(canvas, width, height, scale); } -- GitLab