parent
ba46a65559
commit
ea707b2c08
|
@ -61,8 +61,10 @@ export function virtualScrollDriver(props, oldState, getRenderedItemHeight)
|
||||||
lastItemSize = getRenderedItemHeight(props.totalItems - 1 - lastVisibleItems);
|
lastItemSize = getRenderedItemHeight(props.totalItems - 1 - lastVisibleItems);
|
||||||
if (!lastItemSize)
|
if (!lastItemSize)
|
||||||
{
|
{
|
||||||
// Some required items in the end are missing
|
// Some required items in the end are missing, complain about it loudly, but don't break scrolling
|
||||||
return newState;
|
// eslint-disable-next-line
|
||||||
|
console.error('dynamic-virtual-scroll: item #'+(props.totalItems - 1 - lastVisibleItems)+' is missing from render, please fix your code');
|
||||||
|
lastItemSize = 0;
|
||||||
}
|
}
|
||||||
lastItemsHeight += lastItemSize < props.minRowHeight ? props.minRowHeight : lastItemSize;
|
lastItemsHeight += lastItemSize < props.minRowHeight ? props.minRowHeight : lastItemSize;
|
||||||
lastVisibleItems++;
|
lastVisibleItems++;
|
||||||
|
|
|
@ -36,10 +36,22 @@ export class VirtualScrollList extends React.Component
|
||||||
|
|
||||||
setItemRef = []
|
setItemRef = []
|
||||||
itemRefs = []
|
itemRefs = []
|
||||||
|
itemRefCount = []
|
||||||
|
|
||||||
makeRef(i)
|
makeRef(i)
|
||||||
{
|
{
|
||||||
this.setItemRef[i] = (e) => this.itemRefs[i] = e;
|
this.setItemRef[i] = (e) =>
|
||||||
|
{
|
||||||
|
// If the new row instance is mounted before unmouting the old one,
|
||||||
|
// we get called 2 times in wrong order: first with the new instance,
|
||||||
|
// then with null telling us that the old one is unmounted.
|
||||||
|
// We track reference count to workaround it.
|
||||||
|
this.itemRefCount[i] = (this.itemRefCount[i]||0) + (e ? 1 : -1);
|
||||||
|
if (e || !this.itemRefCount[i])
|
||||||
|
{
|
||||||
|
this.itemRefs[i] = e;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
renderItems(start, count, is_end)
|
renderItems(start, count, is_end)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "dynamic-virtual-scroll",
|
"name": "dynamic-virtual-scroll",
|
||||||
"version": "1.0.13",
|
"version": "1.0.14",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Vitaliy Filippov",
|
"name": "Vitaliy Filippov",
|
||||||
"email": "vitalif@yourcmc.ru",
|
"email": "vitalif@yourcmc.ru",
|
||||||
|
|
Loading…
Reference in New Issue