Skip to content

Commit

Permalink
Fixes removeClipSubviews check for offscreen rendering of ListViews
Browse files Browse the repository at this point in the history
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
tfallon@mail.depaul.edu authored and facebook-github-bot committed Sep 26, 2017
1 parent e3a6be5 commit 03ae65b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions React/Views/RCTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down

0 comments on commit 03ae65b

Please sign in to comment.