Fix typo in ViewabilityHelper (`itemVisiblePercentThreshold` mistyped)
Summary: The new `ViewabilityConfig` API has a typo: `itemVisiblePercentThreashold` should be `itemVisiblePercentThreshold`. Thought it would be good to fix this before people start depending on a property containing a typo :-) Updated tests to match. Closes https://github.com/facebook/react-native/pull/12593 Differential Revision: D4619798 Pulled By: ericvicenti fbshipit-source-id: 0aa8b6cf9ae7e5638607195759e4bd51140667fe
This commit is contained in:
parent
bf429f03a9
commit
9217ff3203
|
@ -35,7 +35,7 @@ export type ViewabilityConfig = {
|
|||
* Similar to `viewAreaPercentThreshold`, but considers the percent of the item that is visible,
|
||||
* rather than the fraction of the viewable area it covers.
|
||||
*/
|
||||
itemVisiblePercentThreashold?: number,
|
||||
itemVisiblePercentThreshold?: number,
|
||||
|
||||
/**
|
||||
* Nothing is considered viewable until the user scrolls (tbd: or taps) the screen after render.
|
||||
|
@ -68,15 +68,15 @@ class ViewabilityHelper {
|
|||
getFrameMetrics: (index: number) => ?{length: number, offset: number},
|
||||
renderRange?: {first: number, last: number}, // Optional optimization to reduce the scan size
|
||||
): Array<number> {
|
||||
const {itemVisiblePercentThreashold, viewAreaCoveragePercentThreshold} = this._config;
|
||||
const {itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold} = this._config;
|
||||
const viewAreaMode = viewAreaCoveragePercentThreshold != null;
|
||||
const viewablePercentThreshold = viewAreaMode ?
|
||||
viewAreaCoveragePercentThreshold :
|
||||
itemVisiblePercentThreashold;
|
||||
itemVisiblePercentThreshold;
|
||||
invariant(
|
||||
viewablePercentThreshold != null &&
|
||||
(itemVisiblePercentThreashold != null) !== (viewAreaCoveragePercentThreshold != null),
|
||||
'Must set exactly one of itemVisiblePercentThreashold or viewAreaCoveragePercentThreshold',
|
||||
(itemVisiblePercentThreshold != null) !== (viewAreaCoveragePercentThreshold != null),
|
||||
'Must set exactly one of itemVisiblePercentThreshold or viewAreaCoveragePercentThreshold',
|
||||
);
|
||||
const viewableIndices = [];
|
||||
if (itemCount === 0) {
|
||||
|
|
|
@ -118,12 +118,12 @@ describe('computeViewableItems', function() {
|
|||
d: {y: 250, height: 50},
|
||||
};
|
||||
data = [{key: 'a'}, {key: 'b'}, {key: 'c'}, {key: 'd'}];
|
||||
let helper = new ViewabilityHelper({itemVisiblePercentThreashold: 0});
|
||||
let helper = new ViewabilityHelper({itemVisiblePercentThreshold: 0});
|
||||
expect(helper.computeViewableItems(data.length, 0, 50, getFrameMetrics))
|
||||
.toEqual([0]);
|
||||
expect(helper.computeViewableItems(data.length, 1, 50, getFrameMetrics))
|
||||
.toEqual([0, 1]);
|
||||
helper = new ViewabilityHelper({itemVisiblePercentThreashold: 100});
|
||||
helper = new ViewabilityHelper({itemVisiblePercentThreshold: 100});
|
||||
expect(helper.computeViewableItems(data.length, 0, 250, getFrameMetrics))
|
||||
.toEqual([0, 1, 2]);
|
||||
expect(helper.computeViewableItems(data.length, 1, 250, getFrameMetrics))
|
||||
|
|
Loading…
Reference in New Issue