useScrollTo.d.ts 699 B

123456789101112131415161718
  1. import * as React from 'react';
  2. import type { GetKey } from '../interface';
  3. import type CacheMap from '../utils/CacheMap';
  4. export type ScrollAlign = 'top' | 'bottom' | 'auto';
  5. export type ScrollPos = {
  6. left?: number;
  7. top?: number;
  8. };
  9. export type ScrollTarget = {
  10. index: number;
  11. align?: ScrollAlign;
  12. offset?: number;
  13. } | {
  14. key: React.Key;
  15. align?: ScrollAlign;
  16. offset?: number;
  17. };
  18. export default function useScrollTo<T>(containerRef: React.RefObject<HTMLDivElement>, data: T[], heights: CacheMap, itemHeight: number, getKey: GetKey<T>, collectHeight: () => void, syncScrollTop: (newTop: number) => void, triggerFlash: () => void): (arg: number | ScrollTarget) => void;