@infinite-list/data-model
Advanced tools
Comparing version 0.1.1-recycle-alpha.2 to 0.1.1-recycle-alpha.3
@@ -13,2 +13,3 @@ import Heap from './Heap'; | ||
getSize(): number; | ||
get indices(): any[]; | ||
getValuePosition(value: number): null | number; | ||
@@ -15,0 +16,0 @@ getNewPositionForValue(value: number): number; |
{ | ||
"name": "@infinite-list/data-model", | ||
"version": "0.1.1-recycle-alpha.2", | ||
"version": "0.1.1-recycle-alpha.3", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "dist", |
@@ -907,3 +907,4 @@ import noop from '@x-oasis/noop'; | ||
const targetIndices = []; | ||
const targetIndices = this._bufferSet.indices; | ||
const scrolling = actionType === 'scrollDown' || actionType === 'scrollUp'; | ||
@@ -914,21 +915,29 @@ | ||
for (let index = bufferedStartIndex; index < visibleStartIndex; index++) { | ||
const position = this.getPosition( | ||
index, | ||
bufferedStartIndex, | ||
visibleStartIndex | ||
); | ||
if (position !== null) targetIndices[position] = index; | ||
if (visibleEndIndex >= 0) { | ||
for (let index = visibleStartIndex; index <= visibleEndIndex; index++) { | ||
const position = this.getPosition( | ||
index, | ||
visibleStartIndex, | ||
visibleEndIndex | ||
); | ||
if (position !== null) targetIndices[position] = index; | ||
} | ||
} | ||
if (bufferedEndIndex >= 0) { | ||
for ( | ||
let index = visibleEndIndex + 1; | ||
index <= bufferedEndIndex; | ||
index++ | ||
) { | ||
const bufferSize = Math.floor( | ||
(this.recycleThreshold - | ||
Math.max(visibleEndIndex - visibleStartIndex, 0)) / | ||
2 | ||
); | ||
for ( | ||
let index = visibleStartIndex, size = bufferSize; | ||
size >= 0; | ||
size--, index-- | ||
) { | ||
if (index >= 0) { | ||
const position = this.getPosition( | ||
index, | ||
visibleEndIndex + 1, | ||
bufferedEndIndex | ||
bufferedStartIndex, | ||
visibleStartIndex | ||
); | ||
@@ -939,8 +948,12 @@ if (position !== null) targetIndices[position] = index; | ||
if (visibleEndIndex >= 0) { | ||
for (let index = visibleStartIndex; index <= visibleEndIndex; index++) { | ||
for ( | ||
let index = visibleEndIndex + 1, size = bufferSize; | ||
size >= 0; | ||
size--, index++ | ||
) { | ||
if (index >= 0) { | ||
const position = this.getPosition( | ||
index, | ||
visibleStartIndex, | ||
visibleEndIndex | ||
visibleEndIndex + 1, | ||
bufferedEndIndex | ||
); | ||
@@ -947,0 +960,0 @@ if (position !== null) targetIndices[position] = index; |
@@ -45,2 +45,11 @@ // import invariant from 'invariant'; | ||
get indices() { | ||
const indices = []; | ||
for (const key in this._valueToPositionMap) { | ||
const value = this._valueToPositionMap[key]; | ||
indices[value] = key; | ||
} | ||
return indices; | ||
} | ||
getValuePosition(value: number): null | number { | ||
@@ -47,0 +56,0 @@ if (this._valueToPositionMap[value] === undefined) { |
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
1534783
16594