Skip to content

Commit

Permalink
Force scroll event inside scrollViewDidEndScrollingAnimation and scro…
Browse files Browse the repository at this point in the history
…llTo

Summary:
Changelog: [internal]

`onScroll` event needs to be fired when scroll view ends the scrolling animation and when scrollTo is called.
This is how Paper does it and client code might depend on it.

Reviewed By: JoshuaGross

Differential Revision: D24527189

fbshipit-source-id: bdec099f16b3d8c97686975a1f769db4d2c0d832
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Oct 24, 2020
1 parent 1d1cbc9 commit e75a0dc
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
[self _forceDispatchNextScrollEvent];
[self scrollViewDidScroll:scrollView];

if (!_eventEmitter) {
return;
Expand Down Expand Up @@ -458,6 +459,8 @@ - (void)scrollTo:(double)x y:(double)y animated:(BOOL)animated
_scrollView.contentSize.height - _scrollView.bounds.size.height + _scrollView.contentInset.bottom +
fmax(_scrollView.contentInset.top, 0),
0.01)); // Make width and height greater than 0

[self _forceDispatchNextScrollEvent];
if (!CGRectContainsPoint(maxRect, offset)) {
CGFloat localX = fmax(offset.x, CGRectGetMinX(maxRect));
localX = fmin(localX, CGRectGetMaxX(maxRect));
Expand Down

0 comments on commit e75a0dc

Please sign in to comment.