Skip to content

Commit bb8ff92

Browse files
ryancatfacebook-github-bot
authored andcommitted
Fix issue with interruptted scroll cause touch in scroll view unresponsive
Summary: This diff fixed an issue that caused regression in fb4a and React Native panel apps regarding scrolling behavior. When scrolling in either horizontal or vertical scroll view, if the consecutive touch interrupted the previous fling (post touch scrolling), the scroll view would block touch event from dispatching to the content view. Thus, the items in scroll view are not responding to touch events anymore. The diff that caused this issue is D34627330 (0368081). In that diff, I added code to cancel the scheduled post touch runnable when touch down is received in scroll view. That is expected as the post touch runnable is to handle snapping scroll case, where [an extra fling](https://fburl.com/code/7qza1ece) is triggered to make sure scroll view stops at the right position. When user touch the screen before the previous scroll fling finishes, this post processing is no longer needed -- the new touch should take full control of scroll view. However, in D34627330 (0368081), I failed to reset the runnable instance `mPostTouchRunnable` to null when cancelling it. This caused the future post touch handle logic [stops to run](https://fburl.com/code/lh8pi7l0), as it thinks the runnable is non-null and has been scheduled. This prevents fabric from receiving proper scroll state updates from android side, thus causing a state corruption and affects logic to decide where the scroll offset is and where the child item is after that. This diff fixed the issue by resetting the runnable instance, as well as making sure if the runnable is already running and the extra fling starts, we are canceling that fling animation properly. Changelog: [Android][Fixed] - Fixed regression on content in scroll view not responding to touch when fling got interrupted Reviewed By: ShikaSD Differential Revision: D34734129 fbshipit-source-id: 7d7689d203ce76c59cd44e16e31582317bb409bd
1 parent c34ef58 commit bb8ff92

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java

+2
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,8 @@ public void run() {
832832
private void cancelPostTouchScrolling() {
833833
if (mPostTouchRunnable != null) {
834834
removeCallbacks(mPostTouchRunnable);
835+
mPostTouchRunnable = null;
836+
getFlingAnimator().cancel();
835837
}
836838
}
837839

ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java

+2
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ public void run() {
622622
private void cancelPostTouchScrolling() {
623623
if (mPostTouchRunnable != null) {
624624
removeCallbacks(mPostTouchRunnable);
625+
mPostTouchRunnable = null;
626+
getFlingAnimator().cancel();
625627
}
626628
}
627629

0 commit comments

Comments
 (0)