mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
Merge pull request #12435 from daswer123/auto-expand
Zoom and pan: fix auto-expand
This commit is contained in:
commit
c7b9394daf
@ -42,6 +42,11 @@ onUiLoaded(async() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detect whether the element has a horizontal scroll bar
|
||||||
|
function hasHorizontalScrollbar(element) {
|
||||||
|
return element.scrollWidth > element.clientWidth;
|
||||||
|
}
|
||||||
|
|
||||||
// Function for defining the "Ctrl", "Shift" and "Alt" keys
|
// Function for defining the "Ctrl", "Shift" and "Alt" keys
|
||||||
function isModifierKey(event, key) {
|
function isModifierKey(event, key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
@ -650,16 +655,14 @@ onUiLoaded(async() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simulation of the function to put a long image into the screen.
|
// Simulation of the function to put a long image into the screen.
|
||||||
// We define the size of the canvas, make a fullscreen to reveal the image, then reduce it to fit into the element.
|
// We detect if an image has a scroll bar or not, make a fullscreen to reveal the image, then reduce it to fit into the element.
|
||||||
// We hide the image and show it to the user when it is ready.
|
// We hide the image and show it to the user when it is ready.
|
||||||
function autoExpand(e) {
|
function autoExpand(e) {
|
||||||
const canvas = document.querySelector(`${elemId} canvas[key="interface"]`);
|
const canvas = document.querySelector(`${elemId} canvas[key="interface"]`);
|
||||||
const isMainTab = activeElement === elementIDs.inpaint || activeElement === elementIDs.inpaintSketch || activeElement === elementIDs.sketch;
|
const isMainTab = activeElement === elementIDs.inpaint || activeElement === elementIDs.inpaintSketch || activeElement === elementIDs.sketch;
|
||||||
|
|
||||||
if (canvas && isMainTab) {
|
if (canvas && isMainTab) {
|
||||||
if (canvas && parseInt(targetElement.style.width) > 862 || parseInt(canvas.width) < 862) {
|
if (hasHorizontalScrollbar(targetElement)) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (canvas) {
|
|
||||||
targetElement.style.visibility = "hidden";
|
targetElement.style.visibility = "hidden";
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
fitToScreen();
|
fitToScreen();
|
||||||
|
Loading…
Reference in New Issue
Block a user