Skip to content
Open
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
5 changes: 1 addition & 4 deletions src/hooks/useScrollTo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,16 @@ export default function useScrollTo<T>(
const mergedAlign = targetAlign || originAlign;

// Get top & bottom
let stackTop = 0;
let itemTop = 0;
let itemBottom = 0;

const maxLen = Math.min(data.length - 1, index);

for (let i = 0; i <= maxLen; i += 1) {
const key = getKey(data[i]);
itemTop = stackTop;
itemTop = itemBottom;
const cacheHeight = heights.get(key);
itemBottom = itemTop + (cacheHeight === undefined ? itemHeight : cacheHeight);

stackTop = itemBottom;
}

// Check if need sync height (visible range has item not record height)
Expand Down