我正在使用 RV List 加载具有自定义格式的大型文档。它就像一个魅力,但我遇到了以下两个问题:我目前在 cellmeasurer 中基于此
设置了一个列表来计算行的动态高度(宽度是固定的)。我设法使用 scrollToindex 找到我想要的行,但有些行非常大,我希望能够滚动到行中的特定位置。我知道我需要使用 scrollTop 来执行此操作,但我不知道如何获取当前行的顶部 + 行内 div 的偏移量以使其正确滚动到正确的位置。我看到了一个类似问题的答案,其中发布了以下代码:
function render ({ scrollToIndex, ...rest }) {
// Convert scrollToIndex to scrollStop
const scrollTop =
**rowOffset** + // Position of row within List
**innerOffset** // Position of inner target within row
这是我的代码:
<AutoSizer>
{({ width, height }) => (
<CellMeasurer
cellRenderer={({index, isScrolling, style, key }) => SectionRenderer(index, key, style)}
columnCount={1}
rowCount={getSectionCount}
width={width}
>
{({ getRowHeight }) => (
<List
height={height}
rowHeight={getRowHeight}
rowCount={getSectionCount}
rowRenderer={({ index, isScrolling, style, key }) => SectionRenderer(index, key, style)}
overscanRowCount={10}
width={width}
scrollToIndex={scrollToSectionIndex}
/>
)}
</CellMeasurer>
)}
</AutoSizer>
我遇到的另一个问题是,虽然我将文档分成块,每个块都以标签结尾以确保文本的流畅(不重叠),但由于某种原因,文本中存在一些单元格测量器忽略的点导致重叠的行 div 的最后一行文本的高度。我还没有设法找到关于列表中重叠发生位置的一致模式。你有什么指示我如何调试这个问题:例如。单独测量给定部分并将其与 CellMeasurer 返回的测量值进行比较?