Skip to content

Commit

Permalink
Back out "Restore scroll position when scroll view is hidden and shown"
Browse files Browse the repository at this point in the history
Summary:
Backing out D42815359 (47903d0) as it caused [this](https://fb.workplace.com/groups/rn.support/permalink/24250950937860193/)

## Changelog:
[iOS][Changed] - Backout to prevent issue

Reviewed By: sammy-SC

Differential Revision: D43041078

fbshipit-source-id: 844764af15c37baee55c927501b8b293878df284
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Feb 6, 2023
1 parent 011ea33 commit 34604fa
Showing 1 changed file with 0 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@

using namespace facebook::react;

struct PendingOffset {
bool isPending;
CGPoint offset;
CGPoint lastOffset;
};

static CGFloat const kClippingLeeway = 44.0;

static UIScrollViewKeyboardDismissMode RCTUIKeyboardDismissModeFromProps(ScrollViewProps const &props)
Expand Down Expand Up @@ -105,8 +99,6 @@ @implementation RCTScrollViewComponentView {
BOOL _shouldUpdateContentInsetAdjustmentBehavior;

CGPoint _contentOffsetWhenClipped;

PendingOffset _pendingOffset;
}

+ (RCTScrollViewComponentView *_Nullable)findScrollViewComponentViewForView:(UIView *)view
Expand Down Expand Up @@ -181,12 +173,6 @@ - (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
_containerView.transform = transform;
_scrollView.transform = transform;
}

// If there is a pending offset, apply it
if (_pendingOffset.isPending) {
[self scrollTo:_pendingOffset.offset.x y:_pendingOffset.offset.y animated:false];
_pendingOffset.isPending = false;
}
}

- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
Expand Down Expand Up @@ -435,13 +421,6 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
[self _updateStateWithContentOffset];
}

// If the view is hidden, then set as pending offset. Apply it later on
// updateLayoutMetrics.
if (_scrollView.window == nil && !_pendingOffset.isPending) {
_pendingOffset.offset = _pendingOffset.lastOffset;
_pendingOffset.isPending = true;
}

NSTimeInterval now = CACurrentMediaTime();
if ((_lastScrollEventDispatchTime == 0) || (now - _lastScrollEventDispatchTime > _scrollEventThrottle)) {
_lastScrollEventDispatchTime = now;
Expand All @@ -452,8 +431,6 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView
RCTSendScrollEventForNativeAnimations_DEPRECATED(scrollView, self.tag);
}

_pendingOffset.lastOffset = _scrollView.contentOffset;

[self _remountChildrenIfNeeded];
}

Expand Down

0 comments on commit 34604fa

Please sign in to comment.