Fix the startup zoom error

This commit is contained in:
Danil Boldyrev 2024-02-01 11:29:06 +03:00
parent 5e37bf66c1
commit ca7ba7d394

View File

@ -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) {