Drag nodes, combos, and edges

Move nodes and combos or reconnect an edge endpoint

Drag nodes and combos · Drag edge endpoints

Drag nodes and combos

Enable drag-node to move nodes. Dragging a selected node moves the other selected nodes with it. Dragging empty space inside a combo moves the whole combo.

Loading example…
Drag a node or the background inside a combo. Shift-click to add to the selection.
behaviors: [
  'zoom-canvas',
  'drag-canvas',
  { type: 'click-select', multiple: true, trigger: 'shift' },
  'drag-node',
],

Use the combo API to change membership. Combo methods

Drag an edge endpoint

Enable drag-edge to drag an endpoint. On release, edge:dragend reports the proposed endpoints. Use updateEdgeData() to save an accepted reconnection.

Loading example…
Start on the A–B edge near B, then release on C.
graph.on('edge:dragend', ({ edgeId, source, target, reconnected }) => {
  if (reconnected && edgeId) {
    graph.updateEdgeData([{ id: edgeId, source, target }]);
  }
  ui.setStatus(`dragend reconnected=${reconnected}\n${edgeId ?? '-'}: ${source} → ${target}`);
});