dragEdge()

in src/components/graph-view-v2.js [1249:1282]


  dragEdge(draggedEdge?: IEdge, mouse: typeof d3.mouse) {
    const { nodeSize, nodeKey } = this.props;

    draggedEdge = draggedEdge || this.state.draggedEdge;

    if (!draggedEdge) {
      return;
    }

    const mouseCoordinates = this.getMouseCoordinates(mouse);
    const targetPosition = {
      x: mouseCoordinates[0],
      y: mouseCoordinates[1],
    };

    const off = calculateOffset(
      nodeSize,
      (this.getNodeById(draggedEdge.source): any).node,
      targetPosition,
      nodeKey
    );

    targetPosition.x += off.xOff;
    targetPosition.y += off.yOff;
    this.syncRenderEdge(
      { source: draggedEdge.source, targetPosition },
      false,
      true
    );
    this.setState({
      draggedEdge,
      draggingEdge: true,
    });
  }