Skip to content

Commit 2cdf969

Browse files
zhongwuzwfacebook-github-bot
authored andcommitted
Fixes ScrollView centerContent not work in some cases (#24817)
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
1 parent c75f062 commit 2cdf969

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

React/Views/ScrollView/RCTScrollView.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ - (BOOL)touchesShouldCancelInContentView:(__unused UIView *)view
298298
- (void)setContentOffset:(CGPoint)contentOffset
299299
{
300300
UIView *contentView = [self contentView];
301-
if (contentView && _centerContent) {
301+
if (contentView && _centerContent && !CGSizeEqualToSize(contentView.frame.size, CGSizeZero)) {
302302
CGSize subviewSize = contentView.frame.size;
303303
CGSize scrollViewSize = self.bounds.size;
304304
if (subviewSize.width <= scrollViewSize.width) {

0 commit comments

Comments
 (0)