UNPKG

4.66 kBTypeScriptView Raw
1import type { ShareableRef, StyleProps, TransformArrayItem, EasingFunction } from '../../commonTypes';
2export type LayoutAnimationsOptions = 'originX' | 'originY' | 'width' | 'height' | 'borderRadius' | 'globalOriginX' | 'globalOriginY';
3type CurrentLayoutAnimationsValues = {
4 [K in LayoutAnimationsOptions as `current${Capitalize<string & K>}`]: number;
5};
6type TargetLayoutAnimationsValues = {
7 [K in LayoutAnimationsOptions as `target${Capitalize<string & K>}`]: number;
8};
9interface WindowDimensions {
10 windowWidth: number;
11 windowHeight: number;
12}
13export interface KeyframeProps extends StyleProps {
14 easing?: EasingFunction;
15}
16type FirstFrame = {
17 0: KeyframeProps & {
18 easing?: never;
19 };
20 from?: never;
21} | {
22 0?: never;
23 from: KeyframeProps & {
24 easing?: never;
25 };
26};
27type LastFrame = {
28 100?: KeyframeProps;
29 to?: never;
30} | {
31 100?: never;
32 to: KeyframeProps;
33};
34export type ValidKeyframeProps = FirstFrame & LastFrame & Record<number, KeyframeProps>;
35export type MaybeInvalidKeyframeProps = Record<number, KeyframeProps> & {
36 to?: KeyframeProps;
37 from?: KeyframeProps;
38};
39export type LayoutAnimation = {
40 initialValues: StyleProps;
41 animations: StyleProps;
42 callback?: (finished: boolean) => void;
43};
44export type AnimationFunction = (a?: any, b?: any, c?: any) => any;
45export type EntryAnimationsValues = TargetLayoutAnimationsValues & WindowDimensions;
46export type ExitAnimationsValues = CurrentLayoutAnimationsValues & WindowDimensions;
47export type EntryExitAnimationFunction = ((targetValues: EntryAnimationsValues) => LayoutAnimation) | ((targetValues: ExitAnimationsValues) => LayoutAnimation) | (() => LayoutAnimation);
48export type AnimationConfigFunction<T> = (targetValues: T) => LayoutAnimation;
49export type LayoutAnimationsValues = CurrentLayoutAnimationsValues & TargetLayoutAnimationsValues & WindowDimensions;
50export interface SharedTransitionAnimationsValues extends LayoutAnimationsValues {
51 currentTransformMatrix: number[];
52 targetTransformMatrix: number[];
53}
54export type SharedTransitionAnimationsFunction = (values: SharedTransitionAnimationsValues) => LayoutAnimation;
55export declare enum LayoutAnimationType {
56 ENTERING = 1,
57 EXITING = 2,
58 LAYOUT = 3,
59 SHARED_ELEMENT_TRANSITION = 4,
60 SHARED_ELEMENT_TRANSITION_PROGRESS = 5
61}
62export type LayoutAnimationFunction = (targetValues: LayoutAnimationsValues) => LayoutAnimation;
63export type LayoutAnimationStartFunction = (tag: number, type: LayoutAnimationType, yogaValues: Partial<SharedTransitionAnimationsValues>, config: (arg: Partial<SharedTransitionAnimationsValues>) => LayoutAnimation) => void;
64export interface ILayoutAnimationBuilder {
65 build: () => LayoutAnimationFunction;
66}
67export interface BaseLayoutAnimationConfig {
68 duration?: number;
69 easing?: EasingFunction;
70 type?: AnimationFunction;
71 damping?: number;
72 dampingRatio?: number;
73 mass?: number;
74 stiffness?: number;
75 overshootClamping?: number;
76 restDisplacementThreshold?: number;
77 restSpeedThreshold?: number;
78}
79export interface BaseBuilderAnimationConfig extends BaseLayoutAnimationConfig {
80 rotate?: number | string;
81}
82export type LayoutAnimationAndConfig = [
83 AnimationFunction,
84 BaseBuilderAnimationConfig
85];
86export interface IEntryExitAnimationBuilder {
87 build: () => EntryExitAnimationFunction;
88}
89export interface IEntryAnimationBuilder {
90 build: () => AnimationConfigFunction<EntryAnimationsValues>;
91}
92export interface IExitAnimationBuilder {
93 build: () => AnimationConfigFunction<ExitAnimationsValues>;
94}
95export type ProgressAnimationCallback = (viewTag: number, progress: number) => void;
96export type ProgressAnimation = (viewTag: number, values: SharedTransitionAnimationsValues, progress: number) => void;
97export type CustomProgressAnimation = (values: SharedTransitionAnimationsValues, progress: number) => StyleProps;
98/**
99 * Used to configure the `.defaultTransitionType()` shared transition modifier.
100 *
101 * @experimental
102 */
103export declare enum SharedTransitionType {
104 ANIMATION = "animation",
105 PROGRESS_ANIMATION = "progressAnimation"
106}
107export type EntryExitAnimationsValues = EntryAnimationsValues | ExitAnimationsValues;
108export type StylePropsWithArrayTransform = StyleProps & {
109 transform?: TransformArrayItem[];
110};
111export interface LayoutAnimationBatchItem {
112 viewTag: number;
113 type: LayoutAnimationType;
114 config: ShareableRef<Keyframe | LayoutAnimationFunction | SharedTransitionAnimationsFunction | ProgressAnimationCallback> | undefined;
115 sharedTransitionTag?: string;
116}
117export {};
118//# sourceMappingURL=commonTypes.d.ts.map
\No newline at end of file