react-native-reanimated 3.6.0 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. package/lib/module/createAnimatedComponent/createAnimatedComponent.js +12 -0
  2. package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
  3. package/lib/module/createAnimatedComponent/setAndForwardRef.js +2 -0
  4. package/lib/module/createAnimatedComponent/setAndForwardRef.js.map +1 -1
  5. package/lib/module/reanimated2/Easing.js +3 -3
  6. package/lib/module/reanimated2/Easing.js.map +1 -1
  7. package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
  8. package/lib/module/reanimated2/animation/decay/decay.js +9 -0
  9. package/lib/module/reanimated2/animation/decay/decay.js.map +1 -1
  10. package/lib/module/reanimated2/animation/decay/utils.js +13 -0
  11. package/lib/module/reanimated2/animation/decay/utils.js.map +1 -1
  12. package/lib/module/reanimated2/animation/delay.js +9 -0
  13. package/lib/module/reanimated2/animation/delay.js.map +1 -1
  14. package/lib/module/reanimated2/animation/repeat.js +11 -0
  15. package/lib/module/reanimated2/animation/repeat.js.map +1 -1
  16. package/lib/module/reanimated2/animation/sequence.js +10 -0
  17. package/lib/module/reanimated2/animation/sequence.js.map +1 -1
  18. package/lib/module/reanimated2/animation/spring.js +9 -0
  19. package/lib/module/reanimated2/animation/spring.js.map +1 -1
  20. package/lib/module/reanimated2/animation/springUtils.js +16 -0
  21. package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
  22. package/lib/module/reanimated2/animation/timing.js +18 -0
  23. package/lib/module/reanimated2/animation/timing.js.map +1 -1
  24. package/lib/module/reanimated2/animation/util.js +7 -0
  25. package/lib/module/reanimated2/animation/util.js.map +1 -1
  26. package/lib/module/reanimated2/commonTypes.js +30 -7
  27. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  28. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  29. package/lib/module/reanimated2/component/LayoutAnimationConfig.js +7 -0
  30. package/lib/module/reanimated2/component/LayoutAnimationConfig.js.map +1 -1
  31. package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
  32. package/lib/module/reanimated2/globals.d.js.map +1 -1
  33. package/lib/module/reanimated2/helperTypes.js.map +1 -1
  34. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +8 -0
  35. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  36. package/lib/module/reanimated2/hook/useAnimatedProps.js +9 -0
  37. package/lib/module/reanimated2/hook/useAnimatedProps.js.map +1 -1
  38. package/lib/module/reanimated2/hook/useAnimatedReaction.js +6 -4
  39. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  40. package/lib/module/reanimated2/hook/useAnimatedRef.js +7 -0
  41. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  42. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +10 -2
  43. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
  44. package/lib/module/reanimated2/hook/useAnimatedSensor.js +10 -0
  45. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  46. package/lib/module/reanimated2/hook/useAnimatedStyle.js +8 -0
  47. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  48. package/lib/module/reanimated2/hook/useDerivedValue.js +14 -8
  49. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  50. package/lib/module/reanimated2/hook/useEvent.js +7 -6
  51. package/lib/module/reanimated2/hook/useEvent.js.map +1 -1
  52. package/lib/module/reanimated2/hook/useFrameCallback.js +17 -0
  53. package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
  54. package/lib/module/reanimated2/hook/useHandler.js +8 -2
  55. package/lib/module/reanimated2/hook/useHandler.js.map +1 -1
  56. package/lib/module/reanimated2/hook/useReducedMotion.js +9 -0
  57. package/lib/module/reanimated2/hook/useReducedMotion.js.map +1 -1
  58. package/lib/module/reanimated2/hook/useScrollViewOffset.js +8 -0
  59. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  60. package/lib/module/reanimated2/hook/useSharedValue.js +11 -3
  61. package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
  62. package/lib/module/reanimated2/hook/useWorkletCallback.js +3 -0
  63. package/lib/module/reanimated2/hook/useWorkletCallback.js.map +1 -1
  64. package/lib/module/reanimated2/index.js +1 -1
  65. package/lib/module/reanimated2/index.js.map +1 -1
  66. package/lib/module/reanimated2/interpolateColor.js +21 -0
  67. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  68. package/lib/module/reanimated2/interpolation.js +51 -21
  69. package/lib/module/reanimated2/interpolation.js.map +1 -1
  70. package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +29 -2
  71. package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
  72. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +67 -2
  73. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
  74. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +6 -3
  75. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
  76. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +4 -0
  77. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  78. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +80 -0
  79. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  80. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +79 -0
  81. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
  82. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +96 -0
  83. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
  84. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +31 -0
  85. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  86. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +15 -0
  87. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
  88. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +31 -0
  89. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  90. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +63 -0
  91. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
  92. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +64 -0
  93. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  94. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +32 -0
  95. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
  96. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +128 -0
  97. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  98. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +8 -0
  99. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  100. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +9 -0
  101. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
  102. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +8 -0
  103. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
  104. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +8 -0
  105. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
  106. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +10 -3
  107. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
  108. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -0
  109. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
  110. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js +49 -3
  111. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js.map +1 -1
  112. package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js +4 -4
  113. package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js.map +1 -1
  114. package/lib/module/reanimated2/platform-specific/checkCppVersion.js +0 -2
  115. package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -1
  116. package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
  117. package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
  118. package/lib/module/reanimated2/platformFunctions/dispatchCommand.js +9 -0
  119. package/lib/module/reanimated2/platformFunctions/dispatchCommand.js.map +1 -1
  120. package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js +14 -4
  121. package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js.map +1 -1
  122. package/lib/module/reanimated2/platformFunctions/measure.js +7 -0
  123. package/lib/module/reanimated2/platformFunctions/measure.js.map +1 -1
  124. package/lib/module/reanimated2/platformFunctions/scrollTo.js +9 -0
  125. package/lib/module/reanimated2/platformFunctions/scrollTo.js.map +1 -1
  126. package/lib/module/reanimated2/platformFunctions/setNativeProps.js +8 -0
  127. package/lib/module/reanimated2/platformFunctions/setNativeProps.js.map +1 -1
  128. package/lib/module/reanimated2/runtimes.js +8 -0
  129. package/lib/module/reanimated2/runtimes.js.map +1 -1
  130. package/lib/module/reanimated2/threads.js +16 -6
  131. package/lib/module/reanimated2/threads.js.map +1 -1
  132. package/lib/typescript/createAnimatedComponent/createAnimatedComponent.d.ts +12 -0
  133. package/lib/typescript/reanimated2/Easing.d.ts +3 -3
  134. package/lib/typescript/reanimated2/animation/decay/decay.d.ts +8 -0
  135. package/lib/typescript/reanimated2/animation/decay/utils.d.ts +12 -0
  136. package/lib/typescript/reanimated2/animation/delay.d.ts +9 -0
  137. package/lib/typescript/reanimated2/animation/repeat.d.ts +11 -0
  138. package/lib/typescript/reanimated2/animation/sequence.d.ts +8 -0
  139. package/lib/typescript/reanimated2/animation/spring.d.ts +9 -0
  140. package/lib/typescript/reanimated2/animation/springUtils.d.ts +15 -0
  141. package/lib/typescript/reanimated2/animation/timing.d.ts +17 -0
  142. package/lib/typescript/reanimated2/animation/util.d.ts +6 -0
  143. package/lib/typescript/reanimated2/commonTypes.d.ts +25 -7
  144. package/lib/typescript/reanimated2/component/FlatList.d.ts +6 -0
  145. package/lib/typescript/reanimated2/component/LayoutAnimationConfig.d.ts +7 -0
  146. package/lib/typescript/reanimated2/component/ScrollView.d.ts +3 -2
  147. package/lib/typescript/reanimated2/helperTypes.d.ts +45 -3
  148. package/lib/typescript/reanimated2/hook/useAnimatedKeyboard.d.ts +7 -0
  149. package/lib/typescript/reanimated2/hook/useAnimatedProps.d.ts +9 -0
  150. package/lib/typescript/reanimated2/hook/useAnimatedReaction.d.ts +6 -4
  151. package/lib/typescript/reanimated2/hook/useAnimatedRef.d.ts +6 -0
  152. package/lib/typescript/reanimated2/hook/useAnimatedScrollHandler.d.ts +10 -0
  153. package/lib/typescript/reanimated2/hook/useAnimatedSensor.d.ts +8 -0
  154. package/lib/typescript/reanimated2/hook/useAnimatedStyle.d.ts +8 -0
  155. package/lib/typescript/reanimated2/hook/useDerivedValue.d.ts +9 -1
  156. package/lib/typescript/reanimated2/hook/useEvent.d.ts +8 -5
  157. package/lib/typescript/reanimated2/hook/useFrameCallback.d.ts +14 -0
  158. package/lib/typescript/reanimated2/hook/useHandler.d.ts +8 -0
  159. package/lib/typescript/reanimated2/hook/useReducedMotion.d.ts +8 -0
  160. package/lib/typescript/reanimated2/hook/useScrollViewOffset.d.ts +7 -0
  161. package/lib/typescript/reanimated2/hook/useSharedValue.d.ts +8 -1
  162. package/lib/typescript/reanimated2/hook/useWorkletCallback.d.ts +3 -0
  163. package/lib/typescript/reanimated2/index.d.ts +1 -1
  164. package/lib/typescript/reanimated2/interpolateColor.d.ts +17 -0
  165. package/lib/typescript/reanimated2/interpolation.d.ts +30 -2
  166. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +25 -2
  167. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +56 -1
  168. package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +4 -0
  169. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Bounce.d.ts +70 -0
  170. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Fade.d.ts +70 -0
  171. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Flip.d.ts +84 -0
  172. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.d.ts +28 -0
  173. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.d.ts +14 -0
  174. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Roll.d.ts +28 -0
  175. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Rotate.d.ts +56 -0
  176. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Slide.d.ts +56 -0
  177. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Stretch.d.ts +28 -0
  178. package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Zoom.d.ts +112 -0
  179. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +7 -0
  180. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +8 -0
  181. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.d.ts +7 -0
  182. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +7 -0
  183. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.d.ts +10 -0
  184. package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +7 -0
  185. package/lib/typescript/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.d.ts +43 -1
  186. package/lib/typescript/reanimated2/layoutReanimation/web/createAnimation.d.ts +4 -4
  187. package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
  188. package/lib/typescript/reanimated2/platformFunctions/dispatchCommand.d.ts +8 -0
  189. package/lib/typescript/reanimated2/platformFunctions/getRelativeCoords.d.ts +11 -3
  190. package/lib/typescript/reanimated2/platformFunctions/measure.d.ts +7 -0
  191. package/lib/typescript/reanimated2/platformFunctions/scrollTo.d.ts +9 -0
  192. package/lib/typescript/reanimated2/platformFunctions/setNativeProps.d.ts +7 -0
  193. package/lib/typescript/reanimated2/runtimes.d.ts +8 -0
  194. package/lib/typescript/reanimated2/threads.d.ts +17 -2
  195. package/package.json +2 -1
  196. package/src/createAnimatedComponent/createAnimatedComponent.tsx +18 -0
  197. package/src/createAnimatedComponent/setAndForwardRef.ts +2 -0
  198. package/src/reanimated2/Easing.ts +3 -3
  199. package/src/reanimated2/PlatformChecker.ts +1 -1
  200. package/src/reanimated2/animation/decay/decay.ts +8 -0
  201. package/src/reanimated2/animation/decay/utils.ts +12 -0
  202. package/src/reanimated2/animation/delay.ts +9 -0
  203. package/src/reanimated2/animation/repeat.ts +11 -0
  204. package/src/reanimated2/animation/sequence.ts +8 -0
  205. package/src/reanimated2/animation/spring.ts +9 -0
  206. package/src/reanimated2/animation/springUtils.ts +15 -0
  207. package/src/reanimated2/animation/timing.ts +17 -0
  208. package/src/reanimated2/animation/util.ts +6 -0
  209. package/src/reanimated2/commonTypes.ts +25 -7
  210. package/src/reanimated2/component/FlatList.tsx +6 -0
  211. package/src/reanimated2/component/LayoutAnimationConfig.tsx +7 -0
  212. package/src/reanimated2/component/ScrollView.tsx +3 -1
  213. package/src/reanimated2/globals.d.ts +1 -1
  214. package/src/reanimated2/helperTypes.ts +45 -3
  215. package/src/reanimated2/hook/useAnimatedKeyboard.ts +7 -0
  216. package/src/reanimated2/hook/useAnimatedProps.ts +9 -0
  217. package/src/reanimated2/hook/useAnimatedReaction.ts +6 -4
  218. package/src/reanimated2/hook/useAnimatedRef.ts +6 -0
  219. package/src/reanimated2/hook/useAnimatedScrollHandler.ts +10 -0
  220. package/src/reanimated2/hook/useAnimatedSensor.ts +8 -0
  221. package/src/reanimated2/hook/useAnimatedStyle.ts +8 -0
  222. package/src/reanimated2/hook/useDerivedValue.ts +15 -7
  223. package/src/reanimated2/hook/useEvent.ts +9 -6
  224. package/src/reanimated2/hook/useFrameCallback.ts +14 -0
  225. package/src/reanimated2/hook/useHandler.ts +8 -0
  226. package/src/reanimated2/hook/useReducedMotion.ts +8 -0
  227. package/src/reanimated2/hook/useScrollViewOffset.ts +7 -0
  228. package/src/reanimated2/hook/useSharedValue.ts +12 -3
  229. package/src/reanimated2/hook/useWorkletCallback.ts +3 -0
  230. package/src/reanimated2/index.ts +1 -1
  231. package/src/reanimated2/interpolateColor.ts +17 -0
  232. package/src/reanimated2/interpolation.ts +48 -22
  233. package/src/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts +26 -3
  234. package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +57 -2
  235. package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +7 -6
  236. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +4 -0
  237. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +71 -0
  238. package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +70 -1
  239. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +84 -0
  240. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +28 -0
  241. package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +14 -0
  242. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +28 -0
  243. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +56 -0
  244. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +56 -0
  245. package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +28 -0
  246. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +112 -0
  247. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +7 -0
  248. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +8 -0
  249. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +7 -0
  250. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +8 -0
  251. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +10 -3
  252. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +7 -0
  253. package/src/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.ts +45 -3
  254. package/src/reanimated2/layoutReanimation/web/createAnimation.ts +4 -4
  255. package/src/reanimated2/platform-specific/checkCppVersion.ts +0 -4
  256. package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
  257. package/src/reanimated2/platformFunctions/dispatchCommand.ts +8 -0
  258. package/src/reanimated2/platformFunctions/getRelativeCoords.ts +12 -4
  259. package/src/reanimated2/platformFunctions/measure.ts +7 -0
  260. package/src/reanimated2/platformFunctions/scrollTo.ts +9 -0
  261. package/src/reanimated2/platformFunctions/setNativeProps.ts +7 -0
  262. package/src/reanimated2/runtimes.ts +8 -0
  263. package/src/reanimated2/threads.ts +18 -7
