Fix avgRowHeight correcting bug

master
Vitaliy Filippov 2018-10-09 14:48:00 +03:00
parent b8e620d203
commit e9edd4d551
1 changed files with 6 additions and 6 deletions

View File

@ -111,10 +111,10 @@ export function virtualScrollDriver(props, oldState, getRenderedItemHeight)
}
sum += itemSize;
}
if (sum + newState.lastItemsTotalHeight + newState.topPlaceholderHeight > newState.targetHeight)
const correctedAvg = (sum + newState.lastItemsTotalHeight) / (count + newState.viewportItemCount);
if (correctedAvg > newState.avgRowHeight)
{
// avgRowHeight should be corrected
newState.avgRowHeight = (sum + newState.lastItemsTotalHeight) / (count + newState.viewportItemCount);
newState.avgRowHeight = correctedAvg;
}
}
else
@ -133,10 +133,10 @@ export function virtualScrollDriver(props, oldState, getRenderedItemHeight)
sum += itemSize;
}
newState.middlePlaceholderHeight = newState.targetHeight - sum - newState.lastItemsTotalHeight - newState.topPlaceholderHeight;
if (newState.middlePlaceholderHeight < 0)
const correctedAvg = (sum + newState.lastItemsTotalHeight) / (newState.middleItemCount + newState.viewportItemCount);
if (correctedAvg > newState.avgRowHeight)
{
// avgRowHeight should be corrected
newState.avgRowHeight = (sum + newState.lastItemsTotalHeight) / (newState.middleItemCount + newState.viewportItemCount);
newState.avgRowHeight = correctedAvg;
}
}
return newState;