Skip to content

Commit

Permalink
fix: account for ListHeaderComponent length when calculating offset… (
Browse files Browse the repository at this point in the history
#17415)

Summary:
… in VirtualizedList - fixes #16612

Issue is detailed in #16612

<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

I need `onViewableItemsChanged` to account for the length of any ListHeaderComponents

I couldn't find any tests that currently cover the use-case of a VirtualizedList + ListComponent + scroll with onViewableItemsChanged, so I have not added any tests - all previous tests pass however.

<!--
Help reviewers and the release process by writing your own release notes

**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**

  CATEGORY
[----------]        TYPE
[ CLI      ]   [-------------]      LOCATION
[ DOCS     ]   [ BREAKING    ]   [-------------]
[ GENERAL  ]   [ BUGFIX      ]   [-{Component}-]
[ INTERNAL ]   [ ENHANCEMENT ]   [ {File}      ]
[ IOS      ]   [ FEATURE     ]   [ {Directory} ]   |-----------|
[ ANDROID  ]   [ MINOR       ]   [ {Framework} ] - | {Message} |
[----------]   [-------------]   [-------------]   |-----------|

[CATEGORY] [TYPE] [LOCATION] - MESSAGE

 EXAMPLES:

 [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
 [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
 [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
 [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
 [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
 [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->

[GENERAL][BUGFIX][VirtualizedList] - account for `ListHeaderComponent` length
Closes #17415

Differential Revision: D8683555

Pulled By: hramos

fbshipit-source-id: 05df7b79c16e3c07c12468e782f3c4b0bdce7403
  • Loading branch information
shakyShane authored and hramos committed Jul 4, 2018
1 parent 5ae80f9 commit 537731f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Libraries/Lists/VirtualizedList.js
Expand Up @@ -1217,7 +1217,9 @@ class VirtualizedList extends React.PureComponent<Props, State> {
}

_selectOffset(metrics: $ReadOnly<{x: number, y: number}>): number {
return !this.props.horizontal ? metrics.y : metrics.x;
return (
(!this.props.horizontal ? metrics.y : metrics.x) - this._headerLength
);
}

_maybeCallOnEndReached() {
Expand Down

0 comments on commit 537731f

Please sign in to comment.