Skip to content
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

Closed
wants to merge 9 commits into from

Conversation

Guardiannw
Copy link
Contributor

Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:

Unless you are a React Native release maintainer and cherry-picking an existing commit into a current release, ensure your pull request is targeting the master React Native branch.

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 the scrollToEnd 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.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. GH Review: review-needed labels Mar 12, 2017
@Guardiannw
Copy link
Contributor Author

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.

@Guardiannw Guardiannw mentioned this pull request Mar 28, 2017
4 tasks
@sbaar
Copy link

sbaar commented Apr 20, 2017

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

@gabriel
Copy link

gabriel commented May 9, 2017

I've encountered this bug as well.

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Jun 21, 2017
@facebook-github-bot
Copy link
Contributor

@sahrens has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants