UNPKG

2.16 kBTypeScriptView Raw
1import type { AnimatableValue, AnimationObject, Animation, ReduceMotion, Timestamp, RequiredKeys } from '../../commonTypes';
2export declare const VELOCITY_EPS: number;
3export declare const SLOPE_FACTOR = 0.1;
4export interface DecayAnimation extends Animation<DecayAnimation> {
5 lastTimestamp: Timestamp;
6 startTimestamp: Timestamp;
7 initialVelocity: number;
8 velocity: number;
9 current: AnimatableValue;
10}
11export interface InnerDecayAnimation extends Omit<DecayAnimation, 'current'>, AnimationObject {
12 current: number;
13 springActive?: boolean;
14}
15/**
16 * The decay animation configuration.
17 *
18 * @param velocity - Initial velocity of the animation. Defaults to 0.
19 * @param deceleration - The rate at which the velocity decreases over time.
20 * Defaults to 0.998.
21 * @param clamp - Array of two numbers which restricts animation's range.
22 * Defaults to [].
23 * @param velocityFactor - Velocity multiplier. Defaults to 1.
24 * @param rubberBandEffect - Makes the animation bounce over the limit specified
25 * in `clamp`. Defaults to `false`.
26 * @param rubberBandFactor - Strength of the rubber band effect. Defaults to
27 * 0.6.
28 * @param reduceMotion - Determines how the animation responds to the device's
29 * reduced motion accessibility setting. Default to `ReduceMotion.System` -
30 * {@link ReduceMotion}.
31 * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDecay#config
32 */
33export type DecayConfig = {
34 deceleration?: number;
35 velocityFactor?: number;
36 velocity?: number;
37 reduceMotion?: ReduceMotion;
38} & ({
39 rubberBandEffect?: false;
40 clamp?: [min: number, max: number];
41} | {
42 rubberBandEffect: true;
43 clamp: [min: number, max: number];
44 rubberBandFactor?: number;
45});
46export type DefaultDecayConfig = RequiredKeys<DecayConfig, 'deceleration' | 'velocityFactor' | 'velocity'> & {
47 rubberBandFactor: number;
48};
49export type RubberBandDecayConfig = RequiredKeys<DefaultDecayConfig, 'clamp'> & {
50 rubberBandEffect: true;
51};
52export declare function isValidRubberBandConfig(config: DefaultDecayConfig): config is RubberBandDecayConfig;
53//# sourceMappingURL=utils.d.ts.map
\No newline at end of file