@infinite-list/data-model
Advanced tools
Comparing version 0.2.45-recycle-group.8 to 0.2.45-recycle-group.9
@@ -33,3 +33,3 @@ import { SafeRange } from './types'; | ||
start(): void; | ||
place(index: number, itemMeta: ItemMeta, safeRange: SafeRange): void; | ||
place(index: number, itemMeta: ItemMeta, safeRange: SafeRange): number; | ||
getMaxValue(): number; | ||
@@ -36,0 +36,0 @@ getMinValue(): number; |
@@ -127,2 +127,3 @@ import Batchinator from '@x-oasis/batchinator'; | ||
spaceState: any[]; | ||
rangeState: ListState<ItemT>; | ||
}; | ||
@@ -129,0 +130,0 @@ resolveToken(startIndex: number, endIndex: number): { |
{ | ||
"name": "@infinite-list/data-model", | ||
"version": "0.2.45-recycle-group.8", | ||
"version": "0.2.45-recycle-group.9", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "dist", |
@@ -16,4 +16,10 @@ "use strict"; | ||
this._indices = []; | ||
var size = props.size, thresholdIndexValue = props.thresholdIndexValue, recyclerReservedBufferSize = props.recyclerReservedBufferSize, recyclerType = props.recyclerType; | ||
this._indicesCopy = []; | ||
this._newIndices = []; | ||
this._itemMetaIndices = []; | ||
this._newItemMetaIndices = []; | ||
var size = props.size, thresholdIndexValue = props.thresholdIndexValue, recyclerReservedBufferSize = props.recyclerReservedBufferSize, recyclerType = props.recyclerType, owner = props.owner, startIndex = props.startIndex; | ||
this._size = size; | ||
this._owner = owner; | ||
this._startIndex = startIndex; | ||
this._recyclerType = recyclerType; | ||
@@ -65,7 +71,21 @@ this._thresholdIndexValue = thresholdIndexValue; | ||
}; | ||
FixedBuffer.prototype.place = function (index, safeRange) { | ||
FixedBuffer.prototype.start = function () { | ||
this._indicesCopy = this._bufferSet.indices.map(function (i) { return parseInt(i); }); | ||
this._newItemMetaIndices = new Array(this._recyclerReservedBufferSize); | ||
this._indices = new Array(this._recyclerReservedBufferSize); | ||
}; | ||
FixedBuffer.prototype.place = function (index, itemMeta, safeRange) { | ||
var idx = this._itemMetaIndices.findIndex(function (meta) { return meta === itemMeta; }); | ||
if (idx !== -1) { | ||
var position_1 = idx; | ||
this._newItemMetaIndices[position_1] = itemMeta; | ||
this._indices[position_1] = index; | ||
return position_1; | ||
} | ||
var position = this.getPosition(index, safeRange.startIndex, safeRange.endIndex); | ||
if (position !== null) | ||
return (this._indices[position] = index); | ||
return false; | ||
if (position === position) { | ||
this._indices[position] = index; | ||
this._newItemMetaIndices[position] = itemMeta; | ||
} | ||
return position; | ||
}; | ||
@@ -80,4 +100,51 @@ FixedBuffer.prototype.getMaxValue = function () { | ||
var arr = []; | ||
var nextItemMetaIndices = new Array(this._recyclerReservedBufferSize); | ||
for (var idx = 0; idx < this._recyclerReservedBufferSize; idx++) { | ||
arr[idx] = parseInt(this._bufferSet.indices[idx]) || null; | ||
if (this._newItemMetaIndices[idx]) { | ||
var targetIndex = this._indices[idx]; | ||
var itemMeta = this._newItemMetaIndices[idx]; | ||
arr.push({ | ||
itemMeta: itemMeta, | ||
targetIndex: targetIndex, | ||
recycleKey: "recycle_" + (this._startIndex + idx) | ||
}); | ||
nextItemMetaIndices[idx] = itemMeta; | ||
continue; | ||
} | ||
else if ((this._owner.getData() || [])[this._indicesCopy[idx]]) { | ||
var targetIndex = this._indicesCopy[idx]; | ||
var data = this._owner.getData() || []; | ||
var item = data[targetIndex]; | ||
if (item) { | ||
var itemMeta = this._owner.getFinalItemMeta(item); | ||
if (itemMeta && itemMeta.recyclerType === this.recyclerType) { | ||
arr.push({ | ||
itemMeta: itemMeta, | ||
targetIndex: targetIndex, | ||
recycleKey: "recycle_" + (this._startIndex + idx) | ||
}); | ||
nextItemMetaIndices[idx] = itemMeta; | ||
continue; | ||
} | ||
} | ||
} | ||
this._itemMetaIndices = nextItemMetaIndices; | ||
arr.push(null); | ||
// const targetIndex = parseInt(this._bufferSet.indices[idx]) | ||
// if (targetIndex === targetIndex) { | ||
// const data = this._owner.getData() || [] | ||
// const item = data[targetIndex] | ||
// if (item) { | ||
// const itemMeta = this._owner.getFinalItemMeta(item); | ||
// if (itemMeta && (itemMeta.recyclerType === this.recyclerType)) { | ||
// arr.push({ | ||
// itemMeta, | ||
// targetIndex, | ||
// }) | ||
// continue | ||
// } | ||
// } | ||
// // remove target index from position idx | ||
// // this._bufferSet.remove(idx) | ||
// } | ||
} | ||
@@ -84,0 +151,0 @@ return arr; |
@@ -456,3 +456,5 @@ "use strict"; | ||
recycleState: recycleState, | ||
spaceState: spaceState | ||
spaceState: spaceState, | ||
// @ts-ignore | ||
rangeState: stateResult.rangeState | ||
}, this._stateResult); | ||
@@ -464,3 +466,5 @@ } | ||
} | ||
this._stateResult = stateResult; | ||
this._stateResult = __assign(__assign({}, stateResult), { | ||
// @ts-ignore | ||
rangeState: stateResult.rangeState }); | ||
}; | ||
@@ -599,3 +603,4 @@ ListBaseDimensions.prototype.setState = function (state, force) { | ||
recycleState: recycleStateResult.filter(function (v) { return v; }), | ||
spaceState: spaceStateResult.filter(function (v) { return v; }) | ||
spaceState: spaceStateResult.filter(function (v) { return v; }), | ||
rangeState: state | ||
}; | ||
@@ -602,0 +607,0 @@ return stateResult; |
@@ -117,12 +117,14 @@ import IntegerBufferSet from '@x-oasis/integer-buffer-set'; | ||
this._indices[position] = index; | ||
} else { | ||
const position = this.getPosition( | ||
index, | ||
safeRange.startIndex, | ||
safeRange.endIndex | ||
); | ||
if (position === position) { | ||
this._newItemMetaIndices[position] = itemMeta; | ||
} | ||
return position | ||
} | ||
const position = this.getPosition( | ||
index, | ||
safeRange.startIndex, | ||
safeRange.endIndex | ||
); | ||
if (position === position) { | ||
this._indices[position] = index; | ||
this._newItemMetaIndices[position] = itemMeta; | ||
} | ||
return position | ||
} | ||
@@ -142,4 +144,3 @@ | ||
for (let idx = 0; idx < this._recyclerReservedBufferSize; idx++) { | ||
if (typeof this._newItemMetaIndices[idx] === 'number') { | ||
// const targetIndex = this._bufferSet.indices[idx] | ||
if (this._newItemMetaIndices[idx]) { | ||
const targetIndex = this._indices[idx]; | ||
@@ -146,0 +147,0 @@ const itemMeta = this._newItemMetaIndices[idx]; |
@@ -583,2 +583,4 @@ import noop from '@x-oasis/noop'; | ||
spaceState, | ||
// @ts-ignore | ||
rangeState: stateResult.rangeState, | ||
}, | ||
@@ -592,3 +594,7 @@ this._stateResult | ||
this._stateResult = stateResult; | ||
this._stateResult = { | ||
...stateResult, | ||
// @ts-ignore | ||
rangeState: stateResult.rangeState, | ||
}; | ||
} | ||
@@ -783,2 +789,3 @@ | ||
spaceState: spaceStateResult.filter((v) => v), | ||
rangeState: state, | ||
}; | ||
@@ -785,0 +792,0 @@ |
import Batchinator from '@x-oasis/batchinator'; | ||
import isClamped from '@x-oasis/is-clamped'; | ||
import noop from '@x-oasis/noop'; | ||
import shallowArrayEqual from '@x-oasis/shallow-array-equal'; | ||
import resolveChanged from '@x-oasis/resolve-changed'; | ||
@@ -6,0 +5,0 @@ import defaultBooleanValue from '@x-oasis/default-boolean-value'; |
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
2640243
34223