internalMoveAnnotationDrag method

void internalMoveAnnotationDrag(
  1. Offset newPointerPosition,
  2. Offset graphDelta,
  3. Map<String, Node<T>> nodes
)

Implementation

void internalMoveAnnotationDrag(
  Offset newPointerPosition,
  Offset graphDelta,
  Map<String, Node<T>> nodes,
) {
  final draggedId = _draggedAnnotationId.value;
  if (draggedId == null || _lastPointerPosition.value == null) return;

  runInAction(() {
    // Move the dragged annotation - use EXACT same logic as nodes
    final annotation = _annotations[draggedId];
    if (annotation != null) {
      final newPosition = annotation.currentPosition + graphDelta;
      annotation.setPosition(newPosition);
      // Update visual position with snapping (identical to node behavior)
      annotation.setVisualPosition(
        _parentController.config.snapAnnotationsToGridIfEnabled(newPosition),
      );

      // If this is a group annotation, move all dependent nodes
      if (annotation is GroupAnnotation && annotation.hasAnyDependencies) {
        _moveGroupDependentNodes(annotation, graphDelta, nodes);
      }
    }

    _lastPointerPosition.value = newPointerPosition;
  });
}