react-virtualized: define types for onRowsRendered props in List (#43972)

* [react-virtualized] define types for onRowsRendered props in List

* rename type onRowsRenderedParams -> RenderedRows

* fix type name

* reuse existing type

* fix OverscanIndices
This commit is contained in:
WrinkleJ 2020-04-17 05:25:57 +03:00 committed by GitHub
parent 17aaf05a60
commit d100a7141e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 14 deletions

View File

@ -2,7 +2,7 @@ import { Validator, Requireable, PureComponent, Component } from 'react';
import { List } from './List';
import { Table } from './Table';
import { CellMeasurerCache, MeasuredCellParent } from './CellMeasurer';
import { Index, Map, Alignment } from '../../index';
import { Index, Map, Alignment, OverscanIndexRange } from '../../index';
export type RenderedSection = {
columnOverscanStartIndex: number;
@ -70,10 +70,9 @@ export type OverscanIndicesGetterParams = {
startIndex: number;
stopIndex: number;
};
export type OverscanIndices = {
overscanStartIndex: number;
overscanStopIndex: number;
};
export type OverscanIndices = OverscanIndexRange;
export type OverscanIndicesGetter = (params: OverscanIndicesGetterParams) => OverscanIndices;
export type ScrollOffset = {

View File

@ -2,7 +2,7 @@ import { PureComponent, Validator, Requireable } from 'react';
import { Index, IndexRange } from '../../index';
export type InfiniteLoaderChildProps = {
onRowsRendered: (params: { startIndex: number; stopIndex: number }) => void;
onRowsRendered: (params: IndexRange) => void;
registerChild: (registeredChild: any) => void;
};

View File

@ -1,6 +1,6 @@
import { PureComponent, Validator, Requireable } from 'react';
import { Grid, GridCoreProps, GridCellProps, OverscanIndicesGetter } from './Grid';
import { Index, IndexRange, Alignment } from '../../index';
import { Index, IndexRange, OverscanIndexRange, Alignment } from '../../index';
import { CellMeasurerCache, CellPosition } from './CellMeasurer';
import { OnScrollParams } from './ScrollSync';
@ -9,6 +9,9 @@ export type ListRowProps = Pick<GridCellProps, Exclude<keyof GridCellProps, 'row
};
export type ListRowRenderer = (props: ListRowProps) => React.ReactNode;
export type RenderedRows = OverscanIndexRange & IndexRange;
export type ListProps = GridCoreProps & {
deferredMeasurementCache?: CellMeasurerCache;
/**
@ -31,12 +34,7 @@ export type ListProps = GridCoreProps & {
* Callback invoked with information about the slice of rows that were just rendered.
* ({ startIndex, stopIndex }): void
*/
onRowsRendered?: (info: {
overscanStartIndex: number;
overscanStopIndex: number;
startIndex: number;
stopIndex: number;
}) => void;
onRowsRendered?: (info: RenderedRows) => void;
/**
* Number of rows to render above/below the visible bounds of the list.
* These rows can help for smoother scrolling on touch devices.

View File

@ -1,13 +1,14 @@
import { PureComponent, Validator, Requireable } from 'react';
import { CellMeasurerCacheInterface, KeyMapper, MeasuredCellParent } from './CellMeasurer';
import { GridCellRenderer } from './Grid';
import { IndexRange } from '../../index';
/**
* Specifies the number of miliseconds during which to disable pointer events while a scroll is in progress.
* This improves performance and makes scrolling smoother.
*/
export const DEFAULT_SCROLLING_RESET_TIME_INTERVAL = 150;
export type OnCellsRenderedCallback = (params: { startIndex: number; stopIndex: number }) => void;
export type OnCellsRenderedCallback = (params: IndexRange) => void;
export type OnScrollCallback = (params: { clientHeight: number; scrollHeight: number; scrollTop: number }) => void;