MCPcopy Index your code
hub / github.com/cifertech/DisplayKit / onMouseMove

Function onMouseMove

app.js:4574–4628  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

4572 });
4573
4574 function onMouseMove(e) {
4575 if (!isDragging) return;
4576 const scale = parseFloat(preview.dataset.scale || "1");
4577 const z = clamp(zoomFactor || 1, 0.5, 3);
4578 const effectiveScale = scale * z;
4579 let dx = (e.clientX - startX) / effectiveScale;
4580 let dy = (e.clientY - startY) / effectiveScale;
4581
4582 let newX = origX + dx;
4583 let newY = origY + dy;
4584
4585 const suppressSnap = e.ctrlKey || e.metaKey;
4586 const snapped = snapMoveToElements(id, newX, newY, { suppressSnap });
4587 newX = snapped.x;
4588 newY = snapped.y;
4589
4590 if (snapToGrid && gridSize > 0 && !suppressSnap) {
4591 newX = Math.round(newX / gridSize) * gridSize;
4592 newY = Math.round(newY / gridSize) * gridSize;
4593 }
4594
4595 const leadOrig = dragOrig.get(id) || { x: origX, y: origY };
4596 const ddx = Math.round(newX) - Math.round(leadOrig.x);
4597 const ddy = Math.round(newY) - Math.round(leadOrig.y);
4598
4599 dragIds.forEach((sid) => {
4600 const s = elements.find((x) => x.id === sid);
4601 const o = dragOrig.get(sid);
4602 if (!s || !o) return;
4603 s.x = Math.round(o.x + ddx);
4604 s.y = Math.round(o.y + ddy);
4605 });
4606
4607 // Snap guides (in preview coordinates)
4608 const guides = ensureSnapGuides();
4609 if (guides.v && snapped.gx != null) {
4610 guides.v.style.left = snapped.gx * scale + "px";
4611 guides.v.classList.add("show");
4612 } else if (guides.v) {
4613 guides.v.classList.remove("show");
4614 }
4615 if (guides.h && snapped.gy != null) {
4616 guides.h.style.top = snapped.gy * scale + "px";
4617 guides.h.classList.add("show");
4618 } else if (guides.h) {
4619 guides.h.classList.remove("show");
4620 }
4621
4622 updatePropsInputs(false);
4623 renderElements();
4624 renderLayers();
4625 updateCode();
4626 const elLead = elements.find((x) => x.id === id);
4627 if (elLead) updateDistanceHintsForDrag(id, elLead.x, elLead.y, elLead.w, elLead.h);
4628 }
4629
4630 function onMouseUp() {
4631 if (isDragging) {

Callers

nothing calls this directly

Calls 8

snapMoveToElementsFunction · 0.85
ensureSnapGuidesFunction · 0.85
updatePropsInputsFunction · 0.85
renderElementsFunction · 0.85
renderLayersFunction · 0.85
updateCodeFunction · 0.85
clampFunction · 0.70

Tested by

no test coverage detected