getClipOriginForOverlap method

  1. @protected
double getClipOriginForOverlap(
  1. double insideClipExtent
)
inherited

Computes the main-axis offset at which the clip's leading edge should start so it reacts to the region overlapped by other slivers (such as a pinned header).

The insideClipExtent is the part of the clip allowed to slide under the overlap before its edge moves: the full extent for ClipOverlapBehavior.followEdge, or the middle rect for ClipOverlapBehavior.preserveShape. The result is clamped between the already-scrolled content and the current overlap.

Implementation

@protected
double getClipOriginForOverlap(double insideClipExtent) {
  final double effectiveOverlap = math.max(0.0, constraints.overlap);
  final double flexibleClipExtent = math.max(
    0.0,
    insideClipExtent - geometry!.maxScrollObstructionExtent,
  );
  // To handle leading side of the viewport.
  final double minClipOrigin = -math.min(flexibleClipExtent, constraints.scrollOffset);

  // When flexibleClipExtent is scrolled, we can push up the clip.
  return clampDouble(
    flexibleClipExtent - constraints.scrollOffset,
    minClipOrigin,
    effectiveOverlap,
  );
}