争渡,争渡,惊起一滩鸥鹭

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

<article onScroll={this.handleScroll.bind(this)} ref="scrollWrap" data-scroll={'yes'} style={{ "height": "calc(100vh - 3.5rem)", "overflow": 'auto', "overflowY": "scroll", "WebkitOverflowScrolling": "touch" }}>
        <div className="wrap" ref="productList">
             遍历的内容
        </div>
</article>

 

    handleScroll(topVal) {
        let self = this;
        let isPending = this.state.isPending;
        let clientHeight = this.refs.productList.clientHeight;
        let scrollHeight = this.refs.scrollWrap.clientHeight;
        let scrollTop = this.refs.scrollWrap.scrollTop;

        if(!isPending){
            if (scrollHeight + scrollTop +5 >= clientHeight) {
                self.setState({isPending:true});
                self.getMoreProducts(this.state.pageNum+1);
            }
        }

    }

 

posted on 2021-07-24 16:27  争渡~  阅读(194)  评论(0)    收藏  举报