From 2be2fff530cff09a019ad3e097cb8e3899d98a76 Mon Sep 17 00:00:00 2001 From: ryuever Date: Tue, 4 Jul 2023 13:42:10 +0800 Subject: [PATCH] feat: update --- packages/data-model/src/ListDimensions.ts | 69 ++++++++++++++--------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/packages/data-model/src/ListDimensions.ts b/packages/data-model/src/ListDimensions.ts index 470f76c2..b55c6aab 100644 --- a/packages/data-model/src/ListDimensions.ts +++ b/packages/data-model/src/ListDimensions.ts @@ -1252,43 +1252,58 @@ class ListDimensions extends BaseDimensions { // ); if (this._getItemLayout || this._approximateMode) { - // if velocity greater than 4, the below on high priority. then start position - // forward 4, - if (velocity > 4) { + if (Math.abs(velocity) <= 1) { this.updateIndices(targetIndices, { safeRange, - startIndex: visibleStartIndex + 4, - maxCount: visibleEndIndex - visibleStartIndex + 1, + startIndex: visibleStartIndex - 1, + maxCount: visibleEndIndex - visibleStartIndex + 3, step: 1, }); - // if velocity less than -4, the above on high priority. then start position - // forward 4, - } else if (velocity < -4) { + } else { this.updateIndices(targetIndices, { safeRange, - startIndex: visibleStartIndex - 4, + startIndex: visibleStartIndex, maxCount: visibleEndIndex - visibleStartIndex + 1, step: 1, }); - } else { - // if velocity less than 1, scroll will stop soon, so add 1 element - // on heading and trailing as buffer - if (Math.abs(velocity) <= 1) { - this.updateIndices(targetIndices, { - safeRange, - startIndex: visibleStartIndex - 1, - maxCount: visibleEndIndex - visibleStartIndex + 3, - step: 1, - }); - } else { - this.updateIndices(targetIndices, { - safeRange, - startIndex: visibleStartIndex, - maxCount: visibleEndIndex - visibleStartIndex + 1, - step: 1, - }); - } } + // if velocity greater than 4, the below on high priority. then start position + // forward 4, + // if (velocity > 4) { + // this.updateIndices(targetIndices, { + // safeRange, + // startIndex: visibleStartIndex + 4, + // maxCount: visibleEndIndex - visibleStartIndex + 1, + // step: 1, + // }); + // // if velocity less than -4, the above on high priority. then start position + // // forward 4, + // } else if (velocity < -4) { + // this.updateIndices(targetIndices, { + // safeRange, + // startIndex: visibleStartIndex - 4, + // maxCount: visibleEndIndex - visibleStartIndex + 1, + // step: 1, + // }); + // } else { + // // if velocity less than 1, scroll will stop soon, so add 1 element + // // on heading and trailing as buffer + // if (Math.abs(velocity) <= 1) { + // this.updateIndices(targetIndices, { + // safeRange, + // startIndex: visibleStartIndex - 1, + // maxCount: visibleEndIndex - visibleStartIndex + 3, + // step: 1, + // }); + // } else { + // this.updateIndices(targetIndices, { + // safeRange, + // startIndex: visibleStartIndex, + // maxCount: visibleEndIndex - visibleStartIndex + 1, + // step: 1, + // }); + // } + // } } else { this.updateIndices(targetIndices, { safeRange,