MCPcopy Create free account
hub / github.com/Shitanshukumar607/Drawspace / handlePointerMove

Function handlePointerMove

hooks/DrawRectangleTool.ts:62–79  ·  view source on GitHub ↗
(e: KonvaEventObject<MouseEvent | TouchEvent>)

Source from the content-addressed store, hash-verified

60 };
61
62 const handlePointerMove = (e: KonvaEventObject<MouseEvent | TouchEvent>) => {
63 if (!isDrawing.current || tool !== "rectangle") return;
64
65 const stage = e.target.getStage();
66 const pos = stage ? getPointerPositionRelativeToStage(stage) : null;
67 if (!pos) return;
68
69 const current = currentDraw.current;
70 if (!current) return;
71
72 const { startX, startY, id } = current;
73 const x = Math.min(startX, pos.x);
74 const y = Math.min(startY, pos.y);
75 const width = Math.max(Math.abs(pos.x - startX), 1);
76 const height = Math.max(Math.abs(pos.y - startY), 1);
77
78 updateRectangleInStore(id, { x, y, width, height });
79 };
80
81 const handlePointerUp = () => {
82 isDrawing.current = false;

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected