Skip to content

Commit

Permalink
RCTRefreshControl: Updates _applyProgressViewOffset
Browse files Browse the repository at this point in the history
Updates _applyProgressViewOffset with an early return for readability
  • Loading branch information
objectivecosta authored Nov 15, 2022
1 parent c035025 commit bf24c9f
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions React/Views/RefreshControl/RCTRefreshControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,22 @@ - (void)endRefreshingProgrammatically

- (void)_applyProgressViewOffset
{
// progressViewOffset must be converted from the ScrollView parent's coordinate space to
// the coordinate space of the RefreshControl. This ensures that the control respects any
// offset in the view hierarchy, and that progressViewOffset is not inadvertently applied
// multiple times.

// Setting the UIRefreshControl's frame breaks integration with ContentInset from the superview
// if it is a UIScrollView. This integration happens when setting the UIScrollView's .refreshControl
// property. For this reason, setting the frame manually should be avoided, if not needed.
if (_progressViewOffset != 0.f) {
UIView *scrollView = self.superview;
UIView *target = scrollView.superview;
CGPoint rawOffset = CGPointMake(0, _progressViewOffset);
CGPoint converted = [self convertPoint:rawOffset fromView:target];
self.frame = CGRectOffset(self.frame, 0, converted.y);
if (_progressViewOffset == 0.f) {
return;
}

// progressViewOffset must be converted from the ScrollView parent's coordinate space to
// the coordinate space of the RefreshControl. This ensures that the control respects any
// offset in the view hierarchy, and that progressViewOffset is not inadvertently applied
// multiple times.
UIView *scrollView = self.superview;
UIView *target = scrollView.superview;
CGPoint rawOffset = CGPointMake(0, _progressViewOffset);
CGPoint converted = [self convertPoint:rawOffset fromView:target];
self.frame = CGRectOffset(self.frame, 0, converted.y);
}

- (NSString *)title
Expand Down

0 comments on commit bf24c9f

Please sign in to comment.