From fe55c46e1210312e09806752493f2c09315b6d8d Mon Sep 17 00:00:00 2001 From: nuintun Date: Mon, 13 Jan 2025 10:20:27 +0800 Subject: [PATCH] feat: Update code --- src/index.ts | 6 +++--- src/utils/measure.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 550869c..49aa397 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ import { now } from './utils/now'; import { Align } from './utils/align'; import { getSize } from './utils/size'; -import { setMeasure } from './utils/measure'; +import { setMeasures } from './utils/measure'; import { getBoundingRect } from './utils/rect'; import { getInitialState } from './utils/state'; import { getVirtualRange } from './utils/range'; @@ -78,7 +78,7 @@ export function useVirtual(options if (remeasureIndex >= 0) { for (let index = remeasureIndex; index < count; index++) { - setMeasure(measures, index, getSize(index, size, measures, viewport)); + setMeasures(measures, index, getSize(index, size, measures, viewport)); } remeasureIndexRef.current = -1; @@ -154,7 +154,7 @@ export function useVirtual(options } } - setMeasure(measures, index, nextSize); + setMeasures(measures, index, nextSize); const { current: scrollOffset } = scrollOffsetRef; const { current: remeasureIndex } = remeasureIndexRef; diff --git a/src/utils/measure.ts b/src/utils/measure.ts index 1ad6c51..5b8e678 100644 --- a/src/utils/measure.ts +++ b/src/utils/measure.ts @@ -5,12 +5,12 @@ import { Measure } from './interface'; /** - * @function setMeasure + * @function setMeasures * @param measures 已缓存测量数组 * @param index 索引 * @param size 列表项目尺寸 */ -export function setMeasure(measures: Measure[], index: number, size: number): void { +export function setMeasures(measures: Measure[], index: number, size: number): void { const start = measures[index - 1]?.end || 0; measures[index] = { start, size, end: start + size };