Android ScrollView: Add scrollBy method#15610
Conversation
There was a problem hiding this comment.
Just for visibility; I've also changed this file: https://github.com/facebook/react-native/pull/15566/files#diff-0e688b19a3a45a0d17cd8d922cc0580aR29
If that makes its way into the code-base, there may be a small rebase required 👍
Currently, React Native allows you to scroll a ScrollView to a particular position using `scrollTo`. If instead you want to scroll by a delta, you could try to do this using `scrollTo` (add the delta to the current scroll position) but this doesn't always work out as intended due to the async nature of React Native (what you think is the current scroll position might be a stale value). This change introduces a `scrollBy` API to solve this problem. `scrollBy` takes a delta to scroll by and native takes care of doing the arithmetic because it knows the latest scroll position.
fb3fe2b to
b2087ba
Compare
|
@AaaChiuuu, @achen1 can you review this PR or find an appropriate person to do so? |
|
I have to mention here that same consideration described in #15609 are also applicable here. |
|
@rigdern I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
|
Thanks for the discussion. We decided to go with an alternative solution. We built a native module which combines a number of operations our virtual list view implementation requires (e.g. scrolling & repositioning items) into a single method so all of the operations are completed in the same frame. |
iOS PR: #15609
Currently, React Native allows you to scroll a ScrollView to a particular position using
scrollTo. If instead you want to scroll by a delta, you could try to do this usingscrollTo(add the delta to the current scroll position) but this doesn't always work out as intended due to the async nature of React Native (what you think is the current scroll position might be a stale value). This change introduces ascrollByAPI to solve this problem.scrollBytakes a delta to scroll by and native takes care of doing the arithmetic because it knows the latest scroll position.Test Plan
In a test app, verified that
scrollByworks properly with and without animation and for both horizontal and verticalScrollViews. Also, my team is using this change in our app.Adam Comella
Microsoft Corp.