(node: MapNodeLayout, id: string, type: 'source' | 'target')
| 577 | * one the browser will measure. |
| 578 | */ |
| 579 | export function portPoint(node: MapNodeLayout, id: string, type: 'source' | 'target'): { x: number; y: number } { |
| 580 | const top = node.ports.top.findIndex((p) => p.id === id && p.type === type); |
| 581 | if (top >= 0) return { x: node.x + (node.width * (top + 1)) / (node.ports.top.length + 1), y: node.y }; |
| 582 | const bottom = node.ports.bottom.findIndex((p) => p.id === id && p.type === type); |
| 583 | if (bottom >= 0) { |
| 584 | return { |
| 585 | x: node.x + (node.width * (bottom + 1)) / (node.ports.bottom.length + 1), |
| 586 | y: node.y + node.height, |
| 587 | }; |
| 588 | } |
| 589 | return { x: node.x + node.width / 2, y: type === 'source' ? node.y + node.height : node.y }; |
| 590 | } |
| 591 | |
| 592 | interface SidePort extends PortRef { |
| 593 | /** Centre x of the link's other end — the sort key along the side. */ |
no outgoing calls
no test coverage detected