Skip to content

Commit b6e61b6

Browse files
committed
Fix: shouldn't have removed index
1 parent c12a01b commit b6e61b6

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Diff for: src/virtual/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ export function useVirtual(data: Val<object[]>, size: { height: number }) {
1414
buffer: 4,
1515
topGap: 0,
1616
bottomGap: 0,
17+
index: 0,
1718

1819
items: computed(() => {
1920
// Technically, size.height is slighty too high because it's the height of the full table,
2021
// including thead, rather than just tbody.
2122
// That's not an issue though, it just means one or two extra rows will be rendered past the bottom.
2223
const length = unref(data).length;
2324
const { buffer, rowHeight, scrollTop } = state;
24-
const index = Math.max((scrollTop / rowHeight | 0) - buffer, 0);
25+
const index = state.index = Math.max((scrollTop / rowHeight | 0) - buffer, 0);
2526
const count = Math.min((size.height / rowHeight | 0) + 1 + buffer + buffer, length - index);
2627
state.topGap = index * rowHeight;
2728
state.bottomGap = (length - count - index) * rowHeight;

Diff for: src/virtual/state.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface VirtualState {
77
buffer: number;
88
topGap: number;
99
bottomGap: number;
10+
index: number;
1011

1112
items: () => Iterator<object>;
1213
}

0 commit comments

Comments
 (0)