Skip to content

Commit

Permalink
Fix issue with setting shadow node state data after scrolling program…
Browse files Browse the repository at this point in the history
…matically

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
  • Loading branch information
ryancat authored and facebook-github-bot committed Oct 13, 2021
1 parent 8581661 commit 55392f6
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,11 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
}

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
[self _handleFinishedScrolling:scrollView];
}

- (void)_handleFinishedScrolling:(UIScrollView *)scrollView
{
[self _forceDispatchNextScrollEvent];
[self scrollViewDidScroll:scrollView];
Expand Down Expand Up @@ -710,6 +715,12 @@ - (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated
}

[_scrollView setContentOffset:offset animated:animated];

if (!animated) {
// When not animated, the expected workflow in ``scrollViewDidEndScrollingAnimation`` after scrolling is not going
// to get triggered. We will need to manually execute here.
[self _handleFinishedScrolling:_scrollView];
}
}

- (void)zoomToRect:(CGRect)rect animated:(BOOL)animated
Expand Down

0 comments on commit 55392f6

Please sign in to comment.