panToPosition method
Pans the viewport to center on the specified graph position.
Maintains the current zoom level while adjusting pan offset to center the given position in the viewport. Used when clicking on the minimap to jump to a location.
Parameters:
graphPosition: The position in graph coordinates to center on
Example:
// Center viewport on graph position (100, 100)
controller.panToPosition(Offset(100, 100));
Implementation
void panToPosition(Offset graphPosition) {
final screenSize = this.screenSize;
if (screenSize == Size.zero) return;
final centerOffset = Offset(screenSize.width / 2, screenSize.height / 2);
final currentZoom = viewport.zoom;
final newPan = Offset(
centerOffset.dx - graphPosition.dx * currentZoom,
centerOffset.dy - graphPosition.dy * currentZoom,
);
setViewport(viewport.copyWith(x: newPan.dx, y: newPan.dy));
}