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