Skip to content

Commit

Permalink
Fixes ScrollView centerContent not work in some cases (#24817)
Browse files Browse the repository at this point in the history
Summary:
The bug description can see #24688, we add `contentView` size check before center the content, because in some cases, the contentView's size not yet be calculated, in those cases, we don't adjust the `contentOffset`.

cc. cpojer .

[iOS] [Fixed] - Fixes ScrollView centerContent not work in some cases
Pull Request resolved: #24817

Differential Revision: D15322502

Pulled By: sahrens

fbshipit-source-id: e2081f13e9f2e8597a379a9db1607451ea496909
  • Loading branch information
zhongwuzw authored and facebook-github-bot committed May 13, 2019
1 parent c75f062 commit 2cdf969
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion React/Views/ScrollView/RCTScrollView.m
Expand Up @@ -298,7 +298,7 @@ - (BOOL)touchesShouldCancelInContentView:(__unused UIView *)view
- (void)setContentOffset:(CGPoint)contentOffset
{
UIView *contentView = [self contentView];
if (contentView && _centerContent) {
if (contentView && _centerContent && !CGSizeEqualToSize(contentView.frame.size, CGSizeZero)) {
CGSize subviewSize = contentView.frame.size;
CGSize scrollViewSize = self.bounds.size;
if (subviewSize.width <= scrollViewSize.width) {
Expand Down

0 comments on commit 2cdf969

Please sign in to comment.