VirtualScroller: fix scrollbar positioning

This commit is contained in:
Liam Fitzgerald 2021-03-03 13:56:22 +10:00
parent 75a00b9c18
commit 02a70af365
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB

View File

@ -136,11 +136,12 @@ export default class VirtualScroller<T> extends Component<VirtualScrollerProps<T
} }
const { scrollTop, scrollHeight, offsetHeight } = this.window; const { scrollTop, scrollHeight, offsetHeight } = this.window;
const unloaded = (this.startOffset() / this.props.size); const unloaded = (this.startOffset() / this.pageSize);
const totalpages = this.props.size / this.pageSize;
const loadedCen = (scrollTop / scrollHeight); const loaded = (scrollTop / scrollHeight);
const loaded = (loadedCen / (this.pageSize / this.props.averageHeight)); const total = unloaded + loaded;
const result = (unloaded + loaded)*this.window.offsetHeight; const result = ((unloaded + loaded) / totalpages) *this.window.offsetHeight;
this.scrollRef.style[this.props.origin] = `${result}px`; this.scrollRef.style[this.props.origin] = `${result}px`;
}, 50); }, 50);