监听滚动条到底部事件响应

直接拿一个页面过来说问题,好桑心获取节点困了好久,然而只想简简单单用这篇文章来记录滚动条滚到底部触发事件

@inject('blogAttentionStore')
@observer
export default class ShareToMe extends React.Component {

  constructor(props) {
    super(props);
    let {parentHeight} = props;

    this.state={
      shareList:[],
      parentHeight:parentHeight,
    }
  }

  // 高度计算
  listHeight = () => {
    let parentHeight = this.state.parentHeight;
    let tabHeight = document.getElementsByClassName('am-tabs-tab-bar-wrap')[0].offsetHeight,
      searchHeight = document.getElementsByClassName('am-search')[0].offsetHeight;
      parentHeight = parentHeight - tabHeight - searchHeight;
    return parentHeight;
  }

  dropDown = () => {
    /* console.log('滚动的高度',this.refs.list.scrollTop)
    console.log('窗口的高度',this.refs.list.offsetHeight)
    console.log('文档的高度',document.getElementsByClassName('blog-shareToMe-list')[0].offsetHeight) */
    let documentHeight = document.getElementsByClassName('blog-shareToMe-list')[0].offsetHeight,
      scrollHeight = this.refs.list.scrollTop,
      divHeight = this.refs.list.offsetHeight;
    if(documentHeight-scrollHeight<=divHeight) {
      console.log('1');
    }
  }

  render() {
    const { blogAttentionStore: { shareList } } = this.props;
    return (
      <div className='blog-blogAttention-shareToMe'>
        <SearchBar
          className = 'blog-blogAttention-shareToMe-searchBar'
          placeholder = {getLabel(32933,'请输入关键字')} 
        />
        <div ref='list' style={{height:this.listHeight(), overflow:'auto'}} onScroll={this.dropDown}>
          <Item className='blog-shareToMe-list' attentionList={ shareList }/>
        </div>
      </div>
    )
  }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值