From bf7d25be40d2a6551a7741a710fb99da743dd3e1 Mon Sep 17 00:00:00 2001 From: Welly Shen Date: Sat, 29 May 2021 00:05:51 +0800 Subject: [PATCH] fix: correct the high of bindary-search for finding the item index from scroll --- .changeset/orange-dolls-raise.md | 5 +++++ src/useVirtual.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/orange-dolls-raise.md diff --git a/.changeset/orange-dolls-raise.md b/.changeset/orange-dolls-raise.md new file mode 100644 index 00000000..6b92f09e --- /dev/null +++ b/.changeset/orange-dolls-raise.md @@ -0,0 +1,5 @@ +--- +"react-cool-virtual": patch +--- + +fix: correct the high of bindary-search for finding the item index from scroll diff --git a/src/useVirtual.ts b/src/useVirtual.ts index 202b08cc..4c309c49 100644 --- a/src/useVirtual.ts +++ b/src/useVirtual.ts @@ -147,7 +147,7 @@ export default < } else { vStart = findNearestBinarySearch( 0, - msData.length, + msData.length - 1, scrollOffset, (idx) => msData[idx].start );