@infinite-list/data-model
Advanced tools
Comparing version 0.1.1-recycle-alpha.11 to 0.1.1-recycle-alpha.12
@@ -5,3 +5,3 @@ import Batchinator from '@x-oasis/batchinator'; | ||
import PrefixIntervalTree from '@x-oasis/prefix-interval-tree'; | ||
import { SpaceStateToken, IndexInfo, ItemLayout, KeysChangedType, ListDimensionsProps, ListRenderState, ListState, OnEndReached, PreStateResult, ScrollMetrics, StateListener, ListStateResult, SpaceStateTokenPosition } from './types'; | ||
import { SpaceStateToken, IndexInfo, ItemLayout, KeysChangedType, ListDimensionsProps, ListRenderState, ListState, OnEndReached, PreStateResult, ScrollMetrics, StateListener, SpaceStateTokenPosition, RecycleStateResult, SpaceStateResult } from './types'; | ||
import OnEndReachedHelper from './viewable/OnEndReachedHelper'; | ||
@@ -45,5 +45,11 @@ import EnabledSelector from './utils/EnabledSelector'; | ||
get selector(): EnabledSelector; | ||
get stateResult(): ListStateResult<ItemT>; | ||
get stateResult(): SpaceStateResult<ItemT> | RecycleStateResult<ItemT> | { | ||
recycleState: SpaceStateToken<ItemT>[]; | ||
spaceState: SpaceStateToken<ItemT>[]; | ||
}; | ||
set offsetInListGroup(offset: number); | ||
getState(): ListStateResult<ItemT>; | ||
getState(): SpaceStateResult<ItemT> | RecycleStateResult<ItemT> | { | ||
recycleState: SpaceStateToken<ItemT>[]; | ||
spaceState: SpaceStateToken<ItemT>[]; | ||
}; | ||
cleanup(): void; | ||
@@ -50,0 +56,0 @@ resolveInitialActiveValue(active: boolean): boolean; |
{ | ||
"name": "@infinite-list/data-model", | ||
"version": "0.1.1-recycle-alpha.11", | ||
"version": "0.1.1-recycle-alpha.12", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "dist", |
@@ -57,3 +57,8 @@ import noop from '@x-oasis/noop'; | ||
private _state: ListState<ItemT>; | ||
private _stateResult: ListStateResult<ItemT> = []; | ||
private _stateResult: | ||
| ListStateResult<ItemT> | ||
| { | ||
recycleState: Array<SpaceStateToken<ItemT>>; | ||
spaceState: Array<SpaceStateToken<ItemT>>; | ||
}; | ||
@@ -1155,17 +1160,32 @@ private _listGroupDimension: ListGroupDimensions; | ||
if (performItemsMetaChange) { | ||
const bufferedItems = this._data.slice( | ||
nextBufferedStartIndex, | ||
nextBufferedEndIndex + 1 | ||
); | ||
if (this._recycleEnabled()) { | ||
const bufferedItemsMeta = ( | ||
this._stateResult as { | ||
recycleState: Array<SpaceStateToken<ItemT>>; | ||
} | ||
).recycleState | ||
.map((item) => this.getKeyMeta(item.key)) | ||
.filter((v) => v); | ||
const bufferedItemsMeta = bufferedItems | ||
.map((item, index) => | ||
this.getItemMeta(item, nextBufferedStartIndex + index) | ||
) | ||
.filter((v) => v); | ||
this._onUpdateItemsMetaChangeBatchinator.schedule( | ||
bufferedItemsMeta, | ||
scrollMetrics | ||
); | ||
} else { | ||
const bufferedItems = this._data.slice( | ||
nextBufferedStartIndex, | ||
nextBufferedEndIndex + 1 | ||
); | ||
this._onUpdateItemsMetaChangeBatchinator.schedule( | ||
bufferedItemsMeta, | ||
scrollMetrics | ||
); | ||
const bufferedItemsMeta = bufferedItems | ||
.map((item, index) => | ||
this.getItemMeta(item, nextBufferedStartIndex + index) | ||
) | ||
.filter((v) => v); | ||
this._onUpdateItemsMetaChangeBatchinator.schedule( | ||
bufferedItemsMeta, | ||
scrollMetrics | ||
); | ||
} | ||
} | ||
@@ -1231,3 +1251,3 @@ } | ||
}); | ||
this.updateState(this._state, scrollMetrics, false); | ||
this.updateState(this._state, scrollMetrics); | ||
} | ||
@@ -1234,0 +1254,0 @@ |
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
1474356
15894