moveSelectedNodes method

void moveSelectedNodes(
  1. Offset delta
)

Moves all selected nodes by the specified delta.

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

Does nothing if no nodes are selected.

Parameters:

  • delta: The offset to move the selected nodes by

Implementation

void moveSelectedNodes(Offset delta) {
  final nodeIds = _selectedNodeIds.toList();
  if (nodeIds.isEmpty) return;

  runInAction(() {
    // Batch position updates
    for (final nodeId in nodeIds) {
      final node = _nodes[nodeId];
      if (node != null) {
        final newPosition = node.position.value + delta;
        node.position.value = newPosition;
        // Update visual position with snapping
        node.setVisualPosition(_config.snapToGridIfEnabled(newPosition));
      }
    }
  });
}