@samatawy/diagrams
    Preparing search index...

    Class ConnectionBasics

    Provides basic utilities for handling connections between nodes in a diagram. This includes logic for reconnecting and disconnecting endpoints of connections, inserting and removing intermediate points on connections, synchronizing connection endpoints with their attached nodes, and rendering arrowheads on connections. The methods in this class are designed to work with the diagram's coordinate system and node structure to ensure accurate manipulation of connections within the diagram editor.

    Index

    Constructors

    Methods

    • Determines if a node supports mutable points, which allows for dynamic modification of its points.

      Parameters

      • node: INode

        The node to check.

      Returns boolean

      True if the node supports mutable points, false otherwise.

    • Reconnects a connection node to a new target based on the specified event coordinates.

      Parameters

      • node: INode & IConnection

        The connection node to reconnect.

      • x: number

        The x-coordinate of the new target.

      • y: number

        The y-coordinate of the new target.

      Returns void

    • Disconnects a connection node from its target based on the specified coordinates.

      Parameters

      • node: INode & IConnection

        The connection node to disconnect.

      • x: number

        The x-coordinate of the target to disconnect from.

      • y: number

        The y-coordinate of the target to disconnect from.

      Returns void

    • Inserts a new point into a connection node at the specified coordinates.

      Parameters

      • node: INode

        The connection node to modify.

      • x: number

        The x-coordinate of the new point.

      • y: number

        The y-coordinate of the new point.

      Returns void

    • Removes a point from a connection node at the specified coordinates.

      Parameters

      • node: INode

        The connection node to modify.

      • x: number

        The x-coordinate of the point to remove.

      • y: number

        The y-coordinate of the point to remove.

      Returns void

    • Reassigns one endpoint anchor to the nearest handle supported by its current target node.

      Assumption: the endpoint already targets the intended node. This method does not perform hit testing.

      Parameters

      • node: INode & IConnection

        The connection node containing the endpoint anchor.

      • endpoint: "from" | "to"

        Which endpoint to normalize ('from' or 'to').

      • tolerance: number = 24

        Maximum distance used while selecting the nearest supported handle.

      Returns IConnectionAnchor | undefined

      The updated anchor if one could be resolved, otherwise undefined.

    • Builds a connectable anchor from an already-hit handle and local (unrotated) point. This is a pure normalization step and does not perform hit testing.

      Parameters

      • source: INode

        Node that was hit.

      • handle: NodeHandle

        Handle that was hit.

      • localPoint: IPoint

        Local (unrotated) point that was hit.

      • rect: IRect

        Bounding rectangle of the source node.

      Returns IConnectionAnchor | undefined

      A normalized connection anchor, or undefined when the handle is not connectable.

    • Resolves the connectable anchor, if any, at the current pointer location.

      Parameters

      • node: INode & IConnection

        Connection being re-targeted.

      • x: number

        Pointer x coordinate in canvas space.

      • y: number

        Pointer y coordinate in canvas space.

      Returns IConnectionAnchor | undefined

      The best non-MOVE anchor at the pointer, or MOVE fallback when only body hit is available.