diff --git a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js index 387658ced..7d5c139e1 100644 --- a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js +++ b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js @@ -383,8 +383,7 @@ onUiLoaded(async() => { // Create tooltip function createTooltip() { - const toolTipElement = - targetElement.querySelector(".image-container"); + const toolTipElement = targetElement.querySelector(".image-container"); const tooltip = document.createElement("div"); tooltip.className = "canvas-tooltip"; @@ -447,25 +446,15 @@ onUiLoaded(async() => { // Add a hint element to the target element toolTipElement.appendChild(tooltip); + + return tooltip; } //Show tool tip if setting enable - if (hotkeysConfig.canvas_show_tooltip) { - createTooltip(); - } + const canvasTooltip = createTooltip(); - // In the course of research, it was found that the tag img is very harmful when zooming and creates white canvases. This hack allows you to almost never think about this problem, it has no effect on webui. - function fixCanvas() { - const activeTab = getActiveTab(elements)?.textContent.trim(); - - if (activeTab && activeTab !== "img2img") { - const img = targetElement.querySelector(`${elemId} img`); - - if (img && img.style.display !== "none") { - img.style.display = "none"; - img.style.visibility = "hidden"; - } - } + if (!hotkeysConfig.canvas_show_tooltip) { + canvasTooltip.style.display = "none"; } // Reset the zoom level and pan position of the target element to their initial values @@ -785,15 +774,7 @@ onUiLoaded(async() => { targetElement.addEventListener("mouseleave", handleMouseLeave); // Reset zoom when click on another tab - if (elements.img2imgTabs) { - elements.img2imgTabs.addEventListener("click", resetZoom); - elements.img2imgTabs.addEventListener("click", () => { - // targetElement.style.width = ""; - if (parseInt(targetElement.style.width) > 865) { - setTimeout(fitToElement, 0); - } - }); - } + elements.img2imgTabs.addEventListener("click", resetZoom); targetElement.addEventListener("wheel", e => { // change zoom level diff --git a/modules/infotext_utils.py b/modules/infotext_utils.py index 6edc44f8b..3d58e2d16 100644 --- a/modules/infotext_utils.py +++ b/modules/infotext_utils.py @@ -101,9 +101,9 @@ def image_from_url_text(filedata): if filedata.startswith("data:image/png;base64,"): filedata = filedata[len("data:image/png;base64,"):] - filedata = base64.decodebytes(filedata.encode('utf-8')) - image = images.read(io.BytesIO(filedata)) - return image + filedata = base64.decodebytes(filedata.encode('utf-8')) + image = images.read(io.BytesIO(filedata)) + return image return None diff --git a/modules/ui.py b/modules/ui.py index 5dc72891c..6467d456c 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -12,7 +12,7 @@ from gradio.components.image_editor import Brush from PIL import Image, PngImagePlugin # noqa: F401 from modules.call_queue import wrap_gradio_gpu_call, wrap_queued_call, wrap_gradio_call -from modules import gradio_extensons, sd_schedulers # noqa: F401 +from modules import gradio_extensions, sd_schedulers # noqa: F401 from modules import sd_hijack, sd_models, script_callbacks, ui_extensions, deepbooru, extra_networks, ui_common, ui_postprocessing, progress, ui_loadsave, shared_items, ui_settings, timer, sysinfo, ui_checkpoint_merger, scripts, sd_samplers, processing, ui_extra_networks, ui_toprow, launch_utils from modules.ui_components import FormRow, FormGroup, ToolButton, FormHTML, InputAccordion, ResizeHandleRow from modules.paths import script_path