MCPcopy Create free account
hub / github.com/dashrobotco/robot-components / handleConnectionDragStart

Function handleConnectionDragStart

app/nodegrid/page.tsx:1663–1705  ·  view source on GitHub ↗
(e: React.MouseEvent)

Source from the content-addressed store, hash-verified

1661
1662 // Handle connection drag start (mouse)
1663 const handleConnectionDragStart = (e: React.MouseEvent) => {
1664 e.stopPropagation();
1665 e.preventDefault();
1666
1667 const panel = panelRef.current;
1668 if (!panel) return;
1669
1670 const rect = panel.getBoundingClientRect();
1671 // Connection starts from the right side of the panel (where the triangle icon is)
1672 const startX = rect.right - 10;
1673 const startY = rect.top + 10;
1674
1675 onConnectionDragStart?.(id, startX, startY);
1676
1677 const handleMouseMove = (moveEvent: MouseEvent) => {
1678 onConnectionDragMove?.(moveEvent.clientX, moveEvent.clientY);
1679 };
1680
1681 const handleMouseUp = (upEvent: MouseEvent) => {
1682 document.removeEventListener('mousemove', handleMouseMove);
1683 document.removeEventListener('mouseup', handleMouseUp);
1684
1685 // Check if we're over another panel
1686 const elementsAtPoint = document.elementsFromPoint(upEvent.clientX, upEvent.clientY);
1687 let targetPanelId: string | null = null;
1688
1689 for (const el of elementsAtPoint) {
1690 const panelEl = el.closest('[data-panel-id]');
1691 if (panelEl) {
1692 const panelId = panelEl.getAttribute('data-panel-id');
1693 if (panelId && panelId !== id) {
1694 targetPanelId = panelId;
1695 break;
1696 }
1697 }
1698 }
1699
1700 onConnectionDragEnd?.(id, targetPanelId, upEvent.clientX, upEvent.clientY);
1701 };
1702
1703 document.addEventListener('mousemove', handleMouseMove);
1704 document.addEventListener('mouseup', handleMouseUp);
1705 };
1706
1707 // Handle connection drag start (touch)
1708 const handleConnectionTouchStart = (e: React.TouchEvent) => {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected