【问题标题】:React - Infinite scrolling - child elemnts with dynamic heightsReact - 无限滚动 - 具有动态高度的子元素
【发布时间】:2017-01-30 13:20:15
【问题描述】:

我正在使用来自 (https://github.com/seatgeek/react-infinite) 的 react-infinite,以便在用户滚动时加载数据。

对我来说问题是子元素(在容器内),它们的高度是动态的。

这是html的结构:

<Infinite class="container" containerHeight={ContainerHeight} elementHeight={rowHieght}>
    <div class="child"> </div>
    <div class="child"> </div>
    ..
</Infinite>

所以当我通过无限时,我会动态计算 rowHeight 和 containerHeight。

问题是孩子可以有不同的身高(意思是1个孩子可以有100的高度,白色的第二个可以有300)。

这使得无限滚动有时会卡住。

这是无限滚动的可能场景吗?

【问题讨论】:

    标签: javascript reactjs infinite-scroll


    【解决方案1】:

    document,可以这样设置:

    <Infinite containerHeight={200} elementHeight={[111, 252, 143]}>
        <div className="111-px"/>
        <div className="252-px"/>
        <div className="143-px"/>
    </Infinite>
    

    【讨论】:

      猜你喜欢
      • 2019-03-19
      • 1970-01-01
      • 2021-12-12
      • 2017-08-30
      • 1970-01-01
      • 2018-01-18
      • 2017-01-25
      • 2019-07-29
      • 2017-10-21
      相关资源
      最近更新 更多