Skip to content

chore: calculateDimensionsIndexRange should calculate on begining #50

@ryuever

Description

@ryuever
  calculateDimensionsIndexRange() {
    let startIndex = 0;
    const rangeMap: {
      [key: string]: number;
    } = {};
    this._dimensionsIndexRange = this.indexKeys.reduce((acc, key) => {
      const dimensions = this.getDimension(key);
      const recyclerType = dimensions.recyclerType;
      if (rangeMap[recyclerType] === undefined) rangeMap[recyclerType] = 0;

      const endIndex = startIndex + dimensions.length;
      const startIndexInRecycler = rangeMap[recyclerType];
      rangeMap[recyclerType] = startIndexInRecycler + dimensions.length;
      acc.push({
        startIndex,
        endIndex,
        dimensions,
        startIndexInRecycler,
        enIndexInRecycler: rangeMap[recyclerType],
      });
      startIndex = endIndex;
      return acc;
    }, []);
  }

  onItemsCountChanged(useCache = false) {
    this.reflowFlattenData();
    this.calculateDimensionsIndexRange();
    this.calculateReflowItemsLength();
    this.updateChildDimensionsOffsetInContainer();
    this.updateScrollMetrics(this._scrollMetrics, { useCache });
  }

Basically, calculateDimensionsIndexRange is triggered onItemsCountChanged, It will be about 50ms delay comparing with registerList / registerItem.

Now this issue will cause itemMeta.getIndexInfo() return with null

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions