Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,19 @@ - (void)updateState:(const State::Shared &)state oldState:(const State::Shared &
}

_contentSize = contentSize;
_containerView.frame = CGRect{RCTCGPointFromPoint(data.contentBoundingRect.origin), contentSize};

// `_containerView` is the scroll view's zooming view (see `viewForZoomingInScrollView:`), so while the user is
// pinch-zoomed in it carries a scale transform. Setting `frame` on a view whose `transform` is not the identity is
// undefined behavior, so lay it out through `bounds` and `center` instead. The scroll view must get the *zoomed*
// size, which is what UIScrollView itself keeps `contentSize` at while zooming.
CGPoint contentOrigin = RCTCGPointFromPoint(data.contentBoundingRect.origin);
_containerView.bounds = CGRect{CGPointZero, contentSize};
CGSize zoomedContentSize = _containerView.frame.size;
_containerView.center =
CGPoint{contentOrigin.x + zoomedContentSize.width / 2, contentOrigin.y + zoomedContentSize.height / 2};

[self _preserveContentOffsetIfNeededWithBlock:^{
self->_scrollView.contentSize = contentSize;
self->_scrollView.contentSize = zoomedContentSize;
}];
}

Expand Down