From c928c228af428b2743ac4442ceff3118fa1dca48 Mon Sep 17 00:00:00 2001 From: Danil Boldyrev Date: Tue, 30 May 2023 16:35:52 +0300 Subject: [PATCH] a small fix for very wide images, because of the scroll bar was the wrong zoom --- extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js index 4bbec34f7..f555960d2 100644 --- a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js +++ b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js @@ -261,10 +261,13 @@ onUiLoaded(async() => { //Reset Zoom targetElement.style.transform = `translate(${0}px, ${0}px) scale(${1})`; + // Get scrollbar width to right-align the image + const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth; + // Get element and screen dimensions const elementWidth = targetElement.offsetWidth; const elementHeight = targetElement.offsetHeight; - const screenWidth = window.innerWidth; + const screenWidth = window.innerWidth - scrollbarWidth; const screenHeight = window.innerHeight; // Get element's coordinates relative to the page