moveNode method

void moveNode(
  1. VSNodeData nodeData,
  2. Offset offset
)

Used to move one or mulitple nodes

Offset will be applied to all nodes based on the offset from the moved nodes original position

Implementation

void moveNode(VSNodeData nodeData, Offset offset) {
  final movedOffset = applyViewPortTransfrom(offset) - nodeData.widgetOffset;

  final List<VSNodeData> modifiedNodes = [];

  if (selectedNodes.contains(nodeData.id)) {
    for (final nodeId in selectedNodes) {
      final currentNode = nodes[nodeId]!;
      modifiedNodes.add(
        currentNode..widgetOffset = currentNode.widgetOffset + movedOffset,
      );
    }
  } else {
    modifiedNodes.add(
      nodeData..widgetOffset = nodeData.widgetOffset + movedOffset,
    );
  }

  updateOrCreateNodes(modifiedNodes);
}