Fix the clip rect computation for removeClippedSubviews
Summary: The computation for calculateClippingRect didn't work if you had a horizontal scroll nested in a vertical scroll view. The fix is to simplify the logic to first intersect the inner view within its parent and then apply transforms (translation by top/left and scroll offset). That now provides the correct clipping rectangle for nested views. Reviewed By: astreet Differential Revision: D3087367 fb-gh-sync-id: efdd430e024c4599189ddb8dbb258fd2b118690f shipit-source-id: efdd430e024c4599189ddb8dbb258fd2b118690f
This commit is contained in:
parent
67efe4c1a9
commit
e8e31823b9
|
@ -45,12 +45,16 @@ public class ReactClippingViewGroupHelper {
|
||||||
ReactClippingViewGroup clippingViewGroup = (ReactClippingViewGroup) parent;
|
ReactClippingViewGroup clippingViewGroup = (ReactClippingViewGroup) parent;
|
||||||
if (clippingViewGroup.getRemoveClippedSubviews()) {
|
if (clippingViewGroup.getRemoveClippedSubviews()) {
|
||||||
clippingViewGroup.getClippingRect(sHelperRect);
|
clippingViewGroup.getClippingRect(sHelperRect);
|
||||||
sHelperRect.offset(-view.getLeft(), -view.getTop());
|
// Intersect the view with the parent's rectangle
|
||||||
view.getDrawingRect(outputRect);
|
// This will result in the overlap with coordinates in the parent space
|
||||||
if (!outputRect.intersect(sHelperRect)) {
|
if (!sHelperRect.intersect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom())) {
|
||||||
// rectangles does not intersect -> we should write empty rect to output
|
|
||||||
outputRect.setEmpty();
|
outputRect.setEmpty();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
// Now we move the coordinates to the View's coordinate space
|
||||||
|
sHelperRect.offset(-view.getLeft(), -view.getTop());
|
||||||
|
sHelperRect.offset(view.getScrollX(), view.getScrollY());
|
||||||
|
outputRect.set(sHelperRect);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue