1 | import type { Animation, AnimatableValue, Timestamp, ReduceMotion } from '../commonTypes';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | export type SpringConfig = {
|
29 | stiffness?: number;
|
30 | overshootClamping?: boolean;
|
31 | restDisplacementThreshold?: number;
|
32 | restSpeedThreshold?: number;
|
33 | velocity?: number;
|
34 | reduceMotion?: ReduceMotion;
|
35 | } & ({
|
36 | mass?: number;
|
37 | damping?: number;
|
38 | duration?: never;
|
39 | dampingRatio?: never;
|
40 | clamp?: never;
|
41 | } | {
|
42 | mass?: never;
|
43 | damping?: never;
|
44 | duration?: number;
|
45 | dampingRatio?: number;
|
46 | clamp?: {
|
47 | min?: number;
|
48 | max?: number;
|
49 | };
|
50 | });
|
51 | export type DefaultSpringConfig = {
|
52 | [K in keyof Required<SpringConfig>]: K extends 'reduceMotion' | 'clamp' ? Required<SpringConfig>[K] | undefined : Required<SpringConfig>[K];
|
53 | };
|
54 | export type WithSpringConfig = SpringConfig;
|
55 | export interface SpringConfigInner {
|
56 | useDuration: boolean;
|
57 | skipAnimation: boolean;
|
58 | }
|
59 | export interface SpringAnimation extends Animation<SpringAnimation> {
|
60 | current: AnimatableValue;
|
61 | toValue: AnimatableValue;
|
62 | velocity: number;
|
63 | lastTimestamp: Timestamp;
|
64 | startTimestamp: Timestamp;
|
65 | startValue: number;
|
66 | zeta: number;
|
67 | omega0: number;
|
68 | omega1: number;
|
69 | }
|
70 | export interface InnerSpringAnimation extends Omit<SpringAnimation, 'toValue' | 'current'> {
|
71 | toValue: number;
|
72 | current: number;
|
73 | }
|
74 | export declare function checkIfConfigIsValid(config: DefaultSpringConfig): boolean;
|
75 | export declare function bisectRoot({ min, max, func, maxIterations, }: {
|
76 | min: number;
|
77 | max: number;
|
78 | func: (x: number) => number;
|
79 | maxIterations?: number;
|
80 | }): number;
|
81 | export declare function initialCalculations(mass: number | undefined, config: DefaultSpringConfig & SpringConfigInner): {
|
82 | zeta: number;
|
83 | omega0: number;
|
84 | omega1: number;
|
85 | };
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 | export declare function scaleZetaToMatchClamps(animation: SpringAnimation, clamp: {
|
92 | min?: number;
|
93 | max?: number;
|
94 | }): number;
|
95 |
|
96 | export declare function calculateNewMassToMatchDuration(x0: number, config: DefaultSpringConfig & SpringConfigInner, v0: number): number;
|
97 | export declare function criticallyDampedSpringCalculations(animation: InnerSpringAnimation, precalculatedValues: {
|
98 | v0: number;
|
99 | x0: number;
|
100 | omega0: number;
|
101 | t: number;
|
102 | }): {
|
103 | position: number;
|
104 | velocity: number;
|
105 | };
|
106 | export declare function underDampedSpringCalculations(animation: InnerSpringAnimation, precalculatedValues: {
|
107 | zeta: number;
|
108 | v0: number;
|
109 | x0: number;
|
110 | omega0: number;
|
111 | omega1: number;
|
112 | t: number;
|
113 | }): {
|
114 | position: number;
|
115 | velocity: number;
|
116 | };
|
117 | export declare function isAnimationTerminatingCalculation(animation: InnerSpringAnimation, config: DefaultSpringConfig): {
|
118 | isOvershooting: boolean;
|
119 | isVelocity: boolean;
|
120 | isDisplacement: boolean;
|
121 | };
|
122 |
|
\ | No newline at end of file |