@@ -8,18 +8,26 @@ import { shouldBeUseWeb } from '../PlatformChecker';
8
8
 
9
9
  export type DerivedValue<Value> = Readonly<SharedValue<Value>>;
10
10
 
11
+ /**
12
+ * Lets you create new shared values based on existing ones while keeping them reactive.
13
+ *
14
+ * @param updater - A function called whenever at least one of the shared values or state used in the function body changes.
15
+ * @param dependencies - An optional array of dependencies. Only relevant when using Reanimated without the Babel plugin on the Web.
16
+ * @returns A new readonly shared value based on a value returned from the updater function
17
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/core/useDerivedValue
18
+ */
11
19
  // @ts-expect-error This overload is required by our API.
12
20
  export function useDerivedValue<Value>(
13
- processor: () => Value,
21
+ updater: () => Value,
14
22
  dependencies?: DependencyList
15
23
  ): DerivedValue<Value>;
16
24
 
17
25
  export function useDerivedValue<Value>(
18
- processor: WorkletFunction<[], Value>,
26
+ updater: WorkletFunction<[], Value>,
19
27
  dependencies?: DependencyList
20
28
  ): DerivedValue<Value> {
21
29
  const initRef = useRef<SharedValue<Value> | null>(null);
22
- let inputs = Object.values(processor.__closure ?? {});
30
+ let inputs = Object.values(updater.__closure ?? {});
23
31
  if (shouldBeUseWeb()) {
24
32
  if (!inputs.length && dependencies?.length) {
25
33
  // let web work without a Babel/SWC plugin
@@ -29,13 +37,13 @@ export function useDerivedValue<Value>(
29
37
 
30
38
  // build dependencies
31
39
  if (dependencies === undefined) {
32
- dependencies = [...inputs, processor.__workletHash];
40
+ dependencies = [...inputs, updater.__workletHash];
33
41
  } else {
34
- dependencies.push(processor.__workletHash);
42
+ dependencies.push(updater.__workletHash);
35
43
  }
36
44
 
37
45
  if (initRef.current === null) {
38
- initRef.current = makeMutable(initialUpdaterRun(processor));
46
+ initRef.current = makeMutable(initialUpdaterRun(updater));
39
47
  }
40
48
 
41
49
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -44,7 +52,7 @@ export function useDerivedValue<Value>(
44
52
  useEffect(() => {
45
53
  const fun = () => {
46
54
  'worklet';
47
- sharedValue.value = processor();
55
+ sharedValue.value = updater();
48
56
  };
49
57
  const mapperId = startMapper(fun, inputs, [sharedValue]);
50
58
  return () => {
@@ -12,21 +12,24 @@ export type EventHandler<
12
12
  Context extends Record<string, unknown> = never
13
13
  > = (event: ReanimatedEvent<Event>, context?: Context) => void;
14
14
 
15
- /**
16
- * Return type of `useEvent` hook.
17
- */
18
15
  export type EventHandlerProcessed<
19
16
  Event extends object,
20
17
  Context extends Record<string, unknown> = never
21
18
  > = (event: Event, context?: Context) => void;
22
19
 
23
- /**
24
- * Real return type of `useEvent` hook - only meant to be used internally.
25
- */
26
20
  export type EventHandlerInternal<Event extends object> = MutableRefObject<
27
21
  WorkletEventHandler<Event>
28
22
  >;
29
23
 
24
+ /**
25
+ * Lets you run a function whenever a specified native event occurs.
26
+ *
27
+ * @param handler - A function that receives an event object with event data - {@link EventHandler}.
28
+ * @param eventNames - An array of event names the `handler` callback will react to.
29
+ * @param rebuild - Whether the event handler should be rebuilt. Defaults to `false`.
30
+ * @returns A function that will be called when the event occurs - {@link EventHandlerProcessed}.
31
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useEvent
32
+ */
30
33
  // @ts-expect-error This overload is required by our API.
31
34
  // We don't know which properites of a component that is made into
32
35
  // an AnimatedComponent are event handlers and we don't want to force the user to define it.
@@ -3,6 +3,12 @@ import { useEffect, useRef } from 'react';
3
3
  import FrameCallbackRegistryJS from '../frameCallback/FrameCallbackRegistryJS';
4
4
  import type { FrameInfo } from '../frameCallback/FrameCallbackRegistryUI';
5
5
 
6
+ /**
7
+ * @param setActive - A function that lets you start the frame callback or stop it from running.
8
+ * @param isActive - A boolean indicating whether a callback is running.
9
+ * @param callbackId - A number indicating a unique identifier of the frame callback.
10
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useFrameCallback#returns
11
+ */
6
12
  export type FrameCallback = {
7
13
  setActive: (isActive: boolean) => void;
8
14
  isActive: boolean;
@@ -10,6 +16,14 @@ export type FrameCallback = {
10
16
  };
11
17
  const frameCallbackRegistry = new FrameCallbackRegistryJS();
12
18
 
19
+ /**
20
+ * Lets you run a function on every frame update.
21
+ *
22
+ * @param callback - A function executed on every frame update.
23
+ * @param autostart - Whether the callback should start automatically. Defaults to `true`.
24
+ * @returns A frame callback object - {@link FrameCallback}.
25
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useFrameCallback
26
+ */
13
27
  export function useFrameCallback(
14
28
  callback: (frameInfo: FrameInfo) => void,
15
29
  autostart = true
@@ -39,6 +39,14 @@ export interface UseHandlerContext<Context extends Record<string, unknown>> {
39
39
  useWeb: boolean;
40
40
  }
41
41
 
42
+ /**
43
+ * Lets you find out whether the event handler dependencies have changed.
44
+ *
45
+ * @param handlers - An object of event handlers.
46
+ * @param dependencies - An optional array of dependencies.
47
+ * @returns An object containing a boolean indicating whether the dependencies have changed, and a boolean indicating whether the code is running on the web.
48
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useHandler
49
+ */
42
50
  // @ts-expect-error This overload is required by our API.
43
51
  export function useHandler<
44
52
  Event extends object,
@@ -3,6 +3,14 @@ import { isReducedMotion } from '../PlatformChecker';
3
3
 
4
4
  const IS_REDUCED_MOTION = isReducedMotion();
5
5
 
6
+ /**
7
+ * Lets you query the reduced motion system setting.
8
+ *
9
+ * Changing the reduced motion system setting doesn't cause your components to rerender.
10
+ *
11
+ * @returns A boolean indicating whether the reduced motion setting was enabled when the app started.
12
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/device/useReducedMotion
13
+ */
6
14
  export function useReducedMotion() {
7
15
  return IS_REDUCED_MOTION;
8
16
  }
@@ -20,6 +20,13 @@ const scrollEventNames = [
20
20
  'onMomentumScrollEnd',
21
21
  ];
22
22
 
23
+ /**
24
+ * Lets you synchronously get the current offset of a `ScrollView`.
25
+ *
26
+ * @param animatedRef - An [animated ref](https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedRef) attached to an Animated.ScrollView component.
27
+ * @returns A shared value which holds the current offset of the `ScrollView`.
28
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/scroll/useScrollViewOffset
29
+ */
23
30
  export function useScrollViewOffset(
24
31
  animatedRef: AnimatedRef<AnimatedScrollView>,
25
32
  initialRef?: SharedValue<number>
@@ -4,14 +4,23 @@ import { cancelAnimation } from '../animation';
4
4
  import type { SharedValue } from '../commonTypes';
5
5
  import { makeMutable } from '../core';
6
6
 
7
+ /**
8
+ * Lets you define [shared values](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#shared-value) in your components.
9
+ *
10
+ * @param initialValue - The value you want to be initially stored to a `.value` property.
11
+ * @returns A shared value with a single `.value` property initially set to the `initialValue` - {@link SharedValue}.
12
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue
13
+ */
7
14
  export function useSharedValue<Value>(
8
- init: Value,
15
+ initialValue: Value,
9
16
  oneWayReadsOnly = false
10
17
  ): SharedValue<Value> {
11
- const ref = useRef<SharedValue<Value>>(makeMutable(init, oneWayReadsOnly));
18
+ const ref = useRef<SharedValue<Value>>(
19
+ makeMutable(initialValue, oneWayReadsOnly)
20
+ );
12
21
 
13
22
  if (ref.current === null) {
14
- ref.current = makeMutable(init, oneWayReadsOnly);
23
+ ref.current = makeMutable(initialValue, oneWayReadsOnly);
15
24
  }
16
25
 
17
26
  useEffect(() => {
@@ -2,6 +2,9 @@
2
2
  import { useCallback } from 'react';
3
3
  import type { DependencyList } from './commonTypes';
4
4
 
5
+ /**
6
+ * @deprecated don't use
7
+ */
5
8
  export function useWorkletCallback<Args extends unknown[], ReturnValue>(
6
9
  worklet: (...args: Args) => ReturnValue,
7
10
  deps?: DependencyList
@@ -80,7 +80,7 @@ export type {
80
80
  } from './interpolateColor';
81
81
  export {
82
82
  /**
83
- * @deprecated Please use `Extrapolation` instead.
83
+ * @deprecated Please use {@link Extrapolation} instead.
84
84
  */
85
85
  Extrapolate,
86
86
  ColorSpace,
@@ -19,6 +19,12 @@ import { useSharedValue } from './hook/useSharedValue';
19
19
  */
20
20
  export const Extrapolate = Extrapolation;
21
21
 
22
+ /**
23
+ * Options for color interpolation.
24
+ *
25
+ * @param gamma - Gamma value used in gamma correction. Defaults to `2.2`.
26
+ * @param useCorrectedHSVInterpolation - Whether to reduce the number of colors the interpolation has to go through. Defaults to `true`.
27
+ */
22
28
  export type InterpolationOptions = {
23
29
  gamma?: number;
24
30
  useCorrectedHSVInterpolation?: boolean;
@@ -180,6 +186,17 @@ const getInterpolateHSV = (
180
186
  return { h, s, v, a };
181
187
  };
182
188
 
189
+ /**
190
+ * Lets you map a value from a range of numbers to a range of colors using linear interpolation.
191
+ *
192
+ * @param value - A number from the `input` range that is going to be mapped to the color in the `output` range.
193
+ * @param inputRange - An array of numbers specifying the input range of the interpolation.
194
+ * @param outputRange - An array of output colors values (eg. "red", "#00FFCC", "rgba(255, 0, 0, 0.5)").
195
+ * @param colorSpace - The color space to use for interpolation. Defaults to 'RGB'.
196
+ * @param options - Additional options for interpolation - {@link InterpolationOptions}.
197
+ * @returns The color after interpolation from within the output range in rgba(r, g, b, a) format.
198
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolateColor
199
+ */
183
200
  export function interpolateColor(
184
201
  value: number,
185
202
  inputRange: readonly number[],
@@ -1,11 +1,21 @@
1
1
  'use strict';
2
2
 
3
+ /**
4
+ * Extrapolation type.
5
+ *
6
+ * @param IDENTITY - Returns the provided value as is.
7
+ * @param CLAMP - Clamps the value to the edge of the output range.
8
+ * @param EXTEND - Predicts the values beyond the output range.
9
+ */
3
10
  export enum Extrapolation {
4
11
  IDENTITY = 'identity',
5
12
  CLAMP = 'clamp',
6
13
  EXTEND = 'extend',
7
14
  }
8
15
 
16
+ /**
17
+ * Represents the possible values for extrapolation as a string.
18
+ */
9
19
  type ExtrapolationAsString = 'identity' | 'clamp' | 'extend';
10
20
 
11
21
  interface InterpolationNarrowedInput {
@@ -15,6 +25,9 @@ interface InterpolationNarrowedInput {
15
25
  rightEdgeOutput: number;
16
26
  }
17
27
 
28
+ /**
29
+ * Allows to specify extrapolation for left and right edge of the interpolation.
30
+ */
18
31
  export interface ExtrapolationConfig {
19
32
  extrapolateLeft?: Extrapolation | string;
20
33
  extrapolateRight?: Extrapolation | string;
@@ -25,6 +38,9 @@ interface RequiredExtrapolationConfig {
25
38
  extrapolateRight: Extrapolation;
26
39
  }
27
40
 
41
+ /**
42
+ * Configuration options for extrapolation.
43
+ */
28
44
  export type ExtrapolationType =
29
45
  | ExtrapolationConfig
30
46
  | Extrapolation
@@ -145,42 +161,50 @@ function internalInterpolate(
145
161
  return val;
146
162
  }
147
163
 
148
- // TODO: support default values in worklets:
149
- // e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)
164
+ /**
165
+ * Lets you map a value from one range to another using linear interpolation.
166
+ *
167
+ * @param value - A number from the `input` range that is going to be mapped to the `output` range.
168
+ * @param inputRange - An array of numbers specifying the input range of the interpolation.
169
+ * @param outputRange - An array of numbers specifying the output range of the interpolation.
170
+ * @param extrapolate - determines what happens when the `value` goes beyond the `input` range. Defaults to `Extrapolation.EXTEND` - {@link ExtrapolationType}.
171
+ * @returns A mapped value within the output range.
172
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolate
173
+ */
150
174
  export function interpolate(
151
175
  x: number,
152
- input: readonly number[],
153
- output: readonly number[],
176
+ inputRange: readonly number[],
177
+ outputRange: readonly number[],
154
178
  type?: ExtrapolationType
155
179
  ): number {
156
180
  'worklet';
157
- if (input.length < 2 || output.length < 2) {
181
+ if (inputRange.length < 2 || outputRange.length < 2) {
158
182
  throw new Error(
159
- '[Reanimated] Interpolation input and output should contain at least two values.'
183
+ '[Reanimated] Interpolation input and output ranges should contain at least two values.'
160
184
  );
161
185
  }
162
186
 
163
187
  const extrapolationConfig = validateType(type);
164
- const length = input.length;
188
+ const length = inputRange.length;
165
189
  const narrowedInput: InterpolationNarrowedInput = {
166
- leftEdgeInput: input[0],
167
- rightEdgeInput: input[1],
168
- leftEdgeOutput: output[0],
169
- rightEdgeOutput: output[1],
190
+ leftEdgeInput: inputRange[0],
191
+ rightEdgeInput: inputRange[1],
192
+ leftEdgeOutput: outputRange[0],
193
+ rightEdgeOutput: outputRange[1],
170
194
  };
171
195
  if (length > 2) {
172
- if (x > input[length - 1]) {
173
- narrowedInput.leftEdgeInput = input[length - 2];
174
- narrowedInput.rightEdgeInput = input[length - 1];
175
- narrowedInput.leftEdgeOutput = output[length - 2];
176
- narrowedInput.rightEdgeOutput = output[length - 1];
196
+ if (x > inputRange[length - 1]) {
197
+ narrowedInput.leftEdgeInput = inputRange[length - 2];
198
+ narrowedInput.rightEdgeInput = inputRange[length - 1];
199
+ narrowedInput.leftEdgeOutput = outputRange[length - 2];
200
+ narrowedInput.rightEdgeOutput = outputRange[length - 1];
177
201
  } else {
178
202
  for (let i = 1; i < length; ++i) {
179
- if (x <= input[i]) {
180
- narrowedInput.leftEdgeInput = input[i - 1];
181
- narrowedInput.rightEdgeInput = input[i];
182
- narrowedInput.leftEdgeOutput = output[i - 1];
183
- narrowedInput.rightEdgeOutput = output[i];
203
+ if (x <= inputRange[i]) {
204
+ narrowedInput.leftEdgeInput = inputRange[i - 1];
205
+ narrowedInput.rightEdgeInput = inputRange[i];
206
+ narrowedInput.leftEdgeOutput = outputRange[i - 1];
207
+ narrowedInput.rightEdgeOutput = outputRange[i];
184
208
  break;
185
209
  }
186
210
  }
@@ -191,11 +215,13 @@ export function interpolate(
191
215
  }
192
216
 
193
217
  /**
194
- * `clamp` lets you limit a value within a specified range.
218
+ * Lets you limit a value within a specified range.
195
219
  *
196
220
  * @param value - A number that will be returned as long as the provided value is in range between `min` and `max`.
197
221
  * @param min - A number which will be returned when provided `value` is lower than `min`.
198
222
  * @param max - A number which will be returned when provided `value` is higher than `max`.
223
+ * @returns A number between min and max bounds.
224
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/clamp/
199
225
  */
200
226
  export function clamp(value: number, min: number, max: number) {
201
227
  'worklet';
@@ -24,6 +24,11 @@ export class BaseAnimationBuilder {
24
24
  throw new Error('[Reanimated] Unimplemented method in child class.');
25
25
  };
26
26
 
27
+ /**
28
+ * Lets you adjust the animation duration. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
29
+ *
30
+ * @param durationMs - Length of the animation (in milliseconds).
31
+ */
27
32
  static duration<T extends typeof BaseAnimationBuilder>(
28
33
  this: T,
29
34
  durationMs: number
@@ -37,6 +42,11 @@ export class BaseAnimationBuilder {
37
42
  return this;
38
43
  }
39
44
 
45
+ /**
46
+ * Lets you adjust the delay before the animation starts (in milliseconds). Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
47
+ *
48
+ * @param delayMs - Delay before the animation starts (in milliseconds).
49
+ */
40
50
  static delay<T extends typeof BaseAnimationBuilder>(
41
51
  this: T,
42
52
  delayMs: number
@@ -50,6 +60,11 @@ export class BaseAnimationBuilder {
50
60
  return this;
51
61
  }
52
62
 
63
+ /**
64
+ * The callback that will fire after the animation ends. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
65
+ *
66
+ * @param callback - Callback that will fire after the animation ends.
67
+ */
53
68
  static withCallback<T extends typeof BaseAnimationBuilder>(
54
69
  this: T,
55
70
  callback: (finished: boolean) => void
@@ -58,17 +73,22 @@ export class BaseAnimationBuilder {
58
73
  return instance.withCallback(callback);
59
74
  }
60
75
 
61
- withCallback(callback: (finsihed: boolean) => void): this {
76
+ withCallback(callback: (finished: boolean) => void): this {
62
77
  this.callbackV = callback;
63
78
  return this;
64
79
  }
65
80
 
81
+ /**
82
+ * Lets you adjust the behavior when the device's reduced motion accessibility setting is turned on. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
83
+ *
84
+ * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.
85
+ */
66
86
  static reduceMotion<T extends typeof BaseAnimationBuilder>(
67
87
  this: T,
68
- reduceMotionV: ReduceMotion
88
+ reduceMotion: ReduceMotion
69
89
  ): InstanceType<T> {
70
90
  const instance = this.createInstance();
71
- return instance.reduceMotion(reduceMotionV);
91
+ return instance.reduceMotion(reduceMotion);
72
92
  }
73
93
 
74
94
  reduceMotion(reduceMotionV: ReduceMotion): this {
@@ -85,6 +105,9 @@ export class BaseAnimationBuilder {
85
105
  return this.durationV ?? 300;
86
106
  }
87
107
 
108
+ /**
109
+ * @deprecated Use `.delay()` with `Math.random()` instead
110
+ */
88
111
  static randomDelay<T extends typeof BaseAnimationBuilder>(
89
112
  this: T
90
113
  ): InstanceType<T> {
@@ -26,6 +26,11 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
26
26
  this: T
27
27
  ) => InstanceType<T>;
28
28
 
29
+ /**
30
+ * Lets you change the easing curve of the animation. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
31
+ *
32
+ * @param easingFunction - An easing function which defines the animation curve.
33
+ */
29
34
  static easing<T extends typeof ComplexAnimationBuilder>(
30
35
  this: T,
31
36
  easingFunction: EasingFunction
@@ -39,6 +44,11 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
39
44
  return this;
40
45
  }
41
46
 
47
+ /**
48
+ * Lets you rotate the element. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
49
+ *
50
+ * @param degree - The rotation degree.
51
+ */
42
52
  static rotate<T extends typeof ComplexAnimationBuilder>(
43
53
  this: T,
44
54
  degree: string
@@ -52,6 +62,11 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
52
62
  return this;
53
63
  }
54
64
 
65
+ /**
66
+ * Enables the spring-based animation configuration. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
67
+ *
68
+ * @param duration - An optional duration of the spring animation (in milliseconds).
69
+ */
55
70
  static springify<T extends typeof ComplexAnimationBuilder>(
56
71
  this: T,
57
72
  duration?: number
@@ -66,6 +81,11 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
66
81
  return this;
67
82
  }
68
83
 
84
+ /**
85
+ * Lets you adjust the spring animation damping ratio. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
86
+ *
87
+ * @param dampingRatio - How damped the spring is.
88
+ */
69
89
  static dampingRatio<T extends typeof ComplexAnimationBuilder>(
70
90
  this: T,
71
91
  dampingRatio: number
@@ -74,11 +94,16 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
74
94
  return instance.dampingRatio(dampingRatio);
75
95
  }
76
96
 
77
- dampingRatio(dampingRatio: number): this {
78
- this.dampingRatioV = dampingRatio;
97
+ dampingRatio(value: number): this {
98
+ this.dampingRatioV = value;
79
99
  return this;
80
100
  }
81
101
 
102
+ /**
103
+ * Lets you adjust the spring animation damping. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
104
+ *
105
+ * @param value - Decides how quickly a spring stops moving. Higher damping means the spring will come to rest faster.
106
+ */
82
107
  static damping<T extends typeof ComplexAnimationBuilder>(
83
108
  this: T,
84
109
  damping: number
@@ -92,6 +117,11 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
92
117
  return this;
93
118
  }
94
119
 
120
+ /**
121
+ * Lets you adjust the spring animation mass. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
122
+ *
123
+ * @param mass - The weight of the spring. Reducing this value makes the animation faster.
124
+ */
95
125
  static mass<T extends typeof ComplexAnimationBuilder>(this: T, mass: number) {
96
126
  const instance = this.createInstance();
97
127
  return instance.mass(mass);
@@ -102,6 +132,11 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
102
132
  return this;
103
133
  }
104
134
 
135
+ /**
136
+ * Lets you adjust the stiffness of the spring animation. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
137
+ *
138
+ * @param stiffness - How bouncy the spring is.
139
+ */
105
140
  static stiffness<T extends typeof ComplexAnimationBuilder>(
106
141
  this: T,
107
142
  stiffness: number
@@ -115,6 +150,11 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
115
150
  return this;
116
151
  }
117
152
 
153
+ /**
154
+ * Lets you adjust overshoot clamping of the spring. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
155
+ *
156
+ * @param overshootClamping - Whether a spring can bounce over the final position.
157
+ */
118
158
  static overshootClamping<T extends typeof ComplexAnimationBuilder>(
119
159
  this: T,
120
160
  overshootClamping: number
@@ -128,6 +168,11 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
128
168
  return this;
129
169
  }
130
170
 
171
+ /**
172
+ * Lets you adjust the rest displacement threshold of the spring animation. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
173
+ *
174
+ * @param restDisplacementThreshold - The displacement below which the spring will snap to the designated position without further oscillations.
175
+ */
131
176
  static restDisplacementThreshold<T extends typeof ComplexAnimationBuilder>(
132
177
  this: T,
133
178
  restDisplacementThreshold: number
@@ -141,6 +186,11 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
141
186
  return this;
142
187
  }
143
188
 
189
+ /**
190
+ * Lets you adjust the rest speed threshold of the spring animation. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
191
+ *
192
+ * @param restSpeedThreshold - The speed in pixels per second from which the spring will snap to the designated position without further oscillations.
193
+ */
144
194
  static restSpeedThreshold<T extends typeof ComplexAnimationBuilder>(
145
195
  this: T,
146
196
  restSpeedThreshold: number
@@ -154,6 +204,11 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
154
204
  return this;
155
205
  }
156
206
 
207
+ /**
208
+ * Lets you override the initial config of the animation
209
+ *
210
+ * @param values - An object containing the styles to override.
211
+ */
157
212
  static withInitialValues<T extends typeof ComplexAnimationBuilder>(
158
213
  this: T,
159
214
  values: StyleProps
@@ -85,8 +85,7 @@ class InnerKeyframe implements IEntryExitAnimationBuilder {
85
85
  }
86
86
  initialValues.transform.forEach((transformStyle, index) => {
87
87
  Object.keys(transformStyle).forEach((transformProp: string) => {
88
- parsedKeyframes[index.toString() + '_transform:' + transformProp] =
89
- [];
88
+ parsedKeyframes[makeKeyframeKey(index, transformProp)] = [];
90
89
  });
91
90
  });
92
91
  } else {
@@ -164,7 +163,7 @@ class InnerKeyframe implements IEntryExitAnimationBuilder {
164
163
  (transformStyle: { [key: string]: any }, index) => {
165
164
  Object.keys(transformStyle).forEach((transformProp: string) => {
166
165
  addKeyPointWith(
167
- index.toString() + '_transform:' + transformProp,
166
+ makeKeyframeKey(index, transformProp),
168
167
  transformStyle[transformProp]
169
168
  );
170
169
  });
@@ -271,9 +270,7 @@ class InnerKeyframe implements IEntryExitAnimationBuilder {
271
270
  initialValues[key].forEach(
272
271
  (transformProp: Record<string, number | string>, index: number) => {
273
272
  Object.keys(transformProp).forEach((transformPropKey: string) => {
274
- addAnimation(
275
- index.toString() + '_transform:' + transformPropKey
276
- );
273
+ addAnimation(makeKeyframeKey(index, transformPropKey));
277
274
  });
278
275
  }
279
276
  );
@@ -290,6 +287,10 @@ class InnerKeyframe implements IEntryExitAnimationBuilder {
290
287
  };
291
288
  }
292
289
 
290
+ function makeKeyframeKey(index: number, transformProp: string) {
291
+ return `${index}_transform:${transformProp}`;
292
+ }
293
+
293
294
  // TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
294
295
  export declare class ReanimatedKeyframe {
295
296
  constructor(definitions: Record<string, KeyframeProps>);
@@ -137,6 +137,10 @@ export type CustomProgressAnimation = (
137
137
  progress: number
138
138
  ) => StyleProps;
139
139
 
140
+ /**
141
+ * Used to configure the `.defaultTransitionType()` shared transition modifier.
142
+ * @experimental
143
+ */
140
144
  export enum SharedTransitionType {
141
145
  ANIMATION = 'animation',
142
146
  PROGRESS_ANIMATION = 'progressAnimation',