From 2c14d95056d53caf31b7e1a4241939eb4801b4a4 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 1 Jul 2019 13:34:38 +0200 Subject: [PATCH] BUG FIXED: When zooming the designer the icons go far from the center --- Spaces/FloatingSpace.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index 1c9aeb5dd..484e5e9c3 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -31,13 +31,16 @@ function newFloatingSpace () { thisObject.container.isWheelable = true thisObject.container.detectMouseOver = true thisObject.container.frame.radius = 0 - thisObject.container.frame.width = browserCanvas.width * 10 - thisObject.container.frame.height = browserCanvas.height * 10 + + let devicePixelRatio = window.devicePixelRatio + const SPACE_SIZE = 10 + + thisObject.container.frame.width = browserCanvas.width * devicePixelRatio * SPACE_SIZE + thisObject.container.frame.height = browserCanvas.height * devicePixelRatio * SPACE_SIZE thisObject.container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2 thisObject.container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2 let visible = false - return thisObject function finalize () { @@ -134,9 +137,19 @@ function newFloatingSpace () { } function physics () { + browserZoomPhysics() thisObject.floatingLayer.physics() } + function browserZoomPhysics () { + if (devicePixelRatio !== window.devicePixelRatio) { + devicePixelRatio = window.devicePixelRatio + + thisObject.container.frame.position.x = browserCanvas.width / 2 - thisObject.container.frame.width / 2 + thisObject.container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2 + } + } + function draw () { if (visible === true) { drawBackground() @@ -155,4 +168,3 @@ function newFloatingSpace () { browserCanvasContext.fill() } } -