@infinite-list/data-model
Advanced tools
Comparing version 0.2.0 to 0.2.2
{ | ||
"name": "@infinite-list/data-model", | ||
"version": "0.2.0", | ||
"version": "0.2.2", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "dist", |
@@ -1315,3 +1315,3 @@ import ListDimensions from '../ListDimensions'; | ||
it('initialization - update data source (initialNumToRender: 10) and use viewabilityConfig', () => { | ||
it('initialization - update data source (initialNumToRender: 10 and container offset: 2000 ) and use viewabilityConfig', () => { | ||
const data = buildData(100); | ||
@@ -1333,3 +1333,3 @@ const recycleList = new ListDimensions({ | ||
x: 0, | ||
y: 0, | ||
y: 2000, | ||
width: 375, | ||
@@ -1414,6 +1414,6 @@ height: 2000, | ||
expect(recycleList.state).toEqual({ | ||
visibleStartIndex: 0, | ||
visibleEndIndex: 9, | ||
visibleStartIndex: -1, | ||
visibleEndIndex: -1, | ||
bufferedStartIndex: 0, | ||
bufferedEndIndex: 16, | ||
bufferedEndIndex: 14, | ||
isEndReached: true, | ||
@@ -1439,3 +1439,3 @@ distanceFromEnd: 74, | ||
expect(recycleListStateResult.recycleState.length).toBe(2); | ||
expect(recycleListStateResult.recycleState.length).toBe(0); | ||
@@ -1450,8 +1450,8 @@ // @ts-ignore | ||
expect(recycleList.state).toEqual({ | ||
visibleStartIndex: 0, | ||
visibleEndIndex: 9, | ||
visibleStartIndex: -1, | ||
visibleEndIndex: -1, | ||
bufferedStartIndex: 0, | ||
bufferedEndIndex: 18, | ||
bufferedEndIndex: 14, | ||
isEndReached: true, | ||
distanceFromEnd: 274, | ||
distanceFromEnd: 74, | ||
data: data.slice(0, 100), | ||
@@ -1469,18 +1469,14 @@ actionType: 'hydrationWithBatchUpdate', | ||
expect(recycleListStateResult.recycleState.length).toBe(2); | ||
expect(recycleListStateResult.recycleState.length).toBe(0); | ||
expect(recycleListStateResult.recycleState.map((v) => v.item.key)).toEqual([ | ||
10, 11, | ||
]); | ||
expect(recycleListStateResult.recycleState.map((v) => v.key)).toEqual([ | ||
'recycle_0', | ||
'recycle_1', | ||
]); | ||
expect(recycleListStateResult.recycleState.map((v) => v.viewable)).toEqual([ | ||
false, | ||
false, | ||
]); | ||
expect(recycleListStateResult.recycleState.map((v) => v.item.key)).toEqual( | ||
[] | ||
); | ||
expect(recycleListStateResult.recycleState.map((v) => v.key)).toEqual([]); | ||
expect(recycleListStateResult.recycleState.map((v) => v.viewable)).toEqual( | ||
[] | ||
); | ||
expect( | ||
recycleListStateResult.recycleState.map((v) => v.imageViewable) | ||
).toEqual([true, true]); | ||
).toEqual([]); | ||
@@ -1506,10 +1502,10 @@ // @ts-ignore | ||
actionType: 'hydrationWithBatchUpdate', | ||
visibleStartIndex: 29, | ||
visibleEndIndex: 39, | ||
bufferedStartIndex: 11, | ||
bufferedEndIndex: 51, | ||
visibleStartIndex: 9, | ||
visibleEndIndex: 19, | ||
bufferedStartIndex: 0, | ||
bufferedEndIndex: 44, | ||
data, | ||
}); | ||
expect(recycleListStateResult.recycleState.map((v) => v.item.key)).toEqual([ | ||
41, 11, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, | ||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | ||
]); | ||
@@ -1536,6 +1532,6 @@ | ||
actionType: 'hydrationWithBatchUpdate', | ||
visibleStartIndex: 26, | ||
visibleEndIndex: 36, | ||
bufferedStartIndex: 8, | ||
bufferedEndIndex: 51, | ||
visibleStartIndex: 6, | ||
visibleEndIndex: 16, | ||
bufferedStartIndex: 0, | ||
bufferedEndIndex: 44, | ||
data, | ||
@@ -1545,7 +1541,6 @@ }); | ||
expect(recycleListStateResult.recycleState.map((v) => v.item.key)).toEqual([ | ||
27, 26, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 28, | ||
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | ||
]); | ||
expect(recycleListStateResult.recycleState.map((v) => v.offset)).toEqual([ | ||
2700, 2600, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, | ||
3900, 2800, | ||
1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, | ||
]); | ||
@@ -1566,8 +1561,5 @@ | ||
'recycle_11', | ||
'recycle_12', | ||
'recycle_13', | ||
]); | ||
expect(recycleListStateResult.recycleState.map((v) => v.viewable)).toEqual([ | ||
true, | ||
false, | ||
true, | ||
@@ -1579,8 +1571,7 @@ true, | ||
true, | ||
true, | ||
true, | ||
false, | ||
false, | ||
false, | ||
true, | ||
false, | ||
false, | ||
]); | ||
@@ -1602,9 +1593,14 @@ expect( | ||
true, | ||
true, | ||
true, | ||
]); | ||
expect(recycleListStateResult.spaceState.length).toBe(4); | ||
expect(recycleListStateResult.spaceState.length).toBe(11); | ||
expect(recycleListStateResult.spaceState.map((v) => v.key)).toEqual([ | ||
'space_0_7', | ||
'0', | ||
'1', | ||
'2', | ||
'3', | ||
'4', | ||
'5', | ||
'6', | ||
'7', | ||
'8', | ||
@@ -1615,98 +1611,5 @@ '9', | ||
expect(recycleListStateResult.spaceState.map((v) => v.length)).toEqual([ | ||
800, 100, 100, 9000, | ||
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 9000, | ||
]); | ||
// @ts-ignore | ||
recycleList.updateScrollMetrics({ | ||
offset: 5000, | ||
visibleLength: 926, | ||
contentLength: 6500, | ||
}); | ||
recycleListStateResult = recycleList.stateResult as RecycleStateResult< | ||
any, | ||
{ | ||
viewable: boolean; | ||
imageViewable: boolean; | ||
} | ||
>; | ||
expect(recycleList.state).toEqual({ | ||
isEndReached: true, | ||
distanceFromEnd: 574, | ||
actionType: 'hydrationWithBatchUpdate', | ||
visibleStartIndex: 49, | ||
visibleEndIndex: 59, | ||
bufferedStartIndex: 31, | ||
bufferedEndIndex: 71, | ||
data, | ||
}); | ||
expect(recycleListStateResult.recycleState.map((v) => v.item.key)).toEqual([ | ||
50, 49, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 39, 51, | ||
]); | ||
expect(recycleListStateResult.recycleState.map((v) => v.offset)).toEqual([ | ||
5000, 4900, 5200, 5300, 5400, 5500, 5600, 5700, 5800, 5900, 6000, 6100, | ||
3900, 5100, | ||
]); | ||
expect(recycleListStateResult.recycleState.map((v) => v.key)).toEqual([ | ||
'recycle_0', | ||
'recycle_1', | ||
'recycle_2', | ||
'recycle_3', | ||
'recycle_4', | ||
'recycle_5', | ||
'recycle_6', | ||
'recycle_7', | ||
'recycle_8', | ||
'recycle_9', | ||
'recycle_10', | ||
'recycle_11', | ||
'recycle_12', | ||
'recycle_13', | ||
]); | ||
expect(recycleListStateResult.recycleState.map((v) => v.viewable)).toEqual([ | ||
true, | ||
false, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
false, | ||
false, | ||
false, | ||
true, | ||
]); | ||
expect( | ||
recycleListStateResult.recycleState.map((v) => v.imageViewable) | ||
).toEqual([ | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
true, | ||
false, | ||
true, | ||
]); | ||
expect(recycleListStateResult.spaceState.length).toBe(2); | ||
expect(recycleListStateResult.spaceState.map((v) => v.key)).toEqual([ | ||
'space_0_9', | ||
'space_10_99', | ||
]); | ||
expect(recycleListStateResult.spaceState.map((v) => v.length)).toEqual([ | ||
1000, 9000, | ||
]); | ||
}); | ||
}); |
@@ -1043,3 +1043,5 @@ import noop from '@x-oasis/noop'; | ||
this._scrollMetrics, | ||
() => indexToOffsetMap[targetIndex] | ||
// should add container offset, because indexToOffsetMap containerOffset is | ||
// exclusive. | ||
() => indexToOffsetMap[targetIndex] + this.getContainerOffset() | ||
) | ||
@@ -1046,0 +1048,0 @@ : itemMeta.getState(); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1567394
18127