|
21 | 21 | import static com.google.android.material.animation.AnimationUtils.lerp; |
22 | 22 | import static java.lang.Math.abs; |
23 | 23 | import static java.lang.Math.max; |
24 | | -import static java.lang.Math.min; |
25 | 24 |
|
26 | 25 | import android.graphics.Canvas; |
27 | 26 | import android.graphics.Color; |
@@ -773,16 +772,17 @@ private void updateChildMaskForLocation( |
773 | 772 |
|
774 | 773 | // If the carousel is a CONTAINED carousel, ensure the mask collapses against the side of the |
775 | 774 | // container instead of bleeding and being clipped by the RecyclerView's bounds. |
| 775 | + // Only do this if there is only one side of the mask that is out of bounds; if |
| 776 | + // both sides are out of bounds on the same side, then the whole mask is out of view. |
776 | 777 | if (carouselStrategy.isContained()) { |
777 | 778 | float offsetCx = calculateChildOffsetCenterForLocation(child, childCenterLocation, range); |
778 | 779 | float maskedLeft = offsetCx - (maskRect.width() / 2F); |
779 | 780 | float maskedRight = offsetCx + (maskRect.width() / 2F); |
780 | | - |
781 | | - if (maskedLeft < getParentLeft()) { |
782 | | - maskRect.left = min(maskRect.left + (getParentLeft() - maskedLeft), childWidth / 2F); |
| 781 | + if (maskedLeft < getParentLeft() && maskedRight >= getParentLeft()) { |
| 782 | + maskRect.left = maskRect.left + (getParentLeft() - maskedLeft); |
783 | 783 | } |
784 | | - if (maskedRight > getParentRight()) { |
785 | | - maskRect.right = max(maskRect.right - (maskedRight - getParentRight()), childWidth / 2F); |
| 784 | + if (maskedRight > getParentRight() && maskedLeft <= getParentRight()) { |
| 785 | + maskRect.right = max(maskRect.right - (maskedRight - getParentRight()), maskRect.left); |
786 | 786 | } |
787 | 787 | } |
788 | 788 | ((Maskable) child).setMaskRectF(maskRect); |
|
0 commit comments