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.

Implementation

void moveNode(String nodeId, Offset delta) {
  final node = _nodes[nodeId];
  if (node != null) {
    final previousPosition = node.position.value;
    runInAction(() {
      final newPosition = previousPosition + delta;
      node.position.value = newPosition;
      // Update visual position with snapping
      node.setVisualPosition(_config.snapToGridIfEnabled(newPosition));
    });
    internalMarkNodeDirty(nodeId);
    // Emit extension event
    _emitEvent(NodeMoved<T>(node, previousPosition));
  }
}