@past3lle/carousel-hooks
Version:
PASTELLE carousel animation hooks built on top of @usegesture and react-springs
42 lines • 2.41 kB
TypeScript
import { SpringConfig, SpringRef } from '@react-spring/web';
import { DragState, PinchState } from '@use-gesture/react';
import { MutableRefObject, SetStateAction } from 'react';
import { AxisDirection, InfiniteScrollHookOptions, InifniteScrollDataParams, WheelGestureParams } from '../types';
export declare function getNearestAxisPoint(point: number, multiple: number): number;
export declare const getIndex: (axis: number, l: number) => number;
export declare const getPos: (i: number, firstVisible: number, firstVisibleIndex: number, length: number) => number;
export declare const calculateInfiniteScrollApiLogic: (i: number, axisDirection: AxisDirection, { prevRef, active, last, axis, dAxis, mAxis, firstVis, firstVisIdx, scaleOptions, snapOnScroll, config, dataLength, itemSize, setCurrentIndex }: Omit<InfiniteScrollHookOptions, 'visible'> & Omit<WheelGestureParams, 'cancel'> & InifniteScrollDataParams) => {
[x: string]: number | boolean | SpringConfig | undefined;
scale: number;
immediate: boolean;
config: SpringConfig | undefined;
};
declare type RunSpringsParams<T> = Omit<T, 'firstVis' | 'firstVisIdx'> & InfiniteScrollHookOptions & InifniteScrollDataParams;
export declare function runInfiniteScrollSprings<T extends Record<any, any>>(api: SpringRef<T>, axisDirection: AxisDirection, { dataLength, itemSize, axis, dAxis, visible, prevRef, ...rest }: RunSpringsParams<Omit<WheelGestureParams, 'cancel'>>): void;
declare type GestureIndexOptions = {
current: MutableRefObject<number>;
last: number;
setIndex?: React.Dispatch<SetStateAction<number>>;
};
declare type DragLogicOptions = {
indexOptions: GestureIndexOptions;
itemSize: number;
axis: AxisDirection;
};
declare type PinchLogicOptions = {
ref?: HTMLElement | null;
};
declare const _default: {
wheel: {
infinite: typeof runInfiniteScrollSprings;
};
drag: {
infinite: typeof runInfiniteScrollSprings;
limited: ([, api]: any[], { axis: axisDirection, indexOptions, itemSize }: DragLogicOptions) => ({ active, movement, direction, cancel }: DragState) => void;
};
pinch: {
zoom: ([springs, api]: any[], { ref }: PinchLogicOptions) => ({ args: [index], origin: [ox, oy], first, movement: [ms], offset: [s], memo }: PinchState) => any;
};
};
export default _default;
//# sourceMappingURL=index.d.ts.map