Correct definition zoom level

I changed the regular expression and now I always have to select scale from style.transfo
This commit is contained in:
Danil Boldyrev 2023-06-04 04:17:55 +03:00
parent ad3d6d9a22
commit 0432e37843
1 changed files with 8 additions and 13 deletions

View File

@ -23,14 +23,6 @@ function getTabId(elements, elementIDs) {
return tabIdLookup[activeTab.innerText]; return tabIdLookup[activeTab.innerText];
} }
// Get Active main tab to prevent "Undo" on text2img from being disabled
function getActiveMainTab() {
const selectedTab = gradioApp().querySelector(
"#tabs .tab-nav button.selected"
);
return selectedTab;
}
// Wait until opts loaded // Wait until opts loaded
async function waitForOpts() { async function waitForOpts() {
return new Promise(resolve => { return new Promise(resolve => {
@ -101,10 +93,13 @@ function restoreImgRedMask(elements, elementIDs) {
imageARPreview.style.transform = ""; imageARPreview.style.transform = "";
if (parseFloat(mainTab.style.width) > 865) { if (parseFloat(mainTab.style.width) > 865) {
const transformValues = mainTab.style.transform const transformString = mainTab.style.transform;
.match(/[-+]?[0-9]*\.?[0-9]+/g) const scaleMatch = transformString.match(/scale\(([-+]?[0-9]*\.?[0-9]+)\)/);
.map(Number); let zoom = 1; // default zoom
const [posX, posY, zoom] = transformValues;
if (scaleMatch && scaleMatch[1]) {
zoom = Number(scaleMatch[1]);
}
imageARPreview.style.transformOrigin = "0 0"; imageARPreview.style.transformOrigin = "0 0";
imageARPreview.style.transform = `scale(${zoom})`; imageARPreview.style.transform = `scale(${zoom})`;
@ -116,7 +111,7 @@ function restoreImgRedMask(elements, elementIDs) {
setTimeout(() => { setTimeout(() => {
img.style.display = "none"; img.style.display = "none";
}, 300); }, 400);
} }
// Main // Main