Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuever committed Jul 4, 2023
1 parent 4977583 commit 2be2fff
Showing 1 changed file with 42 additions and 27 deletions.
69 changes: 42 additions & 27 deletions packages/data-model/src/ListDimensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1252,43 +1252,58 @@ class ListDimensions<ItemT extends {} = {}> 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,
Expand Down

0 comments on commit 2be2fff

Please sign in to comment.