Import it from @grafloria/renderer.
tsclass SnapController
Methods
constructor(config: Partial<SnapConfig> = {})getConfig(): SnapConfigupdateConfig(patch: Partial<SnapConfig>): voidsyncWithEngineConfig(engine: DiagramEngine): void— Read the snapping knobs off the engine's interaction config.computeSnap(box: Rectangle, others: Rectangle[]): SnapResult— Snapboxagainstothers.snapPointToGrid(point: Point): Point— Quantise a single point to the grid (used by the vertex drag).keepInBounds(box: Rectangle, bounds: Rectangle): Rectangle— Clamp a box so it stays fully insidebounds(no-op when it cannot fit).siblingBoxes(engine: DiagramEngine, excludeIds: Iterable<string> = []): Rectangle[]— World bounding boxes of every node EXCEPTexcludeIds(the moving ones).portPosition(node: NodeModel, port: PortModel): Point— World position of a port — THE one the port is actually drawn at.findPortMagnet( engine: DiagramEngine, worldX: number, worldY: number, options: { excludeNodeId?: string; radius?: number; filter?: (port: PortModel, node: NodeModel) => boolean; } = {} ): PortHit | null— The nearest port to a world point withinsnapToPortRadius— the magnet the connection drag snaps to.excludeNodeIdkeeps a drag from snapping back to the node it started on.findProximityConnection( engine: DiagramEngine, nodeId: string, radius?: number ): ProximityCandidate | null— React-Flow-style proximity connect: after draggingnodeId, is one of ITS ports close enough to a compatible port on another node to auto-link them?buildProximityLinkCommand(candidate: ProximityCandidate): Command— Turn a candidate into the ONE undoable command that creates the link.highlightProximityTarget(engine: DiagramEngine, candidate: ProximityCandidate | null): void— Paint the nearest valid target: exactly the flags the SVG renderer already draws for a connection drag (isValidTarget= eligible,isHighlighted= the one that would win). Clears every other port so the highlight can never go stale — the failure mode of "highlight on, nothing turns it off".
Was this page helpful?