1*af2ec015STomasz Sapeta/**
2*af2ec015STomasz Sapeta * Copyright (c) Meta Platforms, Inc. and affiliates.
3*af2ec015STomasz Sapeta *
4*af2ec015STomasz Sapeta * This source code is licensed under the MIT license found in the
5*af2ec015STomasz Sapeta * LICENSE file in the root directory of this source tree.
6*af2ec015STomasz Sapeta *
7*af2ec015STomasz Sapeta * @format
8*af2ec015STomasz Sapeta */
9*af2ec015STomasz Sapeta
10*af2ec015STomasz Sapetaexport type LayoutAnimationType =
11*af2ec015STomasz Sapeta  | 'spring'
12*af2ec015STomasz Sapeta  | 'linear'
13*af2ec015STomasz Sapeta  | 'easeInEaseOut'
14*af2ec015STomasz Sapeta  | 'easeIn'
15*af2ec015STomasz Sapeta  | 'easeOut'
16*af2ec015STomasz Sapeta  | 'keyboard';
17*af2ec015STomasz Sapeta
18*af2ec015STomasz Sapetaexport type LayoutAnimationTypes = {
19*af2ec015STomasz Sapeta  [type in LayoutAnimationType]: type;
20*af2ec015STomasz Sapeta};
21*af2ec015STomasz Sapeta
22*af2ec015STomasz Sapetaexport type LayoutAnimationProperty =
23*af2ec015STomasz Sapeta  | 'opacity'
24*af2ec015STomasz Sapeta  | 'scaleX'
25*af2ec015STomasz Sapeta  | 'scaleY'
26*af2ec015STomasz Sapeta  | 'scaleXY';
27*af2ec015STomasz Sapeta
28*af2ec015STomasz Sapetaexport type LayoutAnimationProperties = {
29*af2ec015STomasz Sapeta  [prop in LayoutAnimationProperty]: prop;
30*af2ec015STomasz Sapeta};
31*af2ec015STomasz Sapeta
32*af2ec015STomasz Sapetaexport interface LayoutAnimationAnim {
33*af2ec015STomasz Sapeta  duration?: number | undefined;
34*af2ec015STomasz Sapeta  delay?: number | undefined;
35*af2ec015STomasz Sapeta  springDamping?: number | undefined;
36*af2ec015STomasz Sapeta  initialVelocity?: number | undefined;
37*af2ec015STomasz Sapeta  type?: LayoutAnimationType | undefined;
38*af2ec015STomasz Sapeta  property?: LayoutAnimationProperty | undefined;
39*af2ec015STomasz Sapeta}
40*af2ec015STomasz Sapeta
41*af2ec015STomasz Sapetaexport interface LayoutAnimationConfig {
42*af2ec015STomasz Sapeta  duration: number;
43*af2ec015STomasz Sapeta  create?: LayoutAnimationAnim | undefined;
44*af2ec015STomasz Sapeta  update?: LayoutAnimationAnim | undefined;
45*af2ec015STomasz Sapeta  delete?: LayoutAnimationAnim | undefined;
46*af2ec015STomasz Sapeta}
47*af2ec015STomasz Sapeta
48*af2ec015STomasz Sapeta/** Automatically animates views to their new positions when the next layout happens.
49*af2ec015STomasz Sapeta * A common way to use this API is to call LayoutAnimation.configureNext before
50*af2ec015STomasz Sapeta * calling setState. */
51*af2ec015STomasz Sapetaexport interface LayoutAnimationStatic {
52*af2ec015STomasz Sapeta  /** Schedules an animation to happen on the next layout.
53*af2ec015STomasz Sapeta   * @param config Specifies animation properties:
54*af2ec015STomasz Sapeta   * `duration` in milliseconds
55*af2ec015STomasz Sapeta   * `create`, config for animating in new views (see Anim type)
56*af2ec015STomasz Sapeta   * `update`, config for animating views that have been updated (see Anim type)
57*af2ec015STomasz Sapeta   * @param onAnimationDidEnd Called when the animation finished. Only supported on iOS.
58*af2ec015STomasz Sapeta   */
59*af2ec015STomasz Sapeta  configureNext: (
60*af2ec015STomasz Sapeta    config: LayoutAnimationConfig,
61*af2ec015STomasz Sapeta    onAnimationDidEnd?: () => void,
62*af2ec015STomasz Sapeta    onAnimationDidFail?: () => void,
63*af2ec015STomasz Sapeta  ) => void;
64*af2ec015STomasz Sapeta  /** Helper for creating a config for configureNext. */
65*af2ec015STomasz Sapeta  create: (
66*af2ec015STomasz Sapeta    duration: number,
67*af2ec015STomasz Sapeta    type?: LayoutAnimationType,
68*af2ec015STomasz Sapeta    creationProp?: LayoutAnimationProperty,
69*af2ec015STomasz Sapeta  ) => LayoutAnimationConfig;
70*af2ec015STomasz Sapeta  Types: LayoutAnimationTypes;
71*af2ec015STomasz Sapeta  Properties: LayoutAnimationProperties;
72*af2ec015STomasz Sapeta  configChecker: (shapeTypes: {[key: string]: any}) => any;
73*af2ec015STomasz Sapeta  Presets: {
74*af2ec015STomasz Sapeta    easeInEaseOut: LayoutAnimationConfig;
75*af2ec015STomasz Sapeta    linear: LayoutAnimationConfig;
76*af2ec015STomasz Sapeta    spring: LayoutAnimationConfig;
77*af2ec015STomasz Sapeta  };
78*af2ec015STomasz Sapeta  easeInEaseOut: (onAnimationDidEnd?: () => void) => void;
79*af2ec015STomasz Sapeta  linear: (onAnimationDidEnd?: () => void) => void;
80*af2ec015STomasz Sapeta  spring: (onAnimationDidEnd?: () => void) => void;
81*af2ec015STomasz Sapeta}
82*af2ec015STomasz Sapeta
83*af2ec015STomasz Sapetaexport const LayoutAnimation: LayoutAnimationStatic;
84*af2ec015STomasz Sapetaexport type LayoutAnimation = LayoutAnimationStatic;
85