diff --git a/src/VirtualList/SizeAndPositionManager.js b/src/VirtualList/SizeAndPositionManager.js index 52b7927..36b32aa 100644 --- a/src/VirtualList/SizeAndPositionManager.js +++ b/src/VirtualList/SizeAndPositionManager.js @@ -134,7 +134,7 @@ export default class SizeAndPositionManager { if (overscanCount) { start = Math.max(0, start - overscanCount); - stop = Math.min(stop + overscanCount, this._itemCount); + stop = Math.min(stop + overscanCount, this._itemCount - 1); } return { diff --git a/tests/SizeAndPositionManager.test.js b/tests/SizeAndPositionManager.test.js index 232e919..e85de76 100644 --- a/tests/SizeAndPositionManager.test.js +++ b/tests/SizeAndPositionManager.test.js @@ -410,6 +410,17 @@ describe('SizeAndPositionManager', () => { expect(start).toEqual(95); expect(stop).toEqual(99); }); + + it("should return a visible range of items for the end of the list", () => { + const {sizeAndPositionManager} = getItemSizeAndPositionManager(); + const {start, stop} = sizeAndPositionManager.getVisibleRange({ + containerSize: 50, + offset: 950, + overscanCount: 5, + }); + expect(start).toEqual(90); + expect(stop).toEqual(99); + }); }); describe('resetItem', () => {