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];
}
// 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
async function waitForOpts() {
return new Promise(resolve => {
@ -101,10 +93,13 @@ function restoreImgRedMask(elements, elementIDs) {
imageARPreview.style.transform = "";
if (parseFloat(mainTab.style.width) > 865) {
const transformValues = mainTab.style.transform
.match(/[-+]?[0-9]*\.?[0-9]+/g)
.map(Number);
const [posX, posY, zoom] = transformValues;
const transformString = mainTab.style.transform;
const scaleMatch = transformString.match(/scale\(([-+]?[0-9]*\.?[0-9]+)\)/);
let zoom = 1; // default zoom
if (scaleMatch && scaleMatch[1]) {
zoom = Number(scaleMatch[1]);
}
imageARPreview.style.transformOrigin = "0 0";
imageARPreview.style.transform = `scale(${zoom})`;
@ -116,7 +111,7 @@ function restoreImgRedMask(elements, elementIDs) {
setTimeout(() => {
img.style.display = "none";
}, 300);
}, 400);
}
// Main