@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
101 lines (100 loc) • 2.65 kB
TypeScript
import { Orientation } from "../../core/system/index.types.js";
import "../../core/index.js";
import { RefObject } from "react";
//#region src/components/infinite-scroll-area/use-infinite-scroll.d.ts
interface UseInfiniteScrollProps extends Omit<IntersectionObserverInit, "root"> {
/**
* Determines whether scrolling is instant or animates smoothly.
*/
behavior?: ScrollBehavior;
/**
* If `true`, the infinite scroll is disabled.
*
* @default false
*/
disabled?: boolean;
/**
* Ref to a reset index function.
*/
indexRef?: RefObject<(index: number) => void>;
/**
* If `true`, invoke `onLoad` function for the first time.
*
* @default false
*/
initialLoad?: boolean;
/**
* The orientation of the infinite scroll.
*
* @default 'vertical'
*/
orientation?: Orientation;
/**
* Ref to a reset function.
*/
resetRef?: RefObject<(index?: number, runScroll?: boolean) => void>;
/**
* If `true`, reverse direction.
*
* @default false
*/
reverse?: boolean;
/**
* Margin around the root. Can have values similar to the CSS margin property,
* e.g. "10px 20px 30px 40px" (top, right, bottom, left).
*/
rootMargin?: string;
/**
* The element that is used as the viewport for checking visibility of the target.
* Defaults to the browser viewport if not specified or if `null`.
*/
rootRef?: RefObject<HTMLElement | null>;
/**
* If set the `onLoad` function will start from the given index.
* If `initialLoad` is `true`, index starts from `0`.
*
* @default 1
*/
startIndex?: number;
/**
* Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed.
*/
threshold?: number | number[];
/**
* The callback invoked when trigger is intersect.
*/
onLoad?: ({
entry,
finish,
index
}: {
finish: () => void;
index: number;
entry?: IntersectionObserverEntry;
}) => Promise<void> | void;
}
/**
* `useInfiniteScroll` is a custom hook for providing infinite scroll functionality.
*
* @see https://yamada-ui.com/docs/hooks/use-infinite-scroll
*/
declare const useInfiniteScroll: <Y extends HTMLElement = HTMLDivElement>({
behavior,
disabled,
indexRef: indexRefProp,
initialLoad,
orientation,
resetRef,
reverse,
rootMargin,
rootRef,
startIndex,
threshold,
onLoad: onLoadProp
}?: UseInfiniteScrollProps) => {
ref: RefObject<Y | null>;
finish: boolean;
};
//#endregion
export { UseInfiniteScrollProps, useInfiniteScroll };
//# sourceMappingURL=use-infinite-scroll.d.ts.map