moveNode method

void moveNode(
  1. String nodeId,
  2. Offset delta
)

Moves a node by the specified delta.

The node's new position will be automatically snapped to the grid if snap-to-grid is enabled in the controller's configuration.

Does nothing if the node doesn't exist.

Parameters:

  • nodeId: The ID of the node to move
  • delta: The offset to move the node by

Implementation

void moveNode(String nodeId, Offset delta) {
  final node = _nodes[nodeId];
  if (node != null) {
    runInAction(() {
      final newPosition = node.position.value + delta;
      node.position.value = newPosition;
      // Update visual position with snapping
      node.setVisualPosition(_config.snapToGridIfEnabled(newPosition));
    });
  }
}