UNPKG

1.75 kBTypeScriptView Raw
1import type { DependencyList, RNNativeScrollEvent, ReanimatedScrollEvent } from './commonTypes';
2import type { EventHandlerInternal, EventHandlerProcessed } from './useEvent';
3export type ScrollHandler<Context extends Record<string, unknown> = Record<string, unknown>> = (event: ReanimatedScrollEvent, context: Context) => void;
4export interface ScrollHandlers<Context extends Record<string, unknown>> {
5 onScroll?: ScrollHandler<Context>;
6 onBeginDrag?: ScrollHandler<Context>;
7 onEndDrag?: ScrollHandler<Context>;
8 onMomentumBegin?: ScrollHandler<Context>;
9 onMomentumEnd?: ScrollHandler<Context>;
10}
11export type ScrollHandlerProcessed<Context extends Record<string, unknown> = Record<string, unknown>> = EventHandlerProcessed<RNNativeScrollEvent, Context>;
12export type ScrollHandlerInternal = EventHandlerInternal<RNNativeScrollEvent>;
13/**
14 * Lets you run callbacks on ScrollView events. Supports `onScroll`,
15 * `onBeginDrag`, `onEndDrag`, `onMomentumBegin`, and `onMomentumEnd` events.
16 *
17 * These callbacks are automatically workletized and ran on the UI thread.
18 *
19 * @param handlers - An object containing event handlers.
20 * @param dependencies - An optional array of dependencies. Only relevant when
21 * using Reanimated without the Babel plugin on the Web.
22 * @returns An object you need to pass to `onScroll` prop on the
23 * `Animated.ScrollView` component.
24 * @see https://docs.swmansion.com/react-native-reanimated/docs/scroll/useAnimatedScrollHandler
25 */
26export declare function useAnimatedScrollHandler<Context extends Record<string, unknown>>(handlers: ScrollHandler<Context> | ScrollHandlers<Context>, dependencies?: DependencyList): ScrollHandlerProcessed<Context>;
27//# sourceMappingURL=useAnimatedScrollHandler.d.ts.map
\No newline at end of file