mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Restore contentOffset from state if necesarry
Summary: Changelog: [Internal] When JS Inspector is activated, ScrollView is unmounted and then mounted again with same state. ScrollView's content offset was being set to 0 inside `[RCTScrollViewComponentView prepareForRecycle]` during unmount but when it is mounted again, we ignored value inside state. Reviewed By: shergin Differential Revision: D22333125 fbshipit-source-id: f232dc95b695605f4819f29d8e0bf14b2f3e9150
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b2c775ca7a
commit
42c8dead62
@@ -201,8 +201,14 @@ void RCTSetEnableOnDemandViewMounting(BOOL value)
|
||||
{
|
||||
assert(std::dynamic_pointer_cast<ScrollViewShadowNode::ConcreteState const>(state));
|
||||
_state = std::static_pointer_cast<ScrollViewShadowNode::ConcreteState const>(state);
|
||||
auto &data = _state->getData();
|
||||
|
||||
CGSize contentSize = RCTCGSizeFromSize(_state->getData().getContentSize());
|
||||
auto contentOffset = RCTCGPointFromPoint(data.contentOffset);
|
||||
if (!oldState && !CGPointEqualToPoint(contentOffset, CGPointZero)) {
|
||||
_scrollView.contentOffset = contentOffset;
|
||||
}
|
||||
|
||||
CGSize contentSize = RCTCGSizeFromSize(data.getContentSize());
|
||||
|
||||
if (CGSizeEqualToSize(_contentSize, contentSize)) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user