Permalink
Browse files

Fixes removeClipSubviews check for offscreen rendering of ListViews

Summary:
This issue has been open for a really long time, but I'm pretty sure this is the line that needed to change:
#1831

What was happening here is that `CGRectIsEmpty` returns true when either height or width is zero. With the current logic, one of those would always be zero when the parent was rendered off screen. This ensures that there the intersection be of CGSizeZero for the view to actually be clipped.

That being said, there seems to be something more complex going on here that I'm not understanding? I would think that you'd simply want to check if the child view's frame is within the bounds of the parent at all. If it was, then don't clip it. If I'm in the wrong, could someone explain this a bit more? If so, I'll fix this issue.

Using this [repository](https://github.com/jcharlet/react_native_listview_bug), this one line change fixes the issue and still clips cells as they are scrolled off screen.
Closes #15669

Differential Revision: D5815056

Pulled By: shergin

fbshipit-source-id: 32382e4954139e4d5af67d786422fd87173b1a1a
  • Loading branch information...
MattFoley authored and facebook-github-bot committed Sep 26, 2017
1 parent e3a6be5 commit 03ae65bc25185fe6d7f62e66f5575ced5c3e8378
Showing with 1 addition and 2 deletions.
  1. +1 −2 React/Views/RCTView.m
View
@@ -346,8 +346,7 @@ - (void)react_updateClippedSubviewsWithClipRect:(CGRect)clipRect relativeToView:
// Mount / unmount views
for (UIView *view in self.reactSubviews) {
if (!CGRectIsEmpty(CGRectIntersection(clipRect, view.frame))) {
if (!CGSizeEqualToSize(CGRectIntersection(clipRect, view.frame).size, CGSizeZero)) {
// View is at least partially visible, so remount it if unmounted
[self addSubview:view];

0 comments on commit 03ae65b

Please sign in to comment.