fix: scrollY未定义

This commit is contained in:
liushaozhen 2020-06-12 13:31:46 +08:00
parent 4554f26ff7
commit b08ee805bc
1 changed files with 6 additions and 1 deletions

View File

@ -194,7 +194,12 @@ export default class InfiniteScroll extends Component {
* @description 根据返回的scrollTop计算当前的索引
*/
handleScrollY = () => {
let rowHeight = this.props.store.getState().rowHeight;
const parentElement = this.getParentElement(this.scrollComponent);
if (!parentElement) {
return;
}
let scrollEl = parentElement;
let scrollY = scrollEl && scrollEl.clientHeight;
//默认显示20条rowsInView根据定高算的。在非固定高下这个只是一个大概的值。
this.rowsInView = scrollY ? Math.floor(scrollY / rowHeight) : CONFIG.defaultRowsInView;