在反应虚拟化的砌体中找到细胞的位置

时间:2018-03-21 13:25:07

标签: javascript reactjs react-virtualized

我正在渲染一个砖石。但是,我必须保留对节点位置的引用以进行空间索引。

我能找到的最佳方法是cellRenderer

中的一个非常好的方法
@hot(module)
export default class ProductsMasonry extends PureComponent {
  // my spatially indexed tree.
  tree: rbush.RBush<BoundingBox> = rbush();

  cellRenderer = ({ key, style, index }) => {
    this.tree.insert({
      minX: parseInt(style.left, 10),
      maxX: parseInt(style.left, 10) + parseInt(style.width, 10),
      minY: parseInt(style.top, 10),
      maxY: parseInt(style.top, 10) + parseInt(style.height, 10),
    });
  }
}

理想情况下,我想将其放在onCellsRendered中,但它只提供startIndexstopIndex,因此我不确定如何利用这些来获取尺寸和细胞的位置。

如何通过虚拟化反应来完成这项工作?

0 个答案:

没有答案
相关问题