From ad3d6d9a22ee8dc4e97c28f87d82b604bc7f5efe Mon Sep 17 00:00:00 2001 From: Danil Boldyrev Date: Sun, 4 Jun 2023 03:38:21 +0300 Subject: [PATCH] Fixed visual bugs --- .../canvas-zoom-and-pan/javascript/zoom.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js index a6434743..7ae2c635 100644 --- a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js +++ b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js @@ -622,13 +622,14 @@ onUiLoaded(async() => { panSpeed = 3.5; } - elemData[elemId].panX = - elemData[elemId].panX + movementX * panSpeed; - elemData[elemId].panY = - elemData[elemId].panY + movementY * panSpeed; + elemData[elemId].panX += movementX * panSpeed; + elemData[elemId].panY += movementY * panSpeed; - targetElement.style.transform = `translate(${elemData[elemId].panX}px, ${elemData[elemId].panY}px) scale(${elemData[elemId].zoomLevel})`; - toggleOverlap("on"); + // Delayed redraw of an element + requestAnimationFrame(() => { + targetElement.style.transform = `translate(${elemData[elemId].panX}px, ${elemData[elemId].panY}px) scale(${elemData[elemId].zoomLevel})`; + toggleOverlap("on"); + }); } function handleMoveByKey(e) {