VirtualScroller: prevent reflow loop when origin=top

This commit is contained in:
Liam Fitzgerald 2021-06-28 15:12:49 +10:00
parent 517e4c726c
commit 0653685f26
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB

View File

@ -498,10 +498,10 @@ export default class VirtualScroller<K,V> extends Component<VirtualScrollerProps
const { visibleItems } = this.state; const { visibleItems } = this.state;
const { keyToString } = this.props; const { keyToString } = this.props;
let bottomIndex = visibleItems[visibleItems.length - 1];
const { scrollTop, scrollHeight } = this.window; const { scrollTop, scrollHeight } = this.window;
const topSpacing = this.props.origin === 'top' ? scrollTop : scrollHeight - scrollTop; const topSpacing = this.props.origin === 'top' ? scrollTop : scrollHeight - scrollTop;
const items = this.props.origin === 'top' ? visibleItems : [...visibleItems].reverse(); const items = this.props.origin === 'top' ? visibleItems : [...visibleItems].reverse();
let bottomIndex = items[0];
items.forEach((index) => { items.forEach((index) => {
const el = this.childRefs.get(keyToString(index)); const el = this.childRefs.get(keyToString(index));
if(!el) { if(!el) {