Skip to content
Closed
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 @@ -111,6 +111,7 @@ @implementation RCTScrollViewComponentView {

CGRect _prevFirstVisibleFrame;
__weak UIView *_firstVisibleView;
NSInteger _firstVisibleViewTag;

CGFloat _endDraggingSensitivityMultiplier;

Expand Down Expand Up @@ -691,6 +692,7 @@ - (void)prepareForRecycle
_contentView = nil;
_prevFirstVisibleFrame = CGRectZero;
_firstVisibleView = nil;
_firstVisibleViewTag = 0;
_virtualViewContainerState = nil;
}

Expand Down Expand Up @@ -1041,7 +1043,7 @@ - (void)removeScrollListener:(NSObject<UIScrollViewDelegate> *)scrollListener
- (void)_prepareForMaintainVisibleScrollPosition
{
const auto &props = static_cast<const ScrollViewProps &>(*_props);
if (!props.maintainVisibleContentPosition) {
if (!props.maintainVisibleContentPosition || _avoidAdjustmentForMaintainVisibleContentPosition) {
return;
}

Expand All @@ -1059,6 +1061,7 @@ - (void)_prepareForMaintainVisibleScrollPosition
if (hasNewView || ii == _contentView.subviews.count - 1) {
_prevFirstVisibleFrame = subview.frame;
_firstVisibleView = subview;
_firstVisibleViewTag = subview.tag;
break;
}
}
Expand All @@ -1071,6 +1074,13 @@ - (void)_adjustForMaintainVisibleContentPosition
return;
}

if (ReactNativeFeatureFlags::enableViewCulling()) {
// Abort if the first visible view has changed (different tag)
if (_firstVisibleView && _firstVisibleView.tag != _firstVisibleViewTag) {
return;
}
}

std::optional<int> autoscrollThreshold = props.maintainVisibleContentPosition.value().autoscrollToTopThreshold;
BOOL horizontal = _scrollView.contentSize.width > self.frame.size.width;
// TODO: detect and handle/ignore re-ordering
Expand Down