Skip to content

Commit

Permalink
fix: the callback of scrollToItem is called twice
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyshen committed Jun 3, 2021
1 parent 59b9267 commit 0e187f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/stale-glasses-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-cool-virtual": patch
---

fix: the callback of `scrollToItem` is called twice
5 changes: 4 additions & 1 deletion src/useVirtual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,14 @@ export default <

if (
hasDynamicSizeRef.current &&
align === Align.auto &&
scrollOffset <= start &&
scrollOffset + outerSize >= end &&
cb
)
) {
cb();
return;
}

const endPos = start - outerSize + size;

Expand Down

0 comments on commit 0e187f9

Please sign in to comment.