@joint/react
    Preparing search index...

    Type Alias ConnectionStrategy

    ConnectionStrategy: (context: ConnectionStrategyParams) => dia.Link.EndJSON

    Computes the final end definition stored on a link after one of its ends is dropped. Pass it (or a ConnectionStrategyOptions object) to the connectionStrategy prop of <Paper>; the callback receives a structured ConnectionStrategyParams context and returns the end JSON to save.

    Type Declaration

      • (context: ConnectionStrategyParams): dia.Link.EndJSON
      • Parameters

        • context: ConnectionStrategyParams

          Context handed to a ConnectionStrategy customize callback after a link end is dropped. Describes where the end landed (cell, magnet, drop point) so the callback can return the final end definition.

          Context handed to a ConnectionStrategy customize callback after a link end is dropped. Describes where the end landed (cell, magnet, drop point) so the callback can return the final end definition.

          • ReadonlydropPoint: PlainPoint

            Paper-space point where the end was dropped.

          • Readonlyend: EndJSON

            The end definition to return, pre-filled by the selected pin mode (or the dropped end when pinning is off).

          • ReadonlyendType: LinkEnd

            Which end was dropped: 'source' or 'target'.

          • Readonlygraph: Graph

            The graph the link belongs to.

          • The link being reconnected.

          • Readonlymagnet: Element

            The magnet element the end was dropped on.

          • Readonlymodel: Cell

            The cell the end was dropped on.

          • Readonlypaper: Paper

            The paper the link is drawn on.

        Returns dia.Link.EndJSON

    import { GraphProvider, Paper } from '@joint/react';
    import type { ConnectionStrategy } from '@joint/react';

    // Snap the dropped end exactly to the pointer position.
    const strategy: ConnectionStrategy = ({ end, dropPoint }) => ({ ...end, x: dropPoint.x, y: dropPoint.y });

    <GraphProvider>
    <Paper connectionStrategy={strategy} renderElement={() => <rect width={80} height={40} />} />
    </GraphProvider>;