getLimitedRect method
Applies per-axis friction damping when the rect's edges cross the
container in the direction of focalPointDelta.
Implementation
Rect getLimitedRect({
required Rect container,
required Offset focalPointDelta,
required Offset friction,
}) {
final endX = getLimitedCenterXInside(container);
final endY = getLimitedCenterYInside(container);
/// if we need to limit the rect and apply friction on the horizontal axis
final limitX = endX != center.dx && endX < center.dx == focalPointDelta.dx > 0;
/// if we need to limit the rect and apply friction on the vertical axis
final limitY = endY != center.dy && endY < center.dy == focalPointDelta.dy > 0;
final dx = limitX ? -friction.dx : 0.0;
final dy = limitY ? -friction.dy : 0.0;
return translate(dx, dy);
}