zoomAt method

void zoomAt(
  1. Offset center,
  2. double factor
)

Zoom while keeping center (in viewport-local coordinates) stable.

Implementation

void zoomAt(Offset center, double factor) {
  final current = _state.scale;
  final desired = (current * factor).clamp(minScale, maxScale).toDouble();
  if (desired == current) return;
  final ratio = desired / current - 1.0;
  final newOffset = _state.offset - (center - _state.offset) * ratio;
  _state = ViewportState(scale: desired, offset: newOffset);
  notifyListeners();
}