Fix custom ratio widget rendering

This commit is contained in:
2026-10-22 13:04:59 +00:00
parent 21fec91a7e
commit 0e6bcc1c20
+5 -1
View File
@@ -145,7 +145,11 @@ function render(node, root) {
const widthInput=document.createElement("input"); widthInput.type="number"; widthInput.dataset.key="w"; widthInput.value=s.w; widthInput.title="Width";
const heightInput=document.createElement("input"); heightInput.type="number"; heightInput.value=s.h; heightInput.title="Height"; heightInput.readOnly=true;
dimensions.append(widthInput,heightInput); panel.append(dimensions);
const preview=document.createElement("div"); preview.className="preview"; const shape=document.createElement("div"); shape.className="preview-shape"; shape.style.aspectRatio=`${Math.max(1,Number(s.w))} / ${Math.max(1,Number(s.h))}`; shape.style.width=`${Math.min(90, Math.max(34, 90 * Number(s.w) / Math.max(Number(s.h), Number(s.w)))}px)`; shape.style.height="42px"; preview.append(shape); panel.append(preview);
const preview=document.createElement("div"); preview.className="preview";
const shape=document.createElement("div"); shape.className="preview-shape";
const shapeWidth=Math.min(90, Math.max(34, 90 * Number(s.w) / Math.max(Number(s.h), Number(s.w))));
shape.style.width=`${shapeWidth}px`; shape.style.height="42px";
preview.append(shape); panel.append(preview);
} else {
const fields = [["custom_w", "Width"],["custom_h", "Height"]];
for (const [key, text] of fields) { const input=document.createElement("input"); input.dataset.key=key; input.type="number"; input.title=text; input.value=s[key]; input.placeholder=text; panel.append(input); }