calculatePanAmount method

double calculatePanAmount(
  1. double proximity
)

Calculates the scaled pan amount based on proximity to edge.

proximity is the distance from the edge zone boundary to the pointer, where 0 is at the boundary and edgePadding is at the viewport edge.

Returns panAmount scaled according to useProximityScaling and speedCurve settings.

Implementation

double calculatePanAmount(double proximity) {
  if (!useProximityScaling || edgePadding <= 0) {
    return panAmount;
  }

  // Normalize proximity to 0-1 range (0 = at boundary, 1 = at edge)
  final normalizedProximity = (proximity / edgePadding).clamp(0.0, 1.0);

  // Apply curve if provided, otherwise use linear scaling
  final scaleFactor =
      speedCurve?.transform(normalizedProximity) ?? normalizedProximity;

  // Scale from 0.3x to 1.5x the base amount
  // This ensures some panning even at the boundary while accelerating near edge
  return panAmount * (0.3 + scaleFactor * 1.2);
}