Skip to content

Commit

Permalink
Update VirtualizedList.js, fix wrong position after scrollToEnd when …
Browse files Browse the repository at this point in the history
…props.refreshing === true

Summary:
Pull request again for clean branch

Thanks for submitting a PR! Please read these instructions carefully:

- [x] Explain the **motivation** for making this change.
- [x] Provide a **test plan** demonstrating that the code is solid.
- [x] Match the **code formatting** of the rest of the codebase.
- [x] Target the `master` branch, NOT a "stable" branch.

What existing problem does the pull request solve?
Fix #14033
Fix wrong position after `scrollToEnd` when `props.refreshing === true`

**Before**

![before](https://cloud.githubusercontent.com/assets/1185694/26242273/657f0180-3cba-11e7-9360-49269fd1bb2f.gif)

**After**

![after](https://cloud.githubusercontent.com/assets/1185694/26242503/465a856c-3cbb-11e7-98fb-f3256fd45c15.gif)

Sign the [CLA][2], if you haven't already.

Small pull requests are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.

Make sure all **tests pass** on both [Travis][3] and [Circle CI][4]. PRs that break tests are unlikely to be merged.

For more info, see the ["Pull Requests"][5] section of our "Contributing" guidelines.

[1]: https://medium.com/martinkonicek/what-is-a-test-plan-8bfc840ec171#.y9lcuqqi9
[2]: https://code.facebook.com/cla
[3]: https://travis-ci.org/facebook/react-native
[4]: http://circleci.com/gh/facebook/react-native
[5]: https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#pull-requests
Closes #14089

Differential Revision: D5283973

Pulled By: sahrens

fbshipit-source-id: 9bef9a922c15aa5bed11a59acbd7b48a76946d29
  • Loading branch information
zongwan authored and facebook-github-bot committed Jun 21, 2017
1 parent 112e376 commit d217921
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,13 @@ class VirtualizedList extends React.PureComponent<OptionalProps, Props, State> {
const animated = params ? params.animated : true;
const veryLast = this.props.getItemCount(this.props.data) - 1;
const frame = this._getFrameMetricsApprox(veryLast);
const offset =
const offset = Math.max(
0,
frame.offset +
frame.length +
this._footerLength -
this._scrollMetrics.visibleLength;
frame.length +
this._footerLength -
this._scrollMetrics.visibleLength,
);
this._scrollRef.scrollTo(
this.props.horizontal ? {x: offset, animated} : {y: offset, animated},
);
Expand Down

0 comments on commit d217921

Please sign in to comment.