From e75a0dc26510c816ce7fe9d1b83c1a92db78a5b6 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Sat, 24 Oct 2020 11:59:25 -0700 Subject: [PATCH] Force scroll event inside scrollViewDidEndScrollingAnimation and scrollTo 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 --- .../ComponentViews/ScrollView/RCTScrollViewComponentView.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index d8bdd35b03f..c51e7146aee 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -392,6 +392,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView { [self _forceDispatchNextScrollEvent]; + [self scrollViewDidScroll:scrollView]; if (!_eventEmitter) { return; @@ -458,6 +459,8 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg _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));