(input, key)
| 6455 | |
| 6456 | |
| 6457 | function bindNumeric(input, key) { |
| 6458 | input.addEventListener("input", () => { |
| 6459 | const el = elements.find((el) => el.id === selectedId); |
| 6460 | if (!el) return; |
| 6461 | if ((el.type === "image" || el.type === "icon") && (key === "w" || key === "h")) { |
| 6462 | input.value = el[key]; |
| 6463 | return; |
| 6464 | } |
| 6465 | let v = parseInt(input.value, 10); |
| 6466 | if (isNaN(v)) v = 0; |
| 6467 | if (snapToGrid && (key === "x" || key === "y") && gridSize > 0) { |
| 6468 | v = Math.round(v / gridSize) * gridSize; |
| 6469 | } |
| 6470 | el[key] = v; |
| 6471 | renderElements(); |
| 6472 | renderLayers(); |
| 6473 | updateCode(); |
| 6474 | pushHistory(); |
| 6475 | |
| 6476 | // If user resized an icon via inputs, recompute the bitmap for code export |
| 6477 | if (el.type === "icon" && (key === "w" || key === "h")) { |
| 6478 | scheduleRecomputeSelectedIcon(); |
| 6479 | } |
| 6480 | }); |
| 6481 | } |
| 6482 | |
| 6483 | /** Drag numeric labels horizontally to scrub values (Figma-like). */ |
| 6484 | function bindScrubLabel(labelEl, inputEl, opts) { |
no test coverage detected