import { h, Component, JSX } from 'preact'; interface VirtualListScrollProps { /** * 滚动回弹类型, 具体表现为是否可以拖动超过内容大小值 * - elastic: 触顶触底会回弹 * - clamped: 触顶触底不回弹 * - 默认值:elastic */ movementType?: 'elastic' | 'clamped'; /** * 滑动灵敏度 * - 值越大滑动越灵敏, 滑动距离会乘上滑动灵敏度 * - 默认值:1 */ scrollSensitivity?: number; /** * 是否有惯性 * - true: 滑动后会有惯性滚动 * - false: 滑动后立即停止 * - 默认值:true */ inertia?: boolean; /** * 惯性函数版本 * - 1: 倾向于unity的惯性效果 * - 2: 倾向于ue的惯性效果 * - 默认值:2 */ inertiaVersion?: number; /** * 惯性衰减率, 仅在inertiaVersion为1时生效 * - 取值范围:0(立即停止)到 1(无减速) * - 默认值:0.135 */ decelerationRate?: number; /** * 静态速度阻力, 仅在inertiaVersion为2时生效 * - 每秒速度的固定衰减值 * - 默认值:100 */ staticVelocityDrag?: number; /** * 摩擦系数, 仅在inertiaVersion为2时生效 * - 每秒速度的动态衰减值, 当前速度*frictionCoefficient * - 默认值:2.0 */ frictionCoefficient?: number; } interface VirtualListProps { /** 布局方向 - horizontal: 水平布局, vertical: 垂直布局 */ layout: 'horizontal' | 'vertical'; /** 渲染列表项的函数,接收索引返回JSX元素 */ renderItemFunc: (index: number) => JSX.Element; /** 每个列表项的尺寸(水平布局时为宽度,垂直布局时为高度) */ itemSize: number; /** 列表项总数 */ itemCount: number; /** 可视区域宽度 */ width: any; /** 可视区域高度 */ height: any; /** 缓存的列表项数量(会在可视区域前后多渲染的数量) */ cacheSize: number; /** 自定义样式, 会添加到组件根节点 */ style?: {}; /** 是否还有更多数据可以加载, 返回false会阻止后续判断是否loadMore */ hasMore?: () => boolean; /** 触底阈值, 到达后会调用loadMore, 默认为itemSize*2 */ touchBottomThreshold?: number; /** 加载更多数据的回调函数 */ loadMore?: () => Promise; /** 滚动相关配置属性 */ scrollProps?: VirtualListScrollProps; } interface VirtualListState { start: number; end: number; listHeight: number; } export declare class VirtualList extends Component { itemCache: Array<{ vNode: h.JSX.Element; isValid: any; ref: any; }>; style: { position?: string; height?: number; width?: any; }; ref: any; listSize: number; /** 列表总长度 */ protected listHeight: number; /** 触底阈值 */ protected touchBottomThreshold: number; /** 视窗可见数量 */ protected itemCount: number; /** 是否正在加载更多 */ protected isLoading: boolean; /** 视窗可见数量 */ protected visibleCount: number; constructor(props: VirtualListProps); componentDidMount(): void; shouldComponentUpdate(nextProps: Readonly, nextState: Readonly, nextContext: any): boolean; componentWillReceiveProps(nextProps: Readonly): void; onScroll: (e: Event) => void; private HandleScrollProps; render(): h.JSX.Element; } export {};