Skip to content

Commit

Permalink
feat: Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
nuintun committed Jan 13, 2025
1 parent b557cd8 commit fe55c46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -78,7 +78,7 @@ export function useVirtual<T extends HTMLElement, U extends HTMLElement>(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;
Expand Down Expand Up @@ -154,7 +154,7 @@ export function useVirtual<T extends HTMLElement, U extends HTMLElement>(options
}
}

setMeasure(measures, index, nextSize);
setMeasures(measures, index, nextSize);

const { current: scrollOffset } = scrollOffsetRef;
const { current: remeasureIndex } = remeasureIndexRef;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/measure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit fe55c46

Please sign in to comment.