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

Function onResizeMove

app.js:4397–4449  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

4395 });
4396
4397 function onResizeMove(e) {
4398 if (!isResizing) return;
4399 const elLock = elements.find((el) => el.id === elementId);
4400 if (!elLock || elLock.locked || elLock.hidden) return;
4401 const scale = parseFloat(preview.dataset.scale || "1");
4402 const z = clamp(zoomFactor || 1, 0.5, 3);
4403 const effectiveScale = scale * z;
4404 const dx = (e.clientX - startX) / effectiveScale;
4405 const dy = (e.clientY - startY) / effectiveScale;
4406
4407 const el = elements.find((el) => el.id === elementId);
4408 if (!el) return;
4409
4410 let newWidth = startWidth;
4411 let newHeight = startHeight;
4412 let newX = startXPos;
4413 let newY = startYPos;
4414
4415
4416 if (direction.includes("e")) {
4417 newWidth = Math.max(10, startWidth + dx);
4418 }
4419 if (direction.includes("w")) {
4420 newWidth = Math.max(10, startWidth - dx);
4421 newX = startXPos + dx;
4422 }
4423 if (direction.includes("s")) {
4424 newHeight = Math.max(10, startHeight + dy);
4425 }
4426 if (direction.includes("n")) {
4427 newHeight = Math.max(10, startHeight - dy);
4428 newY = startYPos + dy;
4429 }
4430
4431
4432 if (snapToGrid && gridSize > 0 && !e.ctrlKey && !e.metaKey) {
4433 newWidth = Math.round(newWidth / gridSize) * gridSize;
4434 newHeight = Math.round(newHeight / gridSize) * gridSize;
4435 newX = Math.round(newX / gridSize) * gridSize;
4436 newY = Math.round(newY / gridSize) * gridSize;
4437 }
4438
4439 el.w = Math.round(newWidth);
4440 el.h = Math.round(newHeight);
4441 el.x = Math.round(newX);
4442 el.y = Math.round(newY);
4443
4444 updatePropsInputs(false);
4445 renderElements();
4446 renderLayers();
4447 updateCode();
4448 updateDistanceHintsForDrag(elementId, el.x, el.y, el.w, el.h);
4449 }
4450
4451 function onResizeUp() {
4452 if (isResizing) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected