Skip to content

Commit 55392f6

Browse files
ryancatfacebook-github-bot
authored andcommitted
Fix issue with setting shadow node state data after scrolling programmatically
Summary: This issue is found when investigating T101563978 with IOS platform. When animation is off, the x position measurement is off after `scrollToItem` is called. The android fix is checked in at D31492685 (1a9e2d5). For IOS, the correct state data is updated only for animated cases, but not for instant scroll cases. This diff unified them. Changelog [IOS][Fixed] Fixed an edge case when scroll to item/index is called without animation, the offset position is not updated. This caused the measurement of the position to be wrong. Reviewed By: sammy-SC Differential Revision: D31564169 fbshipit-source-id: 89f47d8054afb03c2ace1d595163b160e5bb2036
1 parent 8581661 commit 55392f6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm

+11
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,11 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
498498
}
499499

500500
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
501+
{
502+
[self _handleFinishedScrolling:scrollView];
503+
}
504+
505+
- (void)_handleFinishedScrolling:(UIScrollView *)scrollView
501506
{
502507
[self _forceDispatchNextScrollEvent];
503508
[self scrollViewDidScroll:scrollView];
@@ -710,6 +715,12 @@ - (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated
710715
}
711716

712717
[_scrollView setContentOffset:offset animated:animated];
718+
719+
if (!animated) {
720+
// When not animated, the expected workflow in ``scrollViewDidEndScrollingAnimation`` after scrolling is not going
721+
// to get triggered. We will need to manually execute here.
722+
[self _handleFinishedScrolling:_scrollView];
723+
}
713724
}
714725

715726
- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated

0 commit comments

Comments
 (0)