diff --git a/js/dumas_resolution.js b/js/dumas_resolution.js index 480ae8d..4598aba 100644 --- a/js/dumas_resolution.js +++ b/js/dumas_resolution.js @@ -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); }