-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed ScrollView's .scrollToEnd to refrain from exceeding start boundary. #12889
Conversation
…ding the 0 boundary.
The checks did not pass, but I don't think it is due to the code I changed. I didn't change any android code, but it was android scripts that failed. |
Confirmed. This code fixed an issue that would cause scrollToEnd() to scroll past the end. The pr keeps the items vertically aligned at the top, as expected |
I've encountered this bug as well. |
@sahrens has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:
Explain the motivation for making this change. What existing problem does the pull request solve?
The problem occurs when a ScrollView's content height is smaller than the ScrollView height. If the method
scrollToEnd
is called on the ScrollView, it will pull the content down until the bottom of the content is aligned with the bottom of the Scrollview container.This fix will ensure the proper functionality: That the furthest the ScrollView can scroll down is to where the top of the content container is at the origin (i.e., the ScrollView scroll number cannot be less than 0).
Prefer small pull requests. These are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.
Test plan (required)
Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.
Make sure tests pass on both Travis and Circle CI.
I tested on a scenario where the ScrollView is almost the full size of the screen, and the content of the ScrollView has a height of much less. In this situation, the
scrollToEnd
method was executed and the content stayed in the same position. This is the intended behavior. If the content of the ScrollView is smaller than the height of the ScrollView, then thescrollToEnd
method should not scroll anywhere.Code formatting
Look around. Match the style of the rest of the codebase. See also the simple style guide.
For more info, see the "Pull Requests" section of our "Contributing" guidelines.