@infinite-list/data-model
Advanced tools
Comparing version 0.2.45-recycle-group.38 to 0.2.45-recycle-group.39
@@ -112,2 +112,6 @@ import Batchinator from '@x-oasis/batchinator'; | ||
}; | ||
resolveRecycleItemLayout(info: any, indexToOffsetMap: any): { | ||
offset: any; | ||
length: any; | ||
}; | ||
resolveRecycleRecycleState(state: ListState<ItemT>): any[]; | ||
@@ -114,0 +118,0 @@ resolveRecycleState(state: ListState<ItemT>): { |
@@ -17,4 +17,4 @@ import Heap from '@x-oasis/heap'; | ||
getNewPositionForValue(value: number): number; | ||
getMinValue(): number; | ||
getMaxValue(): number; | ||
getMinValue(): any; | ||
getMaxValue(): any; | ||
setPositionValue(position: number, value: number): void; | ||
@@ -21,0 +21,0 @@ replaceFurthestValuePosition(lowValue: number, highValue: number, newValue: number, useMinValueFn?: (options: { |
{ | ||
"name": "@infinite-list/data-model", | ||
"version": "0.2.45-recycle-group.38", | ||
"version": "0.2.45-recycle-group.39", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "dist", |
@@ -644,2 +644,56 @@ import noop from '@x-oasis/noop'; | ||
resolveRecycleItemLayout(info, indexToOffsetMap) { | ||
const { meta: itemMeta, targetIndex } = info; | ||
const itemLayout = itemMeta?.getLayout(); | ||
const itemLength = | ||
(itemLayout?.height || 0) + (itemMeta?.getSeparatorLength() || 0); | ||
if ( | ||
!itemMeta.isApproximateLayout && | ||
indexToOffsetMap[targetIndex] != null | ||
) { | ||
return { | ||
offset: indexToOffsetMap[targetIndex], | ||
length: itemLength, | ||
}; | ||
} | ||
const prevIndex = targetIndex - 1; | ||
const prevMeta = this.getFinalIndexItemMeta(prevIndex); | ||
if (!prevMeta?.isApproximateLayout) { | ||
const prevOffset = | ||
indexToOffsetMap[prevIndex] != null | ||
? indexToOffsetMap[prevIndex] | ||
: this.getFinalIndexKeyOffset(prevIndex) || 0; | ||
const prevLayout = prevMeta?.getLayout(); | ||
const prevLength = | ||
(prevLayout?.height || 0) + (prevMeta?.getSeparatorLength() || 0); | ||
return { | ||
offset: prevOffset + prevLength, | ||
length: itemLength, | ||
}; | ||
} | ||
const nextIndex = targetIndex + 1; | ||
const nextMeta = this.getFinalIndexItemMeta(nextIndex); | ||
if (!nextMeta?.isApproximateLayout) { | ||
const nextOffset = | ||
indexToOffsetMap[nextIndex] != null | ||
? indexToOffsetMap[nextIndex] | ||
: this.getFinalIndexKeyOffset(nextIndex) || 0; | ||
return { | ||
offset: nextOffset - itemLength, | ||
length: itemLength, | ||
}; | ||
} | ||
return { | ||
length: itemLength, | ||
offset: this.itemOffsetBeforeLayoutReady, | ||
}; | ||
} | ||
resolveRecycleRecycleState(state: ListState<ItemT>) { | ||
@@ -716,5 +770,2 @@ const { visibleEndIndex, visibleStartIndex: _visibleStartIndex } = state; | ||
const item = this.getData()[targetIndex]; | ||
const itemLayout = itemMeta?.getLayout(); | ||
const itemLength = | ||
(itemLayout?.height || 0) + (itemMeta?.getSeparatorLength() || 0); | ||
@@ -743,3 +794,2 @@ const itemMetaState = | ||
targetIndex, | ||
length: itemLength, | ||
isSpace: false, | ||
@@ -755,9 +805,4 @@ isSticky: false, | ||
// 如果没有offset,说明item是新增的,那么它渲染就在最开始位置好了 | ||
offset: | ||
itemLength && !itemMeta.isApproximateLayout | ||
? indexToOffsetMap[targetIndex] == null | ||
? this.itemOffsetBeforeLayoutReady | ||
: indexToOffsetMap[targetIndex] | ||
: this.itemOffsetBeforeLayoutReady, | ||
position: 'buffered', | ||
...this.resolveRecycleItemLayout(info, indexToOffsetMap), | ||
}); | ||
@@ -764,0 +809,0 @@ }); |
@@ -515,3 +515,3 @@ import noop from '@x-oasis/noop'; | ||
if (this._approximateMode && !meta.isApproximateLayout) { | ||
if (this._approximateMode && meta.isApproximateLayout) { | ||
meta.setLayout({ x: 0, y: 0, height: 0, width: 0 }); | ||
@@ -518,0 +518,0 @@ this._selectValue.setLength( |
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
2653839
148
34530