Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added indexes for other idGetter usages #376

Merged
Merged
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions src/components/VirtualizedList/virtualized-list-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const easeInOutQuint = time => {

function findItemAtOffset(items, normalizedItems, idGetter, fromIndex, offset) {
for (let i = fromIndex; i < items.length; i++) {
const itemId = idGetter(items[i]);
const itemId = idGetter(items[i], i);
const normalizedItem = normalizedItems[itemId];
const { height, offsetTop } = normalizedItem || EMPTY_OBJECT;
if (height + offsetTop > offset) {
Expand All @@ -51,7 +51,7 @@ function findItemAtOffset(items, normalizedItems, idGetter, fromIndex, offset) {

export const isVerticalScrollbarVisible = (items, normalizedItems, idGetter, listHeight) => {
const lastExistingItem = items[items.length - 1] || EMPTY_OBJECT;
const lastExistingItemId = idGetter(lastExistingItem);
const lastExistingItemId = idGetter(lastExistingItem, i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix eslint and tests errors :)

MosheZemah marked this conversation as resolved.
Show resolved Hide resolved
const normalizedItem = normalizedItems[lastExistingItemId];
if (!normalizedItem) return false;
const { offsetTop: lastExistingItemIdOffsetTop, height: lastExistingItemHeight } = normalizedItems[
Expand All @@ -74,9 +74,9 @@ export const getOnItemsRenderedData = (
const firstVisibleItem = items[visibleStartIndex] || EMPTY_OBJECT;
const secondVisibleItem = items[visibleStartIndex + 1] || EMPTY_OBJECT;
const lastVisibleItem = items[visibleStopIndex] || EMPTY_OBJECT;
const firstItemId = idGetter(firstVisibleItem);
const secondItemId = idGetter(secondVisibleItem);
const lastItemId = idGetter(lastVisibleItem);
const firstItemId = idGetter(firstVisibleItem, visibleStartIndex);
const secondItemId = idGetter(secondVisibleItem, visibleStartIndex + 1);
const lastItemId = idGetter(lastVisibleItem, visibleStopIndex);
const centerOffset = currentOffsetTop + listHeight / 2;
const { offsetTop: firstItemOffsetTop, height: firstItemHeight } = normalizedItems[firstItemId] || EMPTY_OBJECT;
const firstItemOffsetEnd = firstItemOffsetTop + firstItemHeight;
Expand Down