From ca7ba7d39484c1cb09e06dc5fb77bd157b3ed4cf Mon Sep 17 00:00:00 2001 From: Danil Boldyrev Date: Thu, 1 Feb 2024 11:29:06 +0300 Subject: [PATCH] Fix the startup zoom error --- extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js index df60c1a17..6dc8dabd2 100644 --- a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js +++ b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js @@ -401,7 +401,7 @@ onUiLoaded(async() => { toggleOverlap("off"); fullScreenMode = false; - const closeBtn = targetElement.querySelector("button[aria-label='Remove Image']"); + const closeBtn = targetElement.querySelector("button[aria-label='Clear canvas']"); if (closeBtn) { closeBtn.addEventListener("click", resetZoom); } @@ -479,9 +479,10 @@ onUiLoaded(async() => { // Reset zoom when uploading a new image const fileInput = gradioApp().querySelector( - `${elemId} input[type="file"][accept="image/*"].svelte-116rqfv` + `${elemId} .upload-container input[type="file"][accept="image/*"]` ); fileInput.addEventListener("click", resetZoom); + // Update the zoom level and pan position of the target element based on the values of the zoomLevel, panX and panY variables function updateZoom(newZoomLevel, mouseX, mouseY) { @@ -604,6 +605,8 @@ onUiLoaded(async() => { `${elemId} canvas[key="interface"]` ); + // print(canvas) + if (!canvas) return; if (canvas.offsetWidth > 862 || isExtension) {