Skip to content

Commit

Permalink
Fix issue with interruptted scroll cause touch in scroll view unrespo…
Browse files Browse the repository at this point in the history
…nsive

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
  • Loading branch information
ryancat authored and facebook-github-bot committed Mar 9, 2022
1 parent c34ef58 commit bb8ff92
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,8 @@ public void run() {
private void cancelPostTouchScrolling() {
if (mPostTouchRunnable != null) {
removeCallbacks(mPostTouchRunnable);
mPostTouchRunnable = null;
getFlingAnimator().cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,8 @@ public void run() {
private void cancelPostTouchScrolling() {
if (mPostTouchRunnable != null) {
removeCallbacks(mPostTouchRunnable);
mPostTouchRunnable = null;
getFlingAnimator().cancel();
}
}

Expand Down

0 comments on commit bb8ff92

Please sign in to comment.