MCPcopy Create free account
hub / github.com/cifertech/DisplayKit / bindScrubLabel

Function bindScrubLabel

app.js:6484–6508  ·  view source on GitHub ↗

Drag numeric labels horizontally to scrub values (Figma-like).

(labelEl, inputEl, opts)

Source from the content-addressed store, hash-verified

6482
6483/** Drag numeric labels horizontally to scrub values (Figma-like). */
6484function bindScrubLabel(labelEl, inputEl, opts) {
6485 const isRotation = !!(opts && opts.isRotation);
6486 if (!labelEl || !inputEl) return;
6487 labelEl.addEventListener("mousedown", (e) => {
6488 if (e.button !== 0) return;
6489 e.preventDefault();
6490 const startX = e.clientX;
6491 const base = isRotation ? (parseFloat(inputEl.value) || 0) : (parseInt(inputEl.value, 10) || 0);
6492 function onMove(ev) {
6493 const dx = ev.clientX - startX;
6494 const scale = ev.shiftKey ? 2 : ev.altKey ? 0.25 : 1;
6495 const next = isRotation
6496 ? Math.round(base + dx * 0.35 * scale)
6497 : Math.round(base + dx * 0.12 * scale);
6498 inputEl.value = String(next);
6499 inputEl.dispatchEvent(new Event("input", { bubbles: true }));
6500 }
6501 function onUp() {
6502 document.removeEventListener("mousemove", onMove);
6503 document.removeEventListener("mouseup", onUp);
6504 }
6505 document.addEventListener("mousemove", onMove);
6506 document.addEventListener("mouseup", onUp);
6507 });
6508}
6509
6510bindNumeric(propX, "x");
6511bindNumeric(propY, "y");

Callers 1

app.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected