Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/virtual-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ export class Virtualizer<
} else {
const endByLane = Array<number | null>(this.options.lanes).fill(null)
let endIndex = measurements.length - 1
while (endIndex > 0 && endByLane.some((val) => val === null)) {
while (endIndex >= 0 && endByLane.some((val) => val === null)) {
const item = measurements[endIndex]!
if (endByLane[item.lane] === null) {
endByLane[item.lane] = item.end
Expand Down Expand Up @@ -1162,7 +1162,7 @@ function calculateRange({
// Expand backward until we include all lanes' visible items
// closer to the top
const startPerLane = Array(lanes).fill(scrollOffset + outerSize)
while (startIndex > 0 && startPerLane.some((pos) => pos >= scrollOffset)) {
while (startIndex >= 0 && startPerLane.some((pos) => pos >= scrollOffset)) {
const item = measurements[startIndex]!
startPerLane[item.lane] = item.start
startIndex--
Expand Down
13 changes: 13 additions & 0 deletions packages/virtual-core/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,16 @@ test('should return empty items for empty scroll element', () => {
})
expect(virtualizer.getVirtualItems()).toEqual([])
})

test('should return correct total size with one item and multiple lanes', () => {
const virtualizer = new Virtualizer({
count: 1,
lanes: 2,
estimateSize: () => 50,
getScrollElement: () => null,
scrollToFn: vi.fn(),
observeElementRect: vi.fn(),
observeElementOffset: vi.fn(),
})
expect(virtualizer.getTotalSize()).toBe(50)
})