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
@@ -1 +1 @@
1
- {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withSequence","_reduceMotionOrFirstAnimation","_len","arguments","length","_animations","Array","_key","reduceMotion","unshift","console","warn","onStart","animation","value","current","onFrame","animationIndex","animations","map","a","result","finished","findNextNonReducedMotionAnimationIndex","index","callback","forEach","sequence","now","currentAnim","nextAnim","previousAnimation","anim","undefined","currentAnimation","isHigherOrder"],"sources":["sequence.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type { NextAnimation, SequenceAnimation } from './commonTypes';\nimport type {\n Animation,\n AnimatableValue,\n AnimationObject,\n ReduceMotion,\n Timestamp,\n} from '../commonTypes';\n\nexport function withSequence<T extends AnimatableValue>(\n _reduceMotion: ReduceMotion,\n ...animations: T[]\n): T;\n\nexport function withSequence<T extends AnimatableValue>(...animations: T[]): T;\n\nexport function withSequence(\n _reduceMotionOrFirstAnimation?: ReduceMotion | NextAnimation<AnimationObject>,\n ..._animations: NextAnimation<AnimationObject>[]\n): Animation<SequenceAnimation> {\n 'worklet';\n let reduceMotion: ReduceMotion | undefined;\n\n // the first argument is either a config or an animation\n // this is done to allow the reduce motion config prop to be optional\n if (_reduceMotionOrFirstAnimation) {\n if (typeof _reduceMotionOrFirstAnimation === 'string') {\n reduceMotion = _reduceMotionOrFirstAnimation as ReduceMotion;\n } else {\n _animations.unshift(\n _reduceMotionOrFirstAnimation as NextAnimation<AnimationObject>\n );\n }\n }\n\n if (_animations.length === 0) {\n console.warn('[Reanimated] No animation was provided for the sequence');\n\n return defineAnimation<SequenceAnimation>(0, () => {\n 'worklet';\n return {\n onStart: (animation, value) => (animation.current = value),\n onFrame: () => true,\n current: 0,\n animationIndex: 0,\n reduceMotion: getReduceMotionForAnimation(reduceMotion),\n } as SequenceAnimation;\n });\n }\n\n return defineAnimation<SequenceAnimation>(\n _animations[0] as SequenceAnimation,\n () => {\n 'worklet';\n\n const animations = _animations.map((a) => {\n const result = typeof a === 'function' ? a() : a;\n result.finished = false;\n return result;\n });\n\n function findNextNonReducedMotionAnimationIndex(index: number) {\n // the last animation is returned even if reduced motion is enabled,\n // because we want the sequence to finish at the right spot\n while (\n index < animations.length - 1 &&\n animations[index].reduceMotion\n ) {\n index++;\n }\n\n return index;\n }\n\n const callback = (finished: boolean): void => {\n if (finished) {\n // we want to call the callback after every single animation\n // not after all of them\n return;\n }\n // this is going to be called only if sequence has been cancelled\n animations.forEach((animation) => {\n if (typeof animation.callback === 'function' && !animation.finished) {\n animation.callback(finished);\n }\n });\n };\n\n function sequence(animation: SequenceAnimation, now: Timestamp): boolean {\n const currentAnim = animations[animation.animationIndex];\n const finished = currentAnim.onFrame(currentAnim, now);\n animation.current = currentAnim.current;\n if (finished) {\n // we want to call the callback after every single animation\n if (currentAnim.callback) {\n currentAnim.callback(true /* finished */);\n }\n currentAnim.finished = true;\n animation.animationIndex = findNextNonReducedMotionAnimationIndex(\n animation.animationIndex + 1\n );\n if (animation.animationIndex < animations.length) {\n const nextAnim = animations[animation.animationIndex];\n nextAnim.onStart(nextAnim, currentAnim.current, now, currentAnim);\n return false;\n }\n return true;\n }\n return false;\n }\n\n function onStart(\n animation: SequenceAnimation,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: SequenceAnimation\n ): void {\n // child animations inherit the setting, unless they already have it defined\n // they will have it defined only if the user used the `reduceMotion` prop\n animations.forEach((anim) => {\n if (anim.reduceMotion === undefined) {\n anim.reduceMotion = animation.reduceMotion;\n }\n });\n animation.animationIndex = findNextNonReducedMotionAnimationIndex(0);\n\n if (previousAnimation === undefined) {\n previousAnimation = animations[\n animations.length - 1\n ] as SequenceAnimation;\n }\n\n const currentAnimation = animations[animation.animationIndex];\n currentAnimation.onStart(\n currentAnimation,\n value,\n now,\n previousAnimation\n );\n }\n\n return {\n isHigherOrder: true,\n onFrame: sequence,\n onStart,\n animationIndex: 0,\n current: animations[0].current,\n callback,\n reduceMotion: getReduceMotionForAnimation(reduceMotion),\n } as SequenceAnimation;\n }\n );\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;AAiBrE,OAAO,SAASC,YAAYA,CAC1BC,6BAA6E,EAE/C;EAC9B,SAAS;;EAAC,SAAAC,IAAA,GAAAC,S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c,GAAc,EACdG,iBAAoC,EAC9B;MACN;MACA;MACAb,UAAU,CAACQ,OAAO,CAAEM,IAAI,IAAK;QAC3B,IAAIA,IAAI,CAACxB,YAAY,KAAKyB,SAAS,EAAE;UACnCD,IAAI,CAACxB,YAAY,GAAGK,SAAS,CAACL,YAAY;QAC5C;MACF,CAAC,CAAC;MACFK,SAAS,CAACI,cAAc,GAAGM,sCAAsC,CAAC,CAAC,CAAC;MAEpE,IAAIQ,iBAAiB,KAAKE,SAAS,EAAE;QACnCF,iBAAiB,GAAGb,UAAU,CAC5BA,UAAU,CAACd,MAAM,GAAG,CAAC,CACD;MACxB;MAEA,MAAM8B,gBAAgB,GAAGhB,UAAU,CAACL,SAAS,CAACI,cAAc,CAAC;MAC7DiB,gBAAgB,CAACtB,OAAO,CACtBsB,gBAAgB,EAChBpB,KAAK,EACLc,GAAG,EACHG,iBAAiB,CAClB;IACH;IAEA,OAAO;MACLI,aAAa,EAAE,IAAI;MACnBnB,OAAO,EAAEW,QAAQ;MACjBf,OAAO;MACPK,cAAc,EAAE,CAAC;MACjBF,OAAO,EAAEG,UAAU,CAAC,CAAC,CAAC,CAACH,OAAO;MAC9BU,QAAQ;MACRjB,YAAY,EAAET,2BAA2B,CAACS,YAAY;IACxD,CAAC;EACH,CAAC,CACF;AACH"}
1
+ {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withSequence","_reduceMotionOrFirstAnimation","_len","arguments","length","_animations","Array","_key","reduceMotion","unshift","console","warn","onStart","animation","value","current","onFrame","animationIndex","animations","map","a","result","finished","findNextNonReducedMotionAnimationIndex","index","callback","forEach","sequence","now","currentAnim","nextAnim","previousAnimation","anim","undefined","currentAnimation","isHigherOrder"],"sources":["sequence.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type { NextAnimation, SequenceAnimation } from './commonTypes';\nimport type {\n Animation,\n AnimatableValue,\n AnimationObject,\n ReduceMotion,\n Timestamp,\n} from '../commonTypes';\n\n/**\n * Lets you run animations in a sequence.\n *\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\n * @param animations - Any number of animation objects to be run in a sequence.\n * @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation/\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSequence\n */\nexport function withSequence<T extends AnimatableValue>(\n _reduceMotion: ReduceMotion,\n ...animations: T[]\n): T;\n\nexport function withSequence<T extends AnimatableValue>(...animations: T[]): T;\n\nexport function withSequence(\n _reduceMotionOrFirstAnimation?: ReduceMotion | NextAnimation<AnimationObject>,\n ..._animations: NextAnimation<AnimationObject>[]\n): Animation<SequenceAnimation> {\n 'worklet';\n let reduceMotion: ReduceMotion | undefined;\n\n // the first argument is either a config or an animation\n // this is done to allow the reduce motion config prop to be optional\n if (_reduceMotionOrFirstAnimation) {\n if (typeof _reduceMotionOrFirstAnimation === 'string') {\n reduceMotion = _reduceMotionOrFirstAnimation as ReduceMotion;\n } else {\n _animations.unshift(\n _reduceMotionOrFirstAnimation as NextAnimation<AnimationObject>\n );\n }\n }\n\n if (_animations.length === 0) {\n console.warn('[Reanimated] No animation was provided for the sequence');\n\n return defineAnimation<SequenceAnimation>(0, () => {\n 'worklet';\n return {\n onStart: (animation, value) => (animation.current = value),\n onFrame: () => true,\n current: 0,\n animationIndex: 0,\n reduceMotion: getReduceMotionForAnimation(reduceMotion),\n } as SequenceAnimation;\n });\n }\n\n return defineAnimation<SequenceAnimation>(\n _animations[0] as SequenceAnimation,\n () => {\n 'worklet';\n\n const animations = _animations.map((a) => {\n const result = typeof a === 'function' ? a() : a;\n result.finished = false;\n return result;\n });\n\n function findNextNonReducedMotionAnimationIndex(index: number) {\n // the last animation is returned even if reduced motion is enabled,\n // because we want the sequence to finish at the right spot\n while (\n index < animations.length - 1 &&\n animations[index].reduceMotion\n ) {\n index++;\n }\n\n return index;\n }\n\n const callback = (finished: boolean): void => {\n if (finished) {\n // we want to call the callback after every single animation\n // not after all of them\n return;\n }\n // this is going to be called only if sequence has been cancelled\n animations.forEach((animation) => {\n if (typeof animation.callback === 'function' && !animation.finished) {\n animation.callback(finished);\n }\n });\n };\n\n function sequence(animation: SequenceAnimation, now: Timestamp): boolean {\n const currentAnim = animations[animation.animationIndex];\n const finished = currentAnim.onFrame(currentAnim, now);\n animation.current = currentAnim.current;\n if (finished) {\n // we want to call the callback after every single animation\n if (currentAnim.callback) {\n currentAnim.callback(true /* finished */);\n }\n currentAnim.finished = true;\n animation.animationIndex = findNextNonReducedMotionAnimationIndex(\n animation.animationIndex + 1\n );\n if (animation.animationIndex < animations.length) {\n const nextAnim = animations[animation.animationIndex];\n nextAnim.onStart(nextAnim, currentAnim.current, now, currentAnim);\n return false;\n }\n return true;\n }\n return false;\n }\n\n function onStart(\n animation: SequenceAnimation,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: SequenceAnimation\n ): void {\n // child animations inherit the setting, unless they already have it defined\n // they will have it defined only if the user used the `reduceMotion` prop\n animations.forEach((anim) => {\n if (anim.reduceMotion === undefined) {\n anim.reduceMotion = animation.reduceMotion;\n }\n });\n animation.animationIndex = findNextNonReducedMotionAnimationIndex(0);\n\n if (previousAnimation === undefined) {\n previousAnimation = animations[\n animations.length - 1\n ] as SequenceAnimation;\n }\n\n const currentAnimation = animations[animation.animationIndex];\n currentAnimation.onStart(\n currentAnimation,\n value,\n now,\n previousAnimation\n );\n }\n\n return {\n isHigherOrder: true,\n onFrame: sequence,\n onStart,\n animationIndex: 0,\n current: animations[0].current,\n callback,\n reduceMotion: getReduceMotionForAnimation(reduceMotion),\n } as SequenceAnimation;\n }\n );\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;;AAUrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAO,SAASC,YAAYA,CAC1BC,6BAA6E,EAE/C;E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OAAOA,CACdC,SAA4B,EAC5BC,KAAsB,EACtBc,GAAc,EACdG,iBAAoC,EAC9B;MACN;MACA;MACAb,UAAU,CAACQ,OAAO,CAAEM,IAAI,IAAK;QAC3B,IAAIA,IAAI,CAACxB,YAAY,KAAKyB,SAAS,EAAE;UACnCD,IAAI,CAACxB,YAAY,GAAGK,SAAS,CAACL,YAAY;QAC5C;MACF,CAAC,CAAC;MACFK,SAAS,CAACI,cAAc,GAAGM,sCAAsC,CAAC,CAAC,CAAC;MAEpE,IAAIQ,iBAAiB,KAAKE,SAAS,EAAE;QACnCF,iBAAiB,GAAGb,UAAU,CAC5BA,UAAU,CAACd,MAAM,GAAG,CAAC,CACD;MACxB;MAEA,MAAM8B,gBAAgB,GAAGhB,UAAU,CAACL,SAAS,CAACI,cAAc,CAAC;MAC7DiB,gBAAgB,CAACtB,OAAO,CACtBsB,gBAAgB,EAChBpB,KAAK,EACLc,GAAG,EACHG,iBAAiB,CAClB;IACH;IAEA,OAAO;MACLI,aAAa,EAAE,IAAI;MACnBnB,OAAO,EAAEW,QAAQ;MACjBf,OAAO;MACPK,cAAc,EAAE,CAAC;MACjBF,OAAO,EAAEG,UAAU,CAAC,CAAC,CAAC,CAACH,OAAO;MAC9BU,QAAQ;MACRjB,YAAY,EAAET,2BAA2B,CAACS,YAAY;IACxD,CAAC;EACH,CAAC,CACF;AACH"}
@@ -5,6 +5,15 @@ import { initialCalculations, calculateNewMassToMatchDuration, underDampedSpring
5
5
 
6
6
  // TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
7
7
 
8
+ /**
9
+ * Lets you create spring-based animations.
10
+ *
11
+ * @param toValue - the value at which the animation will come to rest - {@link AnimatableValue}
12
+ * @param config - the spring animation configuration - {@link SpringConfig}
13
+ * @param callback - a function called on animation complete - {@link AnimationCallback}
14
+ * @returns an [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation
15
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSpring
16
+ */
8
17
  export const withSpring = (toValue, userConfig, callback) => {
9
18
  'worklet';
10
19
 
@@ -1 +1 @@
1
- {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","initialCalculations","calculateNewMassToMatchDuration","underDampedSpringCalculations","criticallyDampedSpringCalculations","isAnimationTerminatingCalculation","checkIfConfigIsValid","withSpring","toValue","userConfig","callback","defaultConfig","damping","mass","stiffness","overshootClamping","restDisplacementThreshold","restSpeedThreshold","velocity","duration","dampingRatio","reduceMotion","undefined","config","useDuration","skipAnimation","springOnFrame","animation","now","startTimestamp","current","timeFromStart","lastTimestamp","deltaTime","Math","min","t","v0","x0","zeta","omega0","omega1","position","newPosition","newVelocity","isOvershooting","isVelocity","isDisplacement","springIsNotInMove","isTriggeredTwice","previousAnimation","onStart","value","startValue","triggeredTwice","Number","actualDuration","onFrame"],"sources":["spring.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n AnimationCallback,\n AnimatableValue,\n Timestamp,\n} from '../commonTypes';\nimport type {\n SpringConfig,\n SpringAnimation,\n InnerSpringAnimation,\n SpringConfigInner,\n DefaultSpringConfig,\n} from './springUtils';\nimport {\n initialCalculations,\n calculateNewMassToMatchDuration,\n underDampedSpringCalculations,\n criticallyDampedSpringCalculations,\n isAnimationTerminatingCalculation,\n checkIfConfigIsValid,\n} from './springUtils';\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withSpringType = <T extends AnimatableValue>(\n toValue: T,\n userConfig?: SpringConfig,\n callback?: AnimationCallback\n) => T;\n\nexport const withSpring = ((\n toValue: AnimatableValue,\n userConfig?: SpringConfig,\n callback?: AnimationCallback\n): Animation<SpringAnimation> => {\n 'worklet';\n\n return defineAnimation<SpringAnimation>(toValue, () => {\n 'worklet';\n const defaultConfig: DefaultSpringConfig = {\n damping: 10,\n mass: 1,\n stiffness: 100,\n overshootClamping: false,\n restDisplacementThreshold: 0.01,\n restSpeedThreshold: 2,\n velocity: 0,\n duration: 2000,\n dampingRatio: 0.5,\n reduceMotion: undefined,\n } as const;\n\n const config: DefaultSpringConfig & SpringConfigInner = {\n ...defaultConfig,\n ...userConfig,\n useDuration: !!(userConfig?.duration || userConfig?.dampingRatio),\n skipAnimation: false,\n };\n\n config.skipAnimation = !checkIfConfigIsValid(config);\n\n if (config.duration === 0) {\n config.skipAnimation = true;\n }\n\n function springOnFrame(\n animation: InnerSpringAnimation,\n now: Timestamp\n ): boolean {\n const { toValue, startTimestamp, current } = animation;\n\n const timeFromStart = now - startTimestamp;\n\n if (config.useDuration && timeFromStart >= config.duration) {\n animation.current = toValue;\n // clear lastTimestamp to avoid using stale value by the next spring animation that starts after this one\n animation.lastTimestamp = 0;\n return true;\n }\n\n if (config.skipAnimation) {\n animation.current = toValue;\n animation.lastTimestamp = 0;\n return true;\n }\n const { lastTimestamp, velocity } = animation;\n\n const deltaTime = Math.min(now - lastTimestamp, 64);\n animation.lastTimestamp = now;\n\n const t = deltaTime / 1000;\n const v0 = -velocity;\n const x0 = toValue - current;\n\n const { zeta, omega0, omega1 } = animation;\n\n const { position: newPosition, velocity: newVelocity } =\n zeta < 1\n ? underDampedSpringCalculations(animation, {\n zeta,\n v0,\n x0,\n omega0,\n omega1,\n t,\n })\n : criticallyDampedSpringCalculations(animation, {\n v0,\n x0,\n omega0,\n t,\n });\n\n animation.current = newPosition;\n animation.velocity = newVelocity;\n\n const { isOvershooting, isVelocity, isDisplacement } =\n isAnimationTerminatingCalculation(animation, config);\n\n const springIsNotInMove =\n isOvershooting || (isVelocity && isDisplacement);\n\n if (!config.useDuration && springIsNotInMove) {\n animation.velocity = 0;\n animation.current = toValue;\n // clear lastTimestamp to avoid using stale value by the next spring animation that starts after this one\n animation.lastTimestamp = 0;\n return true;\n }\n\n return false;\n }\n\n function isTriggeredTwice(\n previousAnimation: SpringAnimation | undefined,\n animation: SpringAnimation\n ) {\n return (\n previousAnimation?.lastTimestamp &&\n previousAnimation?.startTimestamp &&\n previousAnimation?.toValue === animation.toValue &&\n previousAnimation?.duration === animation.duration &&\n previousAnimation?.dampingRatio === animation.dampingRatio\n );\n }\n\n function onStart(\n animation: SpringAnimation,\n value: number,\n now: Timestamp,\n previousAnimation: SpringAnimation | undefined\n ): void {\n animation.current = value;\n animation.startValue = value;\n\n let mass = config.mass;\n const triggeredTwice = isTriggeredTwice(previousAnimation, animation);\n\n const duration = config.duration;\n\n const x0 = triggeredTwice\n ? // If animation is triggered twice we want to continue the previous animation\n // form the previous starting point\n previousAnimation?.startValue\n : Number(animation.toValue) - value;\n\n if (previousAnimation) {\n animation.velocity =\n (triggeredTwice\n ? previousAnimation?.velocity\n : previousAnimation?.velocity + config.velocity) || 0;\n } else {\n animation.velocity = config.velocity || 0;\n }\n\n if (triggeredTwice) {\n animation.zeta = previousAnimation?.zeta || 0;\n animation.omega0 = previousAnimation?.omega0 || 0;\n animation.omega1 = previousAnimation?.omega1 || 0;\n } else {\n if (config.useDuration) {\n const actualDuration = triggeredTwice\n ? // If animation is triggered twice we want to continue the previous animation\n // so we need to include the time that already elapsed\n duration -\n ((previousAnimation?.lastTimestamp || 0) -\n (previousAnimation?.startTimestamp || 0))\n : duration;\n\n config.duration = actualDuration;\n mass = calculateNewMassToMatchDuration(\n x0 as number,\n config,\n animation.velocity\n );\n }\n\n const { zeta, omega0, omega1 } = initialCalculations(mass, config);\n animation.zeta = zeta;\n animation.omega0 = omega0;\n animation.omega1 = omega1;\n }\n\n animation.lastTimestamp = previousAnimation?.lastTimestamp || now;\n\n animation.startTimestamp = triggeredTwice\n ? previousAnimation?.startTimestamp || now\n : now;\n }\n\n return {\n onFrame: springOnFrame,\n onStart,\n toValue,\n velocity: config.velocity || 0,\n current: toValue,\n startValue: 0,\n callback,\n lastTimestamp: 0,\n startTimestamp: 0,\n zeta: 0,\n omega0: 0,\n omega1: 0,\n reduceMotion: getReduceMotionForAnimation(config.reduceMotion),\n } as SpringAnimation;\n });\n}) as withSpringType;\n"],"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M;UAAEC;QAAO,CAAC,GAAGxC,mBAAmB,CAACY,IAAI,EAAEU,MAAM,CAAC;QAClEI,SAAS,CAACY,IAAI,GAAGA,IAAI;QACrBZ,SAAS,CAACa,MAAM,GAAGA,MAAM;QACzBb,SAAS,CAACc,MAAM,GAAGA,MAAM;MAC3B;MAEAd,SAAS,CAACK,aAAa,GAAG,CAAAkB,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAElB,aAAa,KAAIJ,GAAG;MAEjED,SAAS,CAACE,cAAc,GAAGyB,cAAc,GACrC,CAAAJ,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAErB,cAAc,KAAID,GAAG,GACxCA,GAAG;IACT;IAEA,OAAO;MACL6B,OAAO,EAAE/B,aAAa;MACtByB,OAAO;MACP3C,OAAO;MACPU,QAAQ,EAAEK,MAAM,CAACL,QAAQ,IAAI,CAAC;MAC9BY,OAAO,EAAEtB,OAAO;MAChB6C,UAAU,EAAE,CAAC;MACb3C,QAAQ;MACRsB,aAAa,EAAE,CAAC;MAChBH,cAAc,EAAE,CAAC;MACjBU,IAAI,EAAE,CAAC;MACPC,MAAM,EAAE,CAAC;MACTC,MAAM,EAAE,CAAC;MACTpB,YAAY,EAAErB,2BAA2B,CAACuB,MAAM,CAACF,YAAY;IAC/D,CAAC;EACH,CAAC,CAAC;AACJ,CAAoB"}
1
+ {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","initialCalculations","calculateNewMassToMatchDuration","underDampedSpringCalculations","criticallyDampedSpringCalculations","isAnimationTerminatingCalculation","checkIfConfigIsValid","withSpring","toValue","userConfig","callback","defaultConfig","damping","mass","stiffness","overshootClamping","restDisplacementThreshold","restSpeedThreshold","velocity","duration","dampingRatio","reduceMotion","undefined","config","useDuration","skipAnimation","springOnFrame","animation","now","startTimestamp","current","timeFromStart","lastTimestamp","deltaTime","Math","min","t","v0","x0","zeta","omega0","omega1","position","newPosition","newVelocity","isOvershooting","isVelocity","isDisplacement","springIsNotInMove","isTriggeredTwice","previousAnimation","onStart","value","startValue","triggeredTwice","Number","actualDuration","onFrame"],"sources":["spring.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n AnimationCallback,\n AnimatableValue,\n Timestamp,\n} from '../commonTypes';\nimport type {\n SpringConfig,\n SpringAnimation,\n InnerSpringAnimation,\n SpringConfigInner,\n DefaultSpringConfig,\n} from './springUtils';\nimport {\n initialCalculations,\n calculateNewMassToMatchDuration,\n underDampedSpringCalculations,\n criticallyDampedSpringCalculations,\n isAnimationTerminatingCalculation,\n checkIfConfigIsValid,\n} from './springUtils';\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withSpringType = <T extends AnimatableValue>(\n toValue: T,\n userConfig?: SpringConfig,\n callback?: AnimationCallback\n) => T;\n\n/**\n * Lets you create spring-based animations.\n *\n * @param toValue - the value at which the animation will come to rest - {@link AnimatableValue}\n * @param config - the spring animation configuration - {@link SpringConfig}\n * @param callback - a function called on animation complete - {@link AnimationCallback}\n * @returns an [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSpring\n */\nexport const withSpring = ((\n toValue: AnimatableValue,\n userConfig?: SpringConfig,\n callback?: AnimationCallback\n): Animation<SpringAnimation> => {\n 'worklet';\n\n return defineAnimation<SpringAnimation>(toValue, () => {\n 'worklet';\n const defaultConfig: DefaultSpringConfig = {\n damping: 10,\n mass: 1,\n stiffness: 100,\n overshootClamping: false,\n restDisplacementThreshold: 0.01,\n restSpeedThreshold: 2,\n velocity: 0,\n duration: 2000,\n dampingRatio: 0.5,\n reduceMotion: undefined,\n } as const;\n\n const config: DefaultSpringConfig & SpringConfigInner = {\n ...defaultConfig,\n ...userConfig,\n useDuration: !!(userConfig?.duration || userConfig?.dampingRatio),\n skipAnimation: false,\n };\n\n config.skipAnimation = !checkIfConfigIsValid(config);\n\n if (config.duration === 0) {\n config.skipAnimation = true;\n }\n\n function springOnFrame(\n animation: InnerSpringAnimation,\n now: Timestamp\n ): boolean {\n const { toValue, startTimestamp, current } = animation;\n\n const timeFromStart = now - startTimestamp;\n\n if (config.useDuration && timeFromStart >= config.duration) {\n animation.current = toValue;\n // clear lastTimestamp to avoid using stale value by the next spring animation that starts after this one\n animation.lastTimestamp = 0;\n return true;\n }\n\n if (config.skipAnimation) {\n animation.current = toValue;\n animation.lastTimestamp = 0;\n return true;\n }\n const { lastTimestamp, velocity } = animation;\n\n const deltaTime = Math.min(now - lastTimestamp, 64);\n animation.lastTimestamp = now;\n\n const t = deltaTime / 1000;\n const v0 = -velocity;\n const x0 = toValue - current;\n\n const { zeta, omega0, omega1 } = animation;\n\n const { position: newPosition, velocity: newVelocity } =\n zeta < 1\n ? underDampedSpringCalculations(animation, {\n zeta,\n v0,\n x0,\n omega0,\n omega1,\n t,\n })\n : criticallyDampedSpringCalculations(animation, {\n v0,\n x0,\n omega0,\n t,\n });\n\n animation.current = newPosition;\n animation.velocity = newVelocity;\n\n const { isOvershooting, isVelocity, isDisplacement } =\n isAnimationTerminatingCalculation(animation, config);\n\n const springIsNotInMove =\n isOvershooting || (isVelocity && isDisplacement);\n\n if (!config.useDuration && springIsNotInMove) {\n animation.velocity = 0;\n animation.current = toValue;\n // clear lastTimestamp to avoid using stale value by the next spring animation that starts after this one\n animation.lastTimestamp = 0;\n return true;\n }\n\n return false;\n }\n\n function isTriggeredTwice(\n previousAnimation: SpringAnimation | undefined,\n animation: SpringAnimation\n ) {\n return (\n previousAnimation?.lastTimestamp &&\n previousAnimation?.startTimestamp &&\n previousAnimation?.toValue === animation.toValue &&\n previousAnimation?.duration === animation.duration &&\n previousAnimation?.dampingRatio === animation.dampingRatio\n );\n }\n\n function onStart(\n animation: SpringAnimation,\n value: number,\n now: Timestamp,\n previousAnimation: SpringAnimation | undefined\n ): void {\n animation.current = value;\n animation.startValue = value;\n\n let mass = config.mass;\n const triggeredTwice = isTriggeredTwice(previousAnimation, animation);\n\n const duration = config.duration;\n\n const x0 = triggeredTwice\n ? // If animation is triggered twice we want to continue the previous animation\n // form the previous starting point\n previousAnimation?.startValue\n : Number(animation.toValue) - value;\n\n if (previousAnimation) {\n animation.velocity =\n (triggeredTwice\n ? previousAnimation?.velocity\n : previousAnimation?.velocity + config.velocity) || 0;\n } else {\n animation.velocity = config.velocity || 0;\n }\n\n if (triggeredTwice) {\n animation.zeta = previousAnimation?.zeta || 0;\n animation.omega0 = previousAnimation?.omega0 || 0;\n animation.omega1 = previousAnimation?.omega1 || 0;\n } else {\n if (config.useDuration) {\n const actualDuration = triggeredTwice\n ? // If animation is triggered twice we want to continue the previous animation\n // so we need to include the time that already elapsed\n duration -\n ((previousAnimation?.lastTimestamp || 0) -\n (previousAnimation?.startTimestamp || 0))\n : duration;\n\n config.duration = actualDuration;\n mass = calculateNewMassToMatchDuration(\n x0 as number,\n config,\n animation.velocity\n );\n }\n\n const { zeta, omega0, omega1 } = initialCalculations(mass, config);\n animation.zeta = zeta;\n animation.omega0 = omega0;\n animation.omega1 = omega1;\n }\n\n animation.lastTimestamp = previousAnimation?.lastTimestamp || now;\n\n animation.startTimestamp = triggeredTwice\n ? previousAnimation?.startTimestamp || now\n : now;\n }\n\n return {\n onFrame: springOnFrame,\n onStart,\n toValue,\n velocity: config.velocity || 0,\n current: toValue,\n startValue: 0,\n callback,\n lastTimestamp: 0,\n startTimestamp: 0,\n zeta: 0,\n omega0: 0,\n omega1: 0,\n reduceMotion: getReduceMotionForAnimation(config.reduceMotion),\n } as SpringAnimation;\n });\n}) as withSpringType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;AAcrE,SACEC,mBAAmB,EACnBC,+BAA+B,EAC/BC,6BAA6B,EAC7BC,kCAAkC,EAClCC,iCAAiC,EACjCC,oBAAoB,QACf,eAAe;;AAEtB;;AAOA;AACA;AACA;AACA;A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AAM,GAAGA,MAAM;MAC3B;MAEAd,SAAS,CAACK,aAAa,GAAG,CAAAkB,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAElB,aAAa,KAAIJ,GAAG;MAEjED,SAAS,CAACE,cAAc,GAAGyB,cAAc,GACrC,CAAAJ,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAErB,cAAc,KAAID,GAAG,GACxCA,GAAG;IACT;IAEA,OAAO;MACL6B,OAAO,EAAE/B,aAAa;MACtByB,OAAO;MACP3C,OAAO;MACPU,QAAQ,EAAEK,MAAM,CAACL,QAAQ,IAAI,CAAC;MAC9BY,OAAO,EAAEtB,OAAO;MAChB6C,UAAU,EAAE,CAAC;MACb3C,QAAQ;MACRsB,aAAa,EAAE,CAAC;MAChBH,cAAc,EAAE,CAAC;MACjBU,IAAI,EAAE,CAAC;MACPC,MAAM,EAAE,CAAC;MACTC,MAAM,EAAE,CAAC;MACTpB,YAAY,EAAErB,2BAA2B,CAACuB,MAAM,CAACF,YAAY;IAC/D,CAAC;EACH,CAAC,CAAC;AACJ,CAAoB"}
@@ -1,5 +1,21 @@
1
1
  'use strict';
2
2
 
3
+ /**
4
+ * Spring animation configuration.
5
+ *
6
+ * @param mass - The weight of the spring. Reducing this value makes the animation faster. Defaults to 1.
7
+ * @param damping - How quickly a spring slows down. Higher damping means the spring will come to rest faster. Defaults to 10.
8
+ * @param duration - Length of the animation (in milliseconds). Defaults to 2000.
9
+ * @param dampingRatio - How damped the spring is. Value 1 means the spring is critically damped, and value \>1 means the spring is overdamped. Defaults to 0.5.
10
+ * @param stiffness - How bouncy the spring is. Defaults to 100.
11
+ * @param velocity - Initial velocity applied to the spring equation. Defaults to 0.
12
+ * @param overshootClamping - Whether a spring can bounce over the `toValue`. Defaults to false.
13
+ * @param restDisplacementThreshold - The displacement below which the spring will snap to toValue without further oscillations. Defaults to 0.01.
14
+ * @param restSpeedThreshold - The speed in pixels per second from which the spring will snap to toValue without further oscillations. Defaults to 2.
15
+ * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.
16
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSpring/#config-
17
+ */
18
+
3
19
  // This type contains all the properties from SpringConfig, which are changed to be required, except for optional 'reduceMotion'
4
20
 
5
21
  export function checkIfConfigIsValid(config) {
@@ -1 +1 @@
1
- {"version":3,"names":["checkIfConfigIsValid","config","errorMessage","forEach","prop","value","duration","console","warn","bisectRoot","_ref","min","max","func","maxIterations","ACCURACY","idx","current","Math","abs","initialCalculations","mass","arguments","length","undefined","skipAnimation","zeta","omega0","omega1","useDuration","stiffness","k","dampingRatio","sqrt","damping","c","m","calculateNewMassToMatchDuration","x0","v0","restSpeedThreshold","threshold","durationForMass","amplitude","exp","log","criticallyDampedSpringCalculations","animation","precalculatedValues","toValue","t","criticallyDampedEnvelope","criticallyDampedPosition","criticallyDampedVelocity","position","velocity","underDampedSpringCalculations","sin1","sin","cos1","cos","underDampedEnvelope","underDampedFrag1","underDampedPosition","underDampedVelocity","isAnimationTerminatingCalculation","startValue","isOvershooting","overshootClamping","isVelocity","isDisplacement","restDisplacementThreshold"],"sources":["springUtils.ts"],"sourcesContent":["'use strict';\nimport type {\n Animation,\n AnimatableValue,\n Timestamp,\n ReduceMotion,\n} from '../commonTypes';\n\nexport type SpringConfig = {\n stiffness?: number;\n overshootClamping?: boolean;\n restDisplacementThreshold?: number;\n restSpeedThreshold?: number;\n velocity?: number;\n reduceMotion?: ReduceMotion;\n} & (\n | {\n mass?: number;\n damping?: number;\n duration?: never;\n dampingRatio?: never;\n }\n | {\n mass?: never;\n damping?: never;\n duration?: number;\n dampingRatio?: number;\n }\n);\n\n// This type contains all the properties from SpringConfig, which are changed to be required, except for optional 'reduceMotion'\nexport type DefaultSpringConfig = {\n [K in keyof Required<SpringConfig>]: K extends 'reduceMotion'\n ? Required<SpringConfig>[K] | undefined\n : Required<SpringConfig>[K];\n};\nexport type WithSpringConfig = SpringConfig;\n\nexport interface SpringConfigInner {\n useDuration: boolean;\n skipAnimation: boolean;\n}\n\nexport interface SpringAnimation extends Animation<SpringAnimation> {\n current: AnimatableValue;\n toValue: AnimatableValue;\n velocity: number;\n lastTimestamp: Timestamp;\n startTimestamp: Timestamp;\n startValue: number;\n zeta: number;\n omega0: number;\n omega1: number;\n}\n\nexport interface InnerSpringAnimation\n extends Omit<SpringAnimation, 'toValue' | 'current'> {\n toValue: number;\n current: number;\n}\nexport function checkIfConfigIsValid(config: DefaultSpringConfig): boolean {\n 'worklet';\n let errorMessage = '';\n (\n [\n 'stiffness',\n 'damping',\n 'dampingRatio',\n 'restDisplacementThreshold',\n 'restSpeedThreshold',\n 'mass',\n ] as const\n ).forEach((prop) => {\n const value = config[prop];\n if (value <= 0) {\n errorMessage += `, ${prop} must be grater than zero but got ${value}`;\n }\n });\n\n if (config.duration < 0) {\n errorMessage += `, duration can't be negative, got ${config.duration}`;\n }\n\n if (errorMessage !== '') {\n console.warn('[Reanimated] Invalid spring config' + errorMessage);\n }\n\n return errorMessage === '';\n}\n\nfunction bisectRoot({\n min,\n max,\n func,\n maxIterations = 20,\n}: {\n min: number;\n max: number;\n func: (x: number) => number;\n maxIterations?: number;\n}) {\n 'worklet';\n const ACCURACY = 0.00005;\n let idx = maxIterations;\n let current = (max + min) / 2;\n while (Math.abs(func(current)) > ACCURACY && idx > 0) {\n idx -= 1;\n\n if (func(current) < 0) {\n min = current;\n } else {\n max = current;\n }\n current = (min + max) / 2;\n }\n return current;\n}\n\nexport function initialCalculations(\n mass = 0,\n config: DefaultSpringConfig & SpringConfigInner\n): {\n zeta: number;\n omega0: number;\n omega1: number;\n} {\n 'worklet';\n\n if (config.skipAnimation) {\n return { zeta: 0, omega0: 0, omega1: 0 };\n }\n\n if (config.useDuration) {\n const { stiffness: k, dampingRatio: zeta } = config;\n\n /** omega0 and omega1 denote angular frequency and natural angular frequency, see this link for formulas:\n * https://courses.lumenlearning.com/suny-osuniversityphysics/chapter/15-5-damped-oscillations/\n */\n const omega0 = Math.sqrt(k / mass);\n const omega1 = omega0 * Math.sqrt(1 - zeta ** 2);\n\n return { zeta, omega0, omega1 };\n } else {\n const { damping: c, mass: m, stiffness: k } = config;\n\n const zeta = c / (2 * Math.sqrt(k * m)); // damping ratio\n const omega0 = Math.sqrt(k / m); // undamped angular frequency of the oscillator (rad/ms)\n const omega1 = omega0 * Math.sqrt(1 - zeta ** 2); // exponential decay\n\n return { zeta, omega0, omega1 };\n }\n}\n\nexport function calculateNewMassToMatchDuration(\n x0: number,\n config: DefaultSpringConfig & SpringConfigInner,\n v0: number\n) {\n 'worklet';\n if (config.skipAnimation) {\n return 0;\n }\n\n /** Use this formula: https://phys.libretexts.org/Bookshelves/University_Physics/Book%3A_University_Physics_(OpenStax)/Book%3A_University_Physics_I_-_Mechanics_Sound_Oscillations_and_Waves_(OpenStax)/15%3A_Oscillations/15.06%3A_Damped_Oscillations\n * to find the asymptote and estimate the damping that gives us the expected duration \n\n ⎛ ⎛ c⎞ ⎞ \n ⎜-⎜──⎟ ⋅ duration⎟ \n ⎝ ⎝2m⎠ ⎠ \n A ⋅ e = threshold\n\n \n Amplitude calculated using \"Conservation of energy\"\n _________________\n ╱ 2 2\n ╱ m ⋅ v0 + k ⋅ x0 \n amplitude = ╱ ─────────────────\n ╲╱ k \n\n And replace mass with damping ratio which is provided: m = (c^2)/(4 * k * zeta^2) \n */\n const {\n stiffness: k,\n dampingRatio: zeta,\n restSpeedThreshold: threshold,\n duration,\n } = config;\n\n const durationForMass = (mass: number) => {\n 'worklet';\n const amplitude =\n (mass * v0 * v0 + k * x0 * x0) / (Math.exp(1 - 0.5 * zeta) * k);\n const c = zeta * 2 * Math.sqrt(k * mass);\n return (\n 1000 * ((-2 * mass) / c) * Math.log((threshold * 0.01) / amplitude) -\n duration\n );\n };\n\n // Bisection turns out to be much faster than Newton's method in our case\n return bisectRoot({ min: 0, max: 100, func: durationForMass });\n}\n\nexport function criticallyDampedSpringCalculations(\n animation: InnerSpringAnimation,\n precalculatedValues: {\n v0: number;\n x0: number;\n omega0: number;\n t: number;\n }\n): { position: number; velocity: number } {\n 'worklet';\n const { toValue } = animation;\n\n const { v0, x0, omega0, t } = precalculatedValues;\n\n const criticallyDampedEnvelope = Math.exp(-omega0 * t);\n const criticallyDampedPosition =\n toValue - criticallyDampedEnvelope * (x0 + (v0 + omega0 * x0) * t);\n\n const criticallyDampedVelocity =\n criticallyDampedEnvelope *\n (v0 * (t * omega0 - 1) + t * x0 * omega0 * omega0);\n\n return {\n position: criticallyDampedPosition,\n velocity: criticallyDampedVelocity,\n };\n}\n\nexport function underDampedSpringCalculations(\n animation: InnerSpringAnimation,\n precalculatedValues: {\n zeta: number;\n v0: number;\n x0: number;\n omega0: number;\n omega1: number;\n t: number;\n }\n): { position: number; velocity: number } {\n 'worklet';\n const { toValue, current, velocity } = animation;\n\n const { zeta, t, omega0, omega1 } = precalculatedValues;\n\n const v0 = -velocity;\n const x0 = toValue - current;\n\n const sin1 = Math.sin(omega1 * t);\n const cos1 = Math.cos(omega1 * t);\n\n // under damped\n const underDampedEnvelope = Math.exp(-zeta * omega0 * t);\n const underDampedFrag1 =\n underDampedEnvelope *\n (sin1 * ((v0 + zeta * omega0 * x0) / omega1) + x0 * cos1);\n\n const underDampedPosition = toValue - underDampedFrag1;\n // This looks crazy -- it's actually just the derivative of the oscillation function\n const underDampedVelocity =\n zeta * omega0 * underDampedFrag1 -\n underDampedEnvelope *\n (cos1 * (v0 + zeta * omega0 * x0) - omega1 * x0 * sin1);\n\n return { position: underDampedPosition, velocity: underDampedVelocity };\n}\n\nexport function isAnimationTerminatingCalculation(\n animation: InnerSpringAnimation,\n config: DefaultSpringConfig\n): {\n isOvershooting: boolean;\n isVelocity: boolean;\n isDisplacement: boolean;\n} {\n 'worklet';\n const { toValue, velocity, startValue, current } = animation;\n\n const isOvershooting = config.overshootClamping\n ? (current > toValue && startValue < toValue) ||\n (current < toValue && startValue > toValue)\n : false;\n\n const isVelocity = Math.abs(velocity) < config.restSpeedThreshold;\n const isDisplacement =\n Math.abs(toValue - current) < config.restDisplacementThreshold;\n\n return { isOvershooting, isVelocity, isDisplacement };\n}\n"],"mappings":"AAAA,YAAY;;AA8BZ;;AA8BA,OAAO,SAASA,oBAAoBA,CAACC,MAA2B,EAAW;EACzE,SAAS;;EACT,IAAIC,YAAY,GAAG,EAAE;EAEnB,CACE,WAAW,EACX,SAAS,EACT,cAAc,EACd,2BAA2B,EAC3B,oBAAoB,EACpB,MAAM,CACP,CACDC,OAAO,CAAEC,IAAI,IAAK;IAClB,MAAMC,KAAK,GAAGJ,MAAM,CAACG,IAAI,CAAC;IAC1B,IAAIC,KAAK,IAAI,CAAC,EAAE;MACdH,YAAY,IAAK,KAAIE,IAAK,qCAAoCC,KAAM,EAAC;IACvE;EACF,CAAC,CAAC;EAEF,IAAIJ,MAAM,CAACK,QAAQ,GAAG,CAAC,EAAE;IACvBJ,YAAY,IAAK,qCAAoCD,MAAM,CAACK,QAAS,EAAC;EACxE;EAEA,IAAIJ,YAAY,KAAK,EAAE,EAAE;IACvBK,OAAO,CAACC,IAAI,CAAC,oCAAoC,GAAGN,YAAY,CAAC;EACnE;EAEA,OAAOA,YAAY,KAAK,EAAE;AAC5B;AAEA,SAASO,UAAUA,CAAAC,IAAA,EAUhB;EACD,SAAS;;EAAC,IAXQ;IAClBC,GAAG;IACHC,GAAG;IACHC,IAAI;IACJC,aAAa,GAAG;EAMlB,CAAC,GAAAJ,IAAA;EAEC,MAAMK,QAAQ,GAAG,OAAO;EACxB,IAAIC,GAAG,GAAGF,aAAa;EACvB,IAAIG,OAAO,GAAG,CAACL,GAAG,GAAGD,GAAG,IAAI,CAAC;EAC7B,OAAOO,IAAI,CAACC,GAAG,CAACN,IAAI,CAACI,OAAO,CAAC,CAAC,GAAGF,QAAQ,IAAIC,GAAG,GAAG,CAAC,EAAE;IACpDA,GAAG,IAAI,CAAC;IAER,IAAIH,IAAI,CAACI,OAAO,CAA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","_ref","min","max","func","maxIterations","ACCURACY","idx","current","Math","abs","initialCalculations","mass","arguments","length","undefined","skipAnimation","zeta","omega0","omega1","useDuration","stiffness","k","dampingRatio","sqrt","damping","c","m","calculateNewMassToMatchDuration","x0","v0","restSpeedThreshold","threshold","durationForMass","amplitude","exp","log","criticallyDampedSpringCalculations","animation","precalculatedValues","toValue","t","criticallyDampedEnvelope","criticallyDampedPosition","criticallyDampedVelocity","position","velocity","underDampedSpringCalculations","sin1","sin","cos1","cos","underDampedEnvelope","underDampedFrag1","underDampedPosition","underDampedVelocity","isAnimationTerminatingCalculation","startValue","isOvershooting","overshootClamping","isVelocity","isDisplacement","restDisplacementThreshold"],"sources":["springUtils.ts"],"sourcesContent":["'use strict';\nimport type {\n Animation,\n AnimatableValue,\n Timestamp,\n ReduceMotion,\n} from '../commonTypes';\n\n/**\n * Spring animation configuration.\n *\n * @param mass - The weight of the spring. Reducing this value makes the animation faster. Defaults to 1.\n * @param damping - How quickly a spring slows down. Higher damping means the spring will come to rest faster. Defaults to 10.\n * @param duration - Length of the animation (in milliseconds). Defaults to 2000.\n * @param dampingRatio - How damped the spring is. Value 1 means the spring is critically damped, and value \\>1 means the spring is overdamped. Defaults to 0.5.\n * @param stiffness - How bouncy the spring is. Defaults to 100.\n * @param velocity - Initial velocity applied to the spring equation. Defaults to 0.\n * @param overshootClamping - Whether a spring can bounce over the `toValue`. Defaults to false.\n * @param restDisplacementThreshold - The displacement below which the spring will snap to toValue without further oscillations. Defaults to 0.01.\n * @param restSpeedThreshold - The speed in pixels per second from which the spring will snap to toValue without further oscillations. Defaults to 2.\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSpring/#config-\n */\nexport type SpringConfig = {\n stiffness?: number;\n overshootClamping?: boolean;\n restDisplacementThreshold?: number;\n restSpeedThreshold?: number;\n velocity?: number;\n reduceMotion?: ReduceMotion;\n} & (\n | {\n mass?: number;\n damping?: number;\n duration?: never;\n dampingRatio?: never;\n }\n | {\n mass?: never;\n damping?: never;\n duration?: number;\n dampingRatio?: number;\n }\n);\n\n// This type contains all the properties from SpringConfig, which are changed to be required, except for optional 'reduceMotion'\nexport type DefaultSpringConfig = {\n [K in keyof Required<SpringConfig>]: K extends 'reduceMotion'\n ? Required<SpringConfig>[K] | undefined\n : Required<SpringConfig>[K];\n};\nexport type WithSpringConfig = SpringConfig;\n\nexport interface SpringConfigInner {\n useDuration: boolean;\n skipAnimation: boolean;\n}\n\nexport interface SpringAnimation extends Animation<SpringAnimation> {\n current: AnimatableValue;\n toValue: AnimatableValue;\n velocity: number;\n lastTimestamp: Timestamp;\n startTimestamp: Timestamp;\n startValue: number;\n zeta: number;\n omega0: number;\n omega1: number;\n}\n\nexport interface InnerSpringAnimation\n extends Omit<SpringAnimation, 'toValue' | 'current'> {\n toValue: number;\n current: number;\n}\nexport function checkIfConfigIsValid(config: DefaultSpringConfig): boolean {\n 'worklet';\n let errorMessage = '';\n (\n [\n 'stiffness',\n 'damping',\n 'dampingRatio',\n 'restDisplacementThreshold',\n 'restSpeedThreshold',\n 'mass',\n ] as const\n ).forEach((prop) => {\n const value = config[prop];\n if (value <= 0) {\n errorMessage += `, ${prop} must be grater than zero but got ${value}`;\n }\n });\n\n if (config.duration < 0) {\n errorMessage += `, duration can't be negative, got ${config.duration}`;\n }\n\n if (errorMessage !== '') {\n console.warn('[Reanimated] Invalid spring config' + errorMessage);\n }\n\n return errorMessage === '';\n}\n\nfunction bisectRoot({\n min,\n max,\n func,\n maxIterations = 20,\n}: {\n min: number;\n max: number;\n func: (x: number) => number;\n maxIterations?: number;\n}) {\n 'worklet';\n const ACCURACY = 0.00005;\n let idx = maxIterations;\n let current = (max + min) / 2;\n while (Math.abs(func(current)) > ACCURACY && idx > 0) {\n idx -= 1;\n\n if (func(current) < 0) {\n min = current;\n } else {\n max = current;\n }\n current = (min + max) / 2;\n }\n return current;\n}\n\nexport function initialCalculations(\n mass = 0,\n config: DefaultSpringConfig & SpringConfigInner\n): {\n zeta: number;\n omega0: number;\n omega1: number;\n} {\n 'worklet';\n\n if (config.skipAnimation) {\n return { zeta: 0, omega0: 0, omega1: 0 };\n }\n\n if (config.useDuration) {\n const { stiffness: k, dampingRatio: zeta } = config;\n\n /** omega0 and omega1 denote angular frequency and natural angular frequency, see this link for formulas:\n * https://courses.lumenlearning.com/suny-osuniversityphysics/chapter/15-5-damped-oscillations/\n */\n const omega0 = Math.sqrt(k / mass);\n const omega1 = omega0 * Math.sqrt(1 - zeta ** 2);\n\n return { zeta, omega0, omega1 };\n } else {\n const { damping: c, mass: m, stiffness: k } = config;\n\n const zeta = c / (2 * Math.sqrt(k * m)); // damping ratio\n const omega0 = Math.sqrt(k / m); // undamped angular frequency of the oscillator (rad/ms)\n const omega1 = omega0 * Math.sqrt(1 - zeta ** 2); // exponential decay\n\n return { zeta, omega0, omega1 };\n }\n}\n\nexport function calculateNewMassToMatchDuration(\n x0: number,\n config: DefaultSpringConfig & SpringConfigInner,\n v0: number\n) {\n 'worklet';\n if (config.skipAnimation) {\n return 0;\n }\n\n /** Use this formula: https://phys.libretexts.org/Bookshelves/University_Physics/Book%3A_University_Physics_(OpenStax)/Book%3A_University_Physics_I_-_Mechanics_Sound_Oscillations_and_Waves_(OpenStax)/15%3A_Oscillations/15.06%3A_Damped_Oscillations\n * to find the asymptote and estimate the damping that gives us the expected duration \n\n ⎛ ⎛ c⎞ ⎞ \n ⎜-⎜──⎟ ⋅ duration⎟ \n ⎝ ⎝2m⎠ ⎠ \n A ⋅ e = threshold\n\n \n Amplitude calculated using \"Conservation of energy\"\n _________________\n ╱ 2 2\n ╱ m ⋅ v0 + k ⋅ x0 \n amplitude = ╱ ─────────────────\n ╲╱ k \n\n And replace mass with damping ratio which is provided: m = (c^2)/(4 * k * zeta^2) \n */\n const {\n stiffness: k,\n dampingRatio: zeta,\n restSpeedThreshold: threshold,\n duration,\n } = config;\n\n const durationForMass = (mass: number) => {\n 'worklet';\n const amplitude =\n (mass * v0 * v0 + k * x0 * x0) / (Math.exp(1 - 0.5 * zeta) * k);\n const c = zeta * 2 * Math.sqrt(k * mass);\n return (\n 1000 * ((-2 * mass) / c) * Math.log((threshold * 0.01) / amplitude) -\n duration\n );\n };\n\n // Bisection turns out to be much faster than Newton's method in our case\n return bisectRoot({ min: 0, max: 100, func: durationForMass });\n}\n\nexport function criticallyDampedSpringCalculations(\n animation: InnerSpringAnimation,\n precalculatedValues: {\n v0: number;\n x0: number;\n omega0: number;\n t: number;\n }\n): { position: number; velocity: number } {\n 'worklet';\n const { toValue } = animation;\n\n const { v0, x0, omega0, t } = precalculatedValues;\n\n const criticallyDampedEnvelope = Math.exp(-omega0 * t);\n const criticallyDampedPosition =\n toValue - criticallyDampedEnvelope * (x0 + (v0 + omega0 * x0) * t);\n\n const criticallyDampedVelocity =\n criticallyDampedEnvelope *\n (v0 * (t * omega0 - 1) + t * x0 * omega0 * omega0);\n\n return {\n position: criticallyDampedPosition,\n velocity: criticallyDampedVelocity,\n };\n}\n\nexport function underDampedSpringCalculations(\n animation: InnerSpringAnimation,\n precalculatedValues: {\n zeta: number;\n v0: number;\n x0: number;\n omega0: number;\n omega1: number;\n t: number;\n }\n): { position: number; velocity: number } {\n 'worklet';\n const { toValue, current, velocity } = animation;\n\n const { zeta, t, omega0, omega1 } = precalculatedValues;\n\n const v0 = -velocity;\n const x0 = toValue - current;\n\n const sin1 = Math.sin(omega1 * t);\n const cos1 = Math.cos(omega1 * t);\n\n // under damped\n const underDampedEnvelope = Math.exp(-zeta * omega0 * t);\n const underDampedFrag1 =\n underDampedEnvelope *\n (sin1 * ((v0 + zeta * omega0 * x0) / omega1) + x0 * cos1);\n\n const underDampedPosition = toValue - underDampedFrag1;\n // This looks crazy -- it's actually just the derivative of the oscillation function\n const underDampedVelocity =\n zeta * omega0 * underDampedFrag1 -\n underDampedEnvelope *\n (cos1 * (v0 + zeta * omega0 * x0) - omega1 * x0 * sin1);\n\n return { position: underDampedPosition, velocity: underDampedVelocity };\n}\n\nexport function isAnimationTerminatingCalculation(\n animation: InnerSpringAnimation,\n config: DefaultSpringConfig\n): {\n isOvershooting: boolean;\n isVelocity: boolean;\n isDisplacement: boolean;\n} {\n 'worklet';\n const { toValue, velocity, startValue, current } = animation;\n\n const isOvershooting = config.overshootClamping\n ? (current > toValue && startValue < toValue) ||\n (current < toValue && startValue > toValue)\n : false;\n\n const isVelocity = Math.abs(velocity) < config.restSpeedThreshold;\n const isDisplacement =\n Math.abs(toValue - current) < config.restDisplacementThreshold;\n\n return { isOvershooting, isVelocity, isDisplacement };\n}\n"],"mappings":"AAAA,YAAY;;AAQZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA;;AA8BA,OAAO,SAASA,oBAAoBA,CAACC,MAA2B,EAAW;EACzE,SAAS;;EACT,IAAIC,YAAY,GAAG,EAAE;EAEnB,CACE,WAAW,EACX,SAAS,EACT,cAAc,EACd,2BAA2B,EAC3B,oBAAoB,EACpB,MAAM,CACP,CACDC,OAAO,CAAEC,IAAI,IAAK;IAClB,MAAMC,KAAK,GAAGJ,MAAM,CAACG,IAAI,CAAC;IAC1B,IAAIC,KAAK,IAAI,CAAC,EAAE;MACdH,YAAY,IAAK,KAAIE,IAAK,qCAAoCC,KAAM,EAAC;IACvE;EACF,CAAC,CAAC;EAEF,IAAIJ,MAAM,CAACK,QAAQ,GAAG,CAAC,EAAE;IACvBJ,YAAY,IAAK,qCAAoCD,MAAM,CAACK,QAAS,EAAC;EACxE;EAEA,IAAIJ,YAAY,KAAK,EAAE,EAAE;IACvBK,OAAO,CAACC,IAAI,CAAC,oCAAoC,GAAGN,YAAY,CAAC;EACnE;EAEA,OAAOA,YAAY,KAAK,EAAE;AAC5B;AAEA,SAASO,UAAUA,CAAAC,IAAA,EAUhB;EACD,SAAS;;EAAC,IAXQ;IAClBC,GAAG;IACHC,GAAG;IACHC,I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KAAK;EAET,MAAMoB,UAAU,GAAGnD,IAAI,CAACC,GAAG,CAACoC,QAAQ,CAAC,GAAGtD,MAAM,CAACuC,kBAAkB;EACjE,MAAM8B,cAAc,GAClBpD,IAAI,CAACC,GAAG,CAAC8B,OAAO,GAAGhC,OAAO,CAAC,GAAGhB,MAAM,CAACsE,yBAAyB;EAEhE,OAAO;IAAEJ,cAAc;IAAEE,UAAU;IAAEC;EAAe,CAAC;AACvD"}
@@ -3,8 +3,26 @@
3
3
  import { Easing } from '../Easing';
4
4
  import { defineAnimation, getReduceMotionForAnimation } from './util';
5
5
 
6
+ /**
7
+ * The timing animation configuration.
8
+ *
9
+ * @param duration - Length of the animation (in milliseconds). Defaults to 300.
10
+ * @param easing - An easing function which defines the animation curve. Defaults to `Easing.inOut(Easing.quad)`.
11
+ * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.
12
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withTiming#config-
13
+ */
14
+
6
15
  // TODO TYPESCRIPT This is temporary type put in here to get rid of our .d.ts file
7
16
 
17
+ /**
18
+ * Lets you create an animation based on duration and easing.
19
+ *
20
+ * @param toValue - The value on which the animation will come at rest - {@link AnimatableValue}.
21
+ * @param config - The timing animation configuration - {@link TimingConfig}.
22
+ * @param callback - A function called on animation complete - {@link AnimationCallback}.
23
+ * @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.
24
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withTiming
25
+ */
8
26
  export const withTiming = function (toValue, userConfig, callback) {
9
27
  'worklet';
10
28
 
@@ -1 +1 @@
1
- {"version":3,"names":["Easing","defineAnimation","getReduceMotionForAnimation","withTiming","toValue","userConfig","callback","config","duration","easing","inOut","quad","Object","keys","forEach","key","timing","animation","now","startTime","startValue","runtime","current","progress","onStart","value","previousAnimation","type","factory","onFrame","reduceMotion"],"sources":["timing.ts"],"sourcesContent":["'use strict';\nimport type { EasingFunction, EasingFunctionFactory } from '../Easing';\nimport { Easing } from '../Easing';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n AnimationCallback,\n Timestamp,\n AnimatableValue,\n ReduceMotion,\n} from '../commonTypes';\n\ninterface TimingConfig {\n duration?: number;\n reduceMotion?: ReduceMotion;\n easing?: EasingFunction | EasingFunctionFactory;\n}\n\nexport type WithTimingConfig = TimingConfig;\n\nexport interface TimingAnimation extends Animation<TimingAnimation> {\n type: string;\n easing: EasingFunction;\n startValue: AnimatableValue;\n startTime: Timestamp;\n progress: number;\n toValue: AnimatableValue;\n current: AnimatableValue;\n}\n\ninterface InnerTimingAnimation\n extends Omit<TimingAnimation, 'toValue' | 'current'> {\n toValue: number;\n current: number;\n}\n\n// TODO TYPESCRIPT This is temporary type put in here to get rid of our .d.ts file\ntype withTimingType = <T extends AnimatableValue>(\n toValue: T,\n userConfig?: TimingConfig,\n callback?: AnimationCallback\n) => T;\n\nexport const withTiming = function (\n toValue: AnimatableValue,\n userConfig?: TimingConfig,\n callback?: AnimationCallback\n): Animation<TimingAnimation> {\n 'worklet';\n\n return defineAnimation<TimingAnimation>(toValue, () => {\n 'worklet';\n const config: Required<Omit<TimingConfig, 'reduceMotion'>> = {\n duration: 300,\n easing: Easing.inOut(Easing.quad),\n };\n if (userConfig) {\n Object.keys(userConfig).forEach(\n (key) =>\n ((config as any)[key] = userConfig[key as keyof typeof userConfig])\n );\n }\n\n function timing(animation: InnerTimingAnimation, now: Timestamp): boolean {\n const { toValue, startTime, startValue } = animation;\n const runtime = now - startTime;\n\n if (runtime >= config.duration) {\n // reset startTime to avoid reusing finished animation config in `start` method\n animation.startTime = 0;\n animation.current = toValue;\n return true;\n }\n const progress = animation.easing(runtime / config.duration);\n animation.current =\n (startValue as number) + (toValue - (startValue as number)) * progress;\n return false;\n }\n\n function onStart(\n animation: TimingAnimation,\n value: number,\n now: Timestamp,\n previousAnimation: Animation<TimingAnimation>\n ): void {\n if (\n previousAnimation &&\n (previousAnimation as TimingAnimation).type === 'timing' &&\n (previousAnimation as TimingAnimation).toValue === toValue &&\n (previousAnimation as TimingAnimation).startTime\n ) {\n // to maintain continuity of timing animations we check if we are starting\n // new timing over the old one with the same parameters. If so, we want\n // to copy animation timeline properties\n animation.startTime = (previousAnimation as TimingAnimation).startTime;\n animation.startValue = (\n previousAnimation as TimingAnimation\n ).startValue;\n } else {\n animation.startTime = now;\n animation.startValue = value;\n }\n animation.current = value;\n if (typeof config.easing === 'object') {\n animation.easing = config.easing.factory();\n } else {\n animation.easing = config.easing;\n }\n }\n\n return {\n type: 'timing',\n onFrame: timing,\n onStart: onStart as (animation: TimingAnimation, now: number) => boolean,\n progress: 0,\n toValue,\n startValue: 0,\n startTime: 0,\n easing: () => 0,\n current: toValue,\n callback,\n reduceMotion: getReduceMotionForAnimation(userConfig?.reduceMotion),\n } as TimingAnimation;\n });\n} as withTimingType;\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,MAAM,QAAQ,WAAW;AAClC,SAASC,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;;AAiCrE;;AAOA,OAAO,MAAMC,UAAU,GAAG,SAAAA,CACxBC,OAAwB,EACxBC,UAAyB,EACzBC,QAA4B,EACA;EAC5B,SAAS;;EAET,OAAOL,eAAe,CAAkBG,OAAO,EAAE,MAAM;IACrD,SAAS;;IACT,MAAMG,MAAoD,GAAG;MAC3DC,QAAQ,EAAE,GAAG;MACbC,MAAM,EAAET,MAAM,CAACU,KAAK,CAACV,MAAM,CAACW,IAAI;IAClC,CAAC;IACD,IAAIN,UAAU,EAAE;MACdO,MAAM,CAACC,IAAI,CAACR,UAAU,CAAC,CAACS,OAAO,CAC5BC,GAAG,IACAR,MAAM,CAASQ,GAAG,CAAC,GAAGV,UAAU,CAACU,GAAG,CAA6B,CACtE;IACH;IAEA,SAASC,MAAMA,CAACC,SAA+B,EAAEC,GAAc,EAAW;MACxE,MAAM;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AO,EAAEA,OAA+D;MACxED,QAAQ,EAAE,CAAC;MACXnB,OAAO;MACPgB,UAAU,EAAE,CAAC;MACbD,SAAS,EAAE,CAAC;MACZV,MAAM,EAAEA,CAAA,KAAM,CAAC;MACfa,OAAO,EAAElB,OAAO;MAChBE,QAAQ;MACRwB,YAAY,EAAE5B,2BAA2B,CAACG,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEyB,YAAY;IACpE,CAAC;EACH,CAAC,CAAC;AACJ,CAAmB"}
1
+ {"version":3,"names":["Easing","defineAnimation","getReduceMotionForAnimation","withTiming","toValue","userConfig","callback","config","duration","easing","inOut","quad","Object","keys","forEach","key","timing","animation","now","startTime","startValue","runtime","current","progress","onStart","value","previousAnimation","type","factory","onFrame","reduceMotion"],"sources":["timing.ts"],"sourcesContent":["'use strict';\nimport type { EasingFunction, EasingFunctionFactory } from '../Easing';\nimport { Easing } from '../Easing';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n AnimationCallback,\n Timestamp,\n AnimatableValue,\n ReduceMotion,\n} from '../commonTypes';\n\n/**\n * The timing animation configuration.\n *\n * @param duration - Length of the animation (in milliseconds). Defaults to 300.\n * @param easing - An easing function which defines the animation curve. Defaults to `Easing.inOut(Easing.quad)`.\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withTiming#config-\n */\ninterface TimingConfig {\n duration?: number;\n reduceMotion?: ReduceMotion;\n easing?: EasingFunction | EasingFunctionFactory;\n}\n\nexport type WithTimingConfig = TimingConfig;\n\nexport interface TimingAnimation extends Animation<TimingAnimation> {\n type: string;\n easing: EasingFunction;\n startValue: AnimatableValue;\n startTime: Timestamp;\n progress: number;\n toValue: AnimatableValue;\n current: AnimatableValue;\n}\n\ninterface InnerTimingAnimation\n extends Omit<TimingAnimation, 'toValue' | 'current'> {\n toValue: number;\n current: number;\n}\n\n// TODO TYPESCRIPT This is temporary type put in here to get rid of our .d.ts file\ntype withTimingType = <T extends AnimatableValue>(\n toValue: T,\n userConfig?: TimingConfig,\n callback?: AnimationCallback\n) => T;\n\n/**\n * Lets you create an animation based on duration and easing.\n *\n * @param toValue - The value on which the animation will come at rest - {@link AnimatableValue}.\n * @param config - The timing animation configuration - {@link TimingConfig}.\n * @param callback - A function called on animation complete - {@link AnimationCallback}.\n * @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withTiming\n */\nexport const withTiming = function (\n toValue: AnimatableValue,\n userConfig?: TimingConfig,\n callback?: AnimationCallback\n): Animation<TimingAnimation> {\n 'worklet';\n\n return defineAnimation<TimingAnimation>(toValue, () => {\n 'worklet';\n const config: Required<Omit<TimingConfig, 'reduceMotion'>> = {\n duration: 300,\n easing: Easing.inOut(Easing.quad),\n };\n if (userConfig) {\n Object.keys(userConfig).forEach(\n (key) =>\n ((config as any)[key] = userConfig[key as keyof typeof userConfig])\n );\n }\n\n function timing(animation: InnerTimingAnimation, now: Timestamp): boolean {\n const { toValue, startTime, startValue } = animation;\n const runtime = now - startTime;\n\n if (runtime >= config.duration) {\n // reset startTime to avoid reusing finished animation config in `start` method\n animation.startTime = 0;\n animation.current = toValue;\n return true;\n }\n const progress = animation.easing(runtime / config.duration);\n animation.current =\n (startValue as number) + (toValue - (startValue as number)) * progress;\n return false;\n }\n\n function onStart(\n animation: TimingAnimation,\n value: number,\n now: Timestamp,\n previousAnimation: Animation<TimingAnimation>\n ): void {\n if (\n previousAnimation &&\n (previousAnimation as TimingAnimation).type === 'timing' &&\n (previousAnimation as TimingAnimation).toValue === toValue &&\n (previousAnimation as TimingAnimation).startTime\n ) {\n // to maintain continuity of timing animations we check if we are starting\n // new timing over the old one with the same parameters. If so, we want\n // to copy animation timeline properties\n animation.startTime = (previousAnimation as TimingAnimation).startTime;\n animation.startValue = (\n previousAnimation as TimingAnimation\n ).startValue;\n } else {\n animation.startTime = now;\n animation.startValue = value;\n }\n animation.current = value;\n if (typeof config.easing === 'object') {\n animation.easing = config.easing.factory();\n } else {\n animation.easing = config.easing;\n }\n }\n\n return {\n type: 'timing',\n onFrame: timing,\n onStart: onStart as (animation: TimingAnimation, now: number) => boolean,\n progress: 0,\n toValue,\n startValue: 0,\n startTime: 0,\n easing: () => 0,\n current: toValue,\n callback,\n reduceMotion: getReduceMotionForAnimation(userConfig?.reduceMotion),\n } as TimingAnimation;\n });\n} as withTimingType;\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,MAAM,QAAQ,WAAW;AAClC,SAASC,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;;AASrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAG,SAAAA,CACxBC,OAAwB,EACxBC,UAAyB,EACzBC,QAA4B,EACA;EAC5B,SAAS;;EAET,OAAOL,eAAe,CAAkBG,OAAO,EAAE,MAAM;IACrD,SAAS;;IACT,MAAMG,MAAoD,GAAG;MAC3DC,QAAQ,EAAE,GAAG;MACbC,MAAM,EAAET,MAAM,CAACU,KAAK,CAACV,MAAM,CAACW,IAAI;IAClC,CAAC;IACD,IAAIN,UAAU,EAAE;MACdO,MAAM,CAACC,IAAI,CAACR,UAAU,CAAC,CAACS,OAAO,CAC5BC,GAAG,IACAR,MAAM,CAASQ,GAAG,CAAC,GAAGV,UAAU,CAACU,GAAG,CAA6B,CACtE;IACH;IAEA,SAASC,MAAMA,CAACC,SAA+B,EAAEC,GAAc,EAAW;MACxE,MAAM;QAAEd,OAAO;QAAEe,SAAS;QAAEC;MAAW,CAAC,GAAGH,SAAS;MACpD,MAAMI,OAAO,GAAGH,GAAG,GAAGC,SAAS;MAE/B,IAAIE,OAAO,IAAId,MAAM,CAACC,QAAQ,EAAE;QAC9B;Q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AO;MAChBE,QAAQ;MACRwB,YAAY,EAAE5B,2BAA2B,CAACG,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEyB,YAAY;IACpE,CAAC;EACH,CAAC,CAAC;AACJ,CAAmB"}
@@ -298,6 +298,13 @@ export function defineAnimation(starting, factory) {
298
298
  // @ts-ignore: eslint-disable-line
299
299
  return create;
300
300
  }
301
+
302
+ /**
303
+ * Lets you cancel a running animation paired to a shared value.
304
+ *
305
+ * @param sharedValue - The shared value of a running animation that you want to cancel.
306
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/core/cancelAnimation
307
+ */
301
308
  export function cancelAnimation(sharedValue) {
302
309
  'worklet';
303
310
 
@@ -1 +1 @@
1
- {"version":3,"names":["isColor","convertToRGBA","rgbaArrayToRGBAColor","toGammaSpace","toLinearSpace","ReduceMotion","flatten","multiplyMatrices","scaleMatrix","addMatrices","decomposeMatrixIntoMatricesAndAngles","isAffineMatrixFlat","subtractMatrices","getRotationMatrix","isReducedMotion","shouldBeUseWeb","IN_STYLE_UPDATER","IS_REDUCED_MOTION","initialUpdaterRun","updater","result","recognizePrefixSuffix","value","match","Error","prefix","suffix","number","strippedValue","parseFloat","getReduceMotionFromConfig","config","System","Always","getReduceMotionForAnimation","undefined","applyProgressToMatrix","progress","a","b","applyProgressToNumber","decorateAnimation","animation","baseOnStart","onStart","baseOnFrame","onFrame","isHigherOrder","timestamp","previousAnimation","reduceMotion","animationCopy","Object","assign","callback","prefNumberSuffOnStart","__prefix","__suffix","strippedCurrent","strippedToValue","toValue","current","startValue","paPrefix","paSuffix","paStrippedValue","prefNumberSuffOnFrame","res","tab","colorOnStart","RGBAValue","RGBACurrent","RGBAToValue","forEach","i","index","push","colorOnFrame","finished","transformationMatrixOnStart","startMatrices","stopMatrices","transformationMatrixOnFrame","transforms","mappedTransforms","key","_","currentTranslation","currentScale","skewMatrix","rotations","mappedRotations","angle","rotationMatrixX","rotationMatrixY","rotationMatrixZ","rotationMatrix","updated","arrayOnStart","v","arrayOnFrame","objectOnStart","objectOnFrame","newObject","startTime","Array","isArray","SHOULD_BE_USE_WEB","defineAnimation","starting","factory","create","_WORKLET","cancelAnimation","sharedValue"],"sources":["util.ts"],"sourcesContent":["'use strict';\nimport type { HigherOrderAnimation, StyleLayoutAnimation } from './commonTypes';\nimport type { ParsedColorArray } from '../Colors';\nimport {\n isColor,\n convertToRGBA,\n rgbaArrayToRGBAColor,\n toGammaSpace,\n toLinearSpace,\n} from '../Colors';\nimport { ReduceMotion } from '../commonTypes';\nimport type {\n SharedValue,\n AnimatableValue,\n Animation,\n AnimationObject,\n Timestamp,\n AnimatableValueObject,\n} from '../commonTypes';\nimport type {\n AffineMatrixFlat,\n AffineMatrix,\n} from './transformationMatrix/matrixUtils';\nimport {\n flatten,\n multiplyMatrices,\n scaleMatrix,\n addMatrices,\n decomposeMatrixIntoMatricesAndAngles,\n isAffineMatrixFlat,\n subtractMatrices,\n getRotationMatrix,\n} from './transformationMatrix/matrixUtils';\nimport { isReducedMotion, shouldBeUseWeb } from '../PlatformChecker';\n\nlet IN_STYLE_UPDATER = false;\nconst IS_REDUCED_MOTION = isReducedMotion();\n\nexport function initialUpdaterRun<T>(updater: () => T) {\n IN_STYLE_UPDATER = true;\n const result = updater();\n IN_STYLE_UPDATER = false;\n return result;\n}\n\ninterface RecognizedPrefixSuffix {\n prefix?: string;\n suffix?: string;\n strippedValue: number;\n}\n\nexport function recognizePrefixSuffix(\n value: string | number\n): RecognizedPrefixSuffix {\n 'worklet';\n if (typeof value === 'string') {\n const match = value.match(\n /([A-Za-z]*)(-?\\d*\\.?\\d*)([eE][-+]?[0-9]+)?([A-Za-z%]*)/\n );\n if (!match) {\n throw new Error(\"[Reanimated] Couldn't parse animation value.\");\n }\n const prefix = match[1];\n const suffix = match[4];\n // number with scientific notation\n const number = match[2] + (match[3] ?? '');\n return { prefix, suffix, strippedValue: parseFloat(number) };\n } else {\n return { strippedValue: value };\n }\n}\n\n/**\n * Returns whether the motion should be reduced for a specified config.\n * By default returns the system setting.\n */\nexport function getReduceMotionFromConfig(config?: ReduceMotion) {\n 'worklet';\n return !config || config === ReduceMotion.System\n ? IS_REDUCED_MOTION\n : config === ReduceMotion.Always;\n}\n\n/**\n * Returns the value that should be assigned to `animation.reduceMotion`\n * for a given config. If the config is not defined, `undefined` is returned.\n */\nexport function getReduceMotionForAnimation(config?: ReduceMotion) {\n 'worklet';\n // if the config is not defined, we want `reduceMotion` to be undefined,\n // so the parent animation knows if it should overwrite it\n if (!config) {\n return undefined;\n }\n\n return getReduceMotionFromConfig(config);\n}\n\nfunction applyProgressToMatrix(\n progress: number,\n a: AffineMatrix,\n b: AffineMatrix\n) {\n 'worklet';\n return addMatrices(a, scaleMatrix(subtractMatrices(b, a), progress));\n}\n\nfunction applyProgressToNumber(progress: number, a: number, b: number) {\n 'worklet';\n return a + progress * (b - a);\n}\n\nfunction decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(\n animation: T\n): void {\n 'worklet';\n const baseOnStart = (animation as Animation<AnimationObject>).onStart;\n const baseOnFrame = (animation as Animation<AnimationObject>).onFrame;\n\n if ((animation as HigherOrderAnimation).isHigherOrder) {\n animation.onStart = (\n animation: Animation<AnimationObject>,\n value: number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ) => {\n if (animation.reduceMotion === undefined) {\n animation.reduceMotion = getReduceMotionFromConfig();\n }\n return baseOnStart(animation, value, timestamp, previousAnimation);\n };\n return;\n }\n\n const animationCopy = Object.assign({}, animation);\n delete animationCopy.callback;\n\n const prefNumberSuffOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: number,\n previousAnimation: Animation<AnimationObject>\n ) => {\n // recognize prefix, suffix, and updates stripped value on animation start\n const { prefix, suffix, strippedValue } = recognizePrefixSuffix(value);\n animation.__prefix = prefix;\n animation.__suffix = suffix;\n animation.strippedCurrent = strippedValue;\n const { strippedValue: strippedToValue } = recognizePrefixSuffix(\n animation.toValue as string | number\n );\n animation.current = strippedValue;\n animation.startValue = strippedValue;\n animation.toValue = strippedToValue;\n if (previousAnimation && previousAnimation !== animation) {\n const {\n prefix: paPrefix,\n suffix: paSuffix,\n strippedValue: paStrippedValue,\n } = recognizePrefixSuffix(previousAnimation.current as string | number);\n previousAnimation.current = paStrippedValue;\n previousAnimation.__prefix = paPrefix;\n previousAnimation.__suffix = paSuffix;\n }\n\n baseOnStart(animation, strippedValue, timestamp, previousAnimation);\n\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n\n if (previousAnimation && previousAnimation !== animation) {\n previousAnimation.current =\n (previousAnimation.__prefix ?? '') +\n previousAnimation.current +\n (previousAnimation.__suffix ?? '');\n }\n };\n const prefNumberSuffOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: number\n ) => {\n animation.current = animation.strippedCurrent;\n const res = baseOnFrame(animation, timestamp);\n animation.strippedCurrent = animation.current;\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n return res;\n };\n\n const tab = ['R', 'G', 'B', 'A'];\n const colorOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n let RGBAValue: ParsedColorArray;\n let RGBACurrent: ParsedColorArray;\n let RGBAToValue: ParsedColorArray;\n const res: Array<number> = [];\n if (isColor(value)) {\n RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n RGBAValue = toLinearSpace(convertToRGBA(value));\n if (animation.toValue) {\n RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));\n }\n }\n tab.forEach((i, index) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = RGBACurrent[index];\n animation[i].toValue = RGBAToValue ? RGBAToValue[index] : undefined;\n animation[i].onStart(\n animation[i],\n RGBAValue[index],\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n };\n\n const colorOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n const res: Array<number> = [];\n let finished = true;\n tab.forEach((i, index) => {\n animation[i].current = RGBACurrent[index];\n const result = animation[i].onFrame(animation[i], timestamp);\n // We really need to assign this value to result, instead of passing it directly - otherwise once \"finished\" is false, onFrame won't be called\n finished = finished && result;\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n return finished;\n };\n\n const transformationMatrixOnStart = (\n animation: Animation<AnimationObject>,\n value: AffineMatrixFlat,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n const toValue = animation.toValue as AffineMatrixFlat;\n\n animation.startMatrices = decomposeMatrixIntoMatricesAndAngles(value);\n animation.stopMatrices = decomposeMatrixIntoMatricesAndAngles(toValue);\n\n // We create an animation copy to animate single value between 0 and 100\n // We set limits from 0 to 100 (instead of 0-1) to make spring look good\n // with default thresholds.\n\n animation[0] = Object.assign({}, animationCopy);\n animation[0].current = 0;\n animation[0].toValue = 100;\n animation[0].onStart(\n animation[0],\n 0,\n timestamp,\n previousAnimation ? previousAnimation[0] : undefined\n );\n\n animation.current = value;\n };\n\n const transformationMatrixOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n let finished = true;\n const result = animation[0].onFrame(animation[0], timestamp);\n // We really need to assign this value to result, instead of passing it directly - otherwise once \"finished\" is false, onFrame won't be called\n finished = finished && result;\n\n const progress = animation[0].current / 100;\n\n const transforms = ['translationMatrix', 'scaleMatrix', 'skewMatrix'];\n const mappedTransforms: Array<AffineMatrix> = [];\n\n transforms.forEach((key, _) =>\n mappedTransforms.push(\n applyProgressToMatrix(\n progress,\n animation.startMatrices[key],\n animation.stopMatrices[key]\n )\n )\n );\n\n const [currentTranslation, currentScale, skewMatrix] = mappedTransforms;\n\n const rotations: Array<'x' | 'y' | 'z'> = ['x', 'y', 'z'];\n const mappedRotations: Array<AffineMatrix> = [];\n\n rotations.forEach((key, _) => {\n const angle = applyProgressToNumber(\n progress,\n animation.startMatrices['r' + key],\n animation.stopMatrices['r' + key]\n );\n mappedRotations.push(getRotationMatrix(angle, key));\n });\n\n const [rotationMatrixX, rotationMatrixY, rotationMatrixZ] = mappedRotations;\n\n const rotationMatrix = multiplyMatrices(\n rotationMatrixX,\n multiplyMatrices(rotationMatrixY, rotationMatrixZ)\n );\n\n const updated = flatten(\n multiplyMatrices(\n multiplyMatrices(\n currentScale,\n multiplyMatrices(skewMatrix, rotationMatrix)\n ),\n currentTranslation\n )\n );\n\n animation.current = updated;\n\n return finished;\n };\n\n const arrayOnStart = (\n animation: Animation<AnimationObject>,\n value: Array<number>,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n value.forEach((v, i) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = v;\n animation[i].toValue = (animation.toValue as Array<number>)[i];\n animation[i].onStart(\n animation[i],\n v,\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n });\n\n animation.current = value;\n };\n\n const arrayOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n let finished = true;\n (animation.current as Array<number>).forEach((_, i) => {\n const result = animation[i].onFrame(animation[i], timestamp);\n // We really need to assign this value to result, instead of passing it directly - otherwise once \"finished\" is false, onFrame won't be called\n finished = finished && result;\n (animation.current as Array<number>)[i] = animation[i].current;\n });\n\n return finished;\n };\n\n const objectOnStart = (\n animation: Animation<AnimationObject>,\n value: AnimatableValueObject,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n for (const key in value) {\n animation[key] = Object.assign({}, animationCopy);\n animation[key].onStart = animation.onStart;\n\n animation[key].current = value[key];\n animation[key].toValue = (animation.toValue as AnimatableValueObject)[\n key\n ];\n animation[key].onStart(\n animation[key],\n value[key],\n timestamp,\n previousAnimation ? previousAnimation[key] : undefined\n );\n }\n animation.current = value;\n };\n\n const objectOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n let finished = true;\n const newObject: AnimatableValueObject = {};\n for (const key in animation.current as AnimatableValueObject) {\n const result = animation[key].onFrame(animation[key], timestamp);\n // We really need to assign this value to result, instead of passing it directly - otherwise once \"finished\" is false, onFrame won't be called\n finished = finished && result;\n newObject[key] = animation[key].current;\n }\n animation.current = newObject;\n return finished;\n };\n\n animation.onStart = (\n animation: Animation<AnimationObject>,\n value: number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ) => {\n if (animation.reduceMotion === undefined) {\n animation.reduceMotion = getReduceMotionFromConfig();\n }\n if (animation.reduceMotion) {\n if (animation.toValue !== undefined) {\n animation.current = animation.toValue;\n } else {\n // if there is no `toValue`, then the base function is responsible for setting the current value\n baseOnStart(animation, value, timestamp, previousAnimation);\n }\n animation.startTime = 0;\n animation.onFrame = () => true;\n return;\n }\n if (isColor(value)) {\n colorOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = colorOnFrame;\n return;\n } else if (isAffineMatrixFlat(value)) {\n transformationMatrixOnStart(\n animation,\n value,\n timestamp,\n previousAnimation\n );\n animation.onFrame = transformationMatrixOnFrame;\n return;\n } else if (Array.isArray(value)) {\n arrayOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = arrayOnFrame;\n return;\n } else if (typeof value === 'string') {\n prefNumberSuffOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = prefNumberSuffOnFrame;\n return;\n } else if (typeof value === 'object' && value !== null) {\n objectOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = objectOnFrame;\n return;\n }\n baseOnStart(animation, value, timestamp, previousAnimation);\n };\n}\n\ntype AnimationToDecoration<\n T extends AnimationObject | StyleLayoutAnimation,\n U extends AnimationObject | StyleLayoutAnimation\n> = T extends StyleLayoutAnimation\n ? Record<string, unknown>\n : U | (() => U) | AnimatableValue;\n\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\nexport function defineAnimation<\n T extends AnimationObject | StyleLayoutAnimation, // type that's supposed to be returned\n U extends AnimationObject | StyleLayoutAnimation = T // type that's received\n>(starting: AnimationToDecoration<T, U>, factory: () => T): T {\n 'worklet';\n if (IN_STYLE_UPDATER) {\n return starting as unknown as T;\n }\n const create = () => {\n 'worklet';\n const animation = factory();\n decorateAnimation<U>(animation as unknown as U);\n return animation;\n };\n\n if (_WORKLET || SHOULD_BE_USE_WEB) {\n return create();\n }\n // @ts-ignore: eslint-disable-line\n return create;\n}\n\nexport function cancelAnimation<T>(sharedValue: SharedValue<T>): void {\n 'worklet';\n // setting the current value cancels the animation if one is currently running\n sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign\n}\n"],"mappings":"AAAA,YAAY;;AAGZ,SACEA,OAAO,EACPC,aAAa,EACbC,oBAAoB,EACpBC,YAAY,EACZC,aAAa,QACR,WAAW;AAClB,SAASC,YAAY,QAAQ,gBAAgB;AAa7C,SACEC,OAAO,EACPC,gBAAgB,EAChBC,WAAW,EACXC,WAAW,EACXC,oCAAoC,EACpCC,kBAAkB,EAClBC,gBAAgB,EAChBC,iBAAiB,QACZ,oCAAoC;AAC3C,SAASC,eAAe,EAAEC,cAAc,QAAQ,oBAAoB;AAEpE,IAAIC,gBAAgB,GAAG,KAAK;AAC5B,MAAMC,iBAAiB,GAAGH,eAAe,EAAE;AAE3C,OAAO,SAASI,iBAAiBA,CAAIC,OAAgB,EAAE;EACrDH,gBAAgB,GAAG,IAAI;EACvB,MAAMI,MAAM,GAAGD,OAAO,EAAE;EACxBH,gBAAgB,GAAG,KAAK;EACxB,OAAOI,MAAM;AACf;AAQA,OAAO,SAASC,qBAAqBA,CACnCC,KAAsB,EACE;EACxB,SAAS;;EACT,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,MAAMC,KAAK,GAAGD,KAAK,CAACC,KAAK,CACvB,wDAA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AAIsE,QAAQ,IAAIL,iBAAiB,EAAE;IACjC,OAAOI,MAAM,EAAE;EACjB;EACA;EACA,OAAOA,MAAM;AACf;AAEA,OAAO,SAASE,eAAeA,CAAIC,WAA2B,EAAQ;EACpE,SAAS;;EACT;EACAA,WAAW,CAAC5F,KAAK,GAAG4F,WAAW,CAAC5F,KAAK,CAAC,CAAC;AACzC"}
1
+ {"version":3,"names":["isColor","convertToRGBA","rgbaArrayToRGBAColor","toGammaSpace","toLinearSpace","ReduceMotion","flatten","multiplyMatrices","scaleMatrix","addMatrices","decomposeMatrixIntoMatricesAndAngles","isAffineMatrixFlat","subtractMatrices","getRotationMatrix","isReducedMotion","shouldBeUseWeb","IN_STYLE_UPDATER","IS_REDUCED_MOTION","initialUpdaterRun","updater","result","recognizePrefixSuffix","value","match","Error","prefix","suffix","number","strippedValue","parseFloat","getReduceMotionFromConfig","config","System","Always","getReduceMotionForAnimation","undefined","applyProgressToMatrix","progress","a","b","applyProgressToNumber","decorateAnimation","animation","baseOnStart","onStart","baseOnFrame","onFrame","isHigherOrder","timestamp","previousAnimation","reduceMotion","animationCopy","Object","assign","callback","prefNumberSuffOnStart","__prefix","__suffix","strippedCurrent","strippedToValue","toValue","current","startValue","paPrefix","paSuffix","paStrippedValue","prefNumberSuffOnFrame","res","tab","colorOnStart","RGBAValue","RGBACurrent","RGBAToValue","forEach","i","index","push","colorOnFrame","finished","transformationMatrixOnStart","startMatrices","stopMatrices","transformationMatrixOnFrame","transforms","mappedTransforms","key","_","currentTranslation","currentScale","skewMatrix","rotations","mappedRotations","angle","rotationMatrixX","rotationMatrixY","rotationMatrixZ","rotationMatrix","updated","arrayOnStart","v","arrayOnFrame","objectOnStart","objectOnFrame","newObject","startTime","Array","isArray","SHOULD_BE_USE_WEB","defineAnimation","starting","factory","create","_WORKLET","cancelAnimation","sharedValue"],"sources":["util.ts"],"sourcesContent":["'use strict';\nimport type { HigherOrderAnimation, StyleLayoutAnimation } from './commonTypes';\nimport type { ParsedColorArray } from '../Colors';\nimport {\n isColor,\n convertToRGBA,\n rgbaArrayToRGBAColor,\n toGammaSpace,\n toLinearSpace,\n} from '../Colors';\nimport { ReduceMotion } from '../commonTypes';\nimport type {\n SharedValue,\n AnimatableValue,\n Animation,\n AnimationObject,\n Timestamp,\n AnimatableValueObject,\n} from '../commonTypes';\nimport type {\n AffineMatrixFlat,\n AffineMatrix,\n} from './transformationMatrix/matrixUtils';\nimport {\n flatten,\n multiplyMatrices,\n scaleMatrix,\n addMatrices,\n decomposeMatrixIntoMatricesAndAngles,\n isAffineMatrixFlat,\n subtractMatrices,\n getRotationMatrix,\n} from './transformationMatrix/matrixUtils';\nimport { isReducedMotion, shouldBeUseWeb } from '../PlatformChecker';\n\nlet IN_STYLE_UPDATER = false;\nconst IS_REDUCED_MOTION = isReducedMotion();\n\nexport function initialUpdaterRun<T>(updater: () => T) {\n IN_STYLE_UPDATER = true;\n const result = updater();\n IN_STYLE_UPDATER = false;\n return result;\n}\n\ninterface RecognizedPrefixSuffix {\n prefix?: string;\n suffix?: string;\n strippedValue: number;\n}\n\nexport function recognizePrefixSuffix(\n value: string | number\n): RecognizedPrefixSuffix {\n 'worklet';\n if (typeof value === 'string') {\n const match = value.match(\n /([A-Za-z]*)(-?\\d*\\.?\\d*)([eE][-+]?[0-9]+)?([A-Za-z%]*)/\n );\n if (!match) {\n throw new Error(\"[Reanimated] Couldn't parse animation value.\");\n }\n const prefix = match[1];\n const suffix = match[4];\n // number with scientific notation\n const number = match[2] + (match[3] ?? '');\n return { prefix, suffix, strippedValue: parseFloat(number) };\n } else {\n return { strippedValue: value };\n }\n}\n\n/**\n * Returns whether the motion should be reduced for a specified config.\n * By default returns the system setting.\n */\nexport function getReduceMotionFromConfig(config?: ReduceMotion) {\n 'worklet';\n return !config || config === ReduceMotion.System\n ? IS_REDUCED_MOTION\n : config === ReduceMotion.Always;\n}\n\n/**\n * Returns the value that should be assigned to `animation.reduceMotion`\n * for a given config. If the config is not defined, `undefined` is returned.\n */\nexport function getReduceMotionForAnimation(config?: ReduceMotion) {\n 'worklet';\n // if the config is not defined, we want `reduceMotion` to be undefined,\n // so the parent animation knows if it should overwrite it\n if (!config) {\n return undefined;\n }\n\n return getReduceMotionFromConfig(config);\n}\n\nfunction applyProgressToMatrix(\n progress: number,\n a: AffineMatrix,\n b: AffineMatrix\n) {\n 'worklet';\n return addMatrices(a, scaleMatrix(subtractMatrices(b, a), progress));\n}\n\nfunction applyProgressToNumber(progress: number, a: number, b: number) {\n 'worklet';\n return a + progress * (b - a);\n}\n\nfunction decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(\n animation: T\n): void {\n 'worklet';\n const baseOnStart = (animation as Animation<AnimationObject>).onStart;\n const baseOnFrame = (animation as Animation<AnimationObject>).onFrame;\n\n if ((animation as HigherOrderAnimation).isHigherOrder) {\n animation.onStart = (\n animation: Animation<AnimationObject>,\n value: number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ) => {\n if (animation.reduceMotion === undefined) {\n animation.reduceMotion = getReduceMotionFromConfig();\n }\n return baseOnStart(animation, value, timestamp, previousAnimation);\n };\n return;\n }\n\n const animationCopy = Object.assign({}, animation);\n delete animationCopy.callback;\n\n const prefNumberSuffOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: number,\n previousAnimation: Animation<AnimationObject>\n ) => {\n // recognize prefix, suffix, and updates stripped value on animation start\n const { prefix, suffix, strippedValue } = recognizePrefixSuffix(value);\n animation.__prefix = prefix;\n animation.__suffix = suffix;\n animation.strippedCurrent = strippedValue;\n const { strippedValue: strippedToValue } = recognizePrefixSuffix(\n animation.toValue as string | number\n );\n animation.current = strippedValue;\n animation.startValue = strippedValue;\n animation.toValue = strippedToValue;\n if (previousAnimation && previousAnimation !== animation) {\n const {\n prefix: paPrefix,\n suffix: paSuffix,\n strippedValue: paStrippedValue,\n } = recognizePrefixSuffix(previousAnimation.current as string | number);\n previousAnimation.current = paStrippedValue;\n previousAnimation.__prefix = paPrefix;\n previousAnimation.__suffix = paSuffix;\n }\n\n baseOnStart(animation, strippedValue, timestamp, previousAnimation);\n\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n\n if (previousAnimation && previousAnimation !== animation) {\n previousAnimation.current =\n (previousAnimation.__prefix ?? '') +\n previousAnimation.current +\n (previousAnimation.__suffix ?? '');\n }\n };\n const prefNumberSuffOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: number\n ) => {\n animation.current = animation.strippedCurrent;\n const res = baseOnFrame(animation, timestamp);\n animation.strippedCurrent = animation.current;\n animation.current =\n (animation.__prefix ?? '') +\n animation.current +\n (animation.__suffix ?? '');\n return res;\n };\n\n const tab = ['R', 'G', 'B', 'A'];\n const colorOnStart = (\n animation: Animation<AnimationObject>,\n value: string | number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n let RGBAValue: ParsedColorArray;\n let RGBACurrent: ParsedColorArray;\n let RGBAToValue: ParsedColorArray;\n const res: Array<number> = [];\n if (isColor(value)) {\n RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n RGBAValue = toLinearSpace(convertToRGBA(value));\n if (animation.toValue) {\n RGBAToValue = toLinearSpace(convertToRGBA(animation.toValue));\n }\n }\n tab.forEach((i, index) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = RGBACurrent[index];\n animation[i].toValue = RGBAToValue ? RGBAToValue[index] : undefined;\n animation[i].onStart(\n animation[i],\n RGBAValue[index],\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n };\n\n const colorOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));\n const res: Array<number> = [];\n let finished = true;\n tab.forEach((i, index) => {\n animation[i].current = RGBACurrent[index];\n const result = animation[i].onFrame(animation[i], timestamp);\n // We really need to assign this value to result, instead of passing it directly - otherwise once \"finished\" is false, onFrame won't be called\n finished = finished && result;\n res.push(animation[i].current);\n });\n\n animation.current = rgbaArrayToRGBAColor(\n toGammaSpace(res as ParsedColorArray)\n );\n return finished;\n };\n\n const transformationMatrixOnStart = (\n animation: Animation<AnimationObject>,\n value: AffineMatrixFlat,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n const toValue = animation.toValue as AffineMatrixFlat;\n\n animation.startMatrices = decomposeMatrixIntoMatricesAndAngles(value);\n animation.stopMatrices = decomposeMatrixIntoMatricesAndAngles(toValue);\n\n // We create an animation copy to animate single value between 0 and 100\n // We set limits from 0 to 100 (instead of 0-1) to make spring look good\n // with default thresholds.\n\n animation[0] = Object.assign({}, animationCopy);\n animation[0].current = 0;\n animation[0].toValue = 100;\n animation[0].onStart(\n animation[0],\n 0,\n timestamp,\n previousAnimation ? previousAnimation[0] : undefined\n );\n\n animation.current = value;\n };\n\n const transformationMatrixOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n let finished = true;\n const result = animation[0].onFrame(animation[0], timestamp);\n // We really need to assign this value to result, instead of passing it directly - otherwise once \"finished\" is false, onFrame won't be called\n finished = finished && result;\n\n const progress = animation[0].current / 100;\n\n const transforms = ['translationMatrix', 'scaleMatrix', 'skewMatrix'];\n const mappedTransforms: Array<AffineMatrix> = [];\n\n transforms.forEach((key, _) =>\n mappedTransforms.push(\n applyProgressToMatrix(\n progress,\n animation.startMatrices[key],\n animation.stopMatrices[key]\n )\n )\n );\n\n const [currentTranslation, currentScale, skewMatrix] = mappedTransforms;\n\n const rotations: Array<'x' | 'y' | 'z'> = ['x', 'y', 'z'];\n const mappedRotations: Array<AffineMatrix> = [];\n\n rotations.forEach((key, _) => {\n const angle = applyProgressToNumber(\n progress,\n animation.startMatrices['r' + key],\n animation.stopMatrices['r' + key]\n );\n mappedRotations.push(getRotationMatrix(angle, key));\n });\n\n const [rotationMatrixX, rotationMatrixY, rotationMatrixZ] = mappedRotations;\n\n const rotationMatrix = multiplyMatrices(\n rotationMatrixX,\n multiplyMatrices(rotationMatrixY, rotationMatrixZ)\n );\n\n const updated = flatten(\n multiplyMatrices(\n multiplyMatrices(\n currentScale,\n multiplyMatrices(skewMatrix, rotationMatrix)\n ),\n currentTranslation\n )\n );\n\n animation.current = updated;\n\n return finished;\n };\n\n const arrayOnStart = (\n animation: Animation<AnimationObject>,\n value: Array<number>,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n value.forEach((v, i) => {\n animation[i] = Object.assign({}, animationCopy);\n animation[i].current = v;\n animation[i].toValue = (animation.toValue as Array<number>)[i];\n animation[i].onStart(\n animation[i],\n v,\n timestamp,\n previousAnimation ? previousAnimation[i] : undefined\n );\n });\n\n animation.current = value;\n };\n\n const arrayOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n let finished = true;\n (animation.current as Array<number>).forEach((_, i) => {\n const result = animation[i].onFrame(animation[i], timestamp);\n // We really need to assign this value to result, instead of passing it directly - otherwise once \"finished\" is false, onFrame won't be called\n finished = finished && result;\n (animation.current as Array<number>)[i] = animation[i].current;\n });\n\n return finished;\n };\n\n const objectOnStart = (\n animation: Animation<AnimationObject>,\n value: AnimatableValueObject,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ): void => {\n for (const key in value) {\n animation[key] = Object.assign({}, animationCopy);\n animation[key].onStart = animation.onStart;\n\n animation[key].current = value[key];\n animation[key].toValue = (animation.toValue as AnimatableValueObject)[\n key\n ];\n animation[key].onStart(\n animation[key],\n value[key],\n timestamp,\n previousAnimation ? previousAnimation[key] : undefined\n );\n }\n animation.current = value;\n };\n\n const objectOnFrame = (\n animation: Animation<AnimationObject>,\n timestamp: Timestamp\n ): boolean => {\n let finished = true;\n const newObject: AnimatableValueObject = {};\n for (const key in animation.current as AnimatableValueObject) {\n const result = animation[key].onFrame(animation[key], timestamp);\n // We really need to assign this value to result, instead of passing it directly - otherwise once \"finished\" is false, onFrame won't be called\n finished = finished && result;\n newObject[key] = animation[key].current;\n }\n animation.current = newObject;\n return finished;\n };\n\n animation.onStart = (\n animation: Animation<AnimationObject>,\n value: number,\n timestamp: Timestamp,\n previousAnimation: Animation<AnimationObject>\n ) => {\n if (animation.reduceMotion === undefined) {\n animation.reduceMotion = getReduceMotionFromConfig();\n }\n if (animation.reduceMotion) {\n if (animation.toValue !== undefined) {\n animation.current = animation.toValue;\n } else {\n // if there is no `toValue`, then the base function is responsible for setting the current value\n baseOnStart(animation, value, timestamp, previousAnimation);\n }\n animation.startTime = 0;\n animation.onFrame = () => true;\n return;\n }\n if (isColor(value)) {\n colorOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = colorOnFrame;\n return;\n } else if (isAffineMatrixFlat(value)) {\n transformationMatrixOnStart(\n animation,\n value,\n timestamp,\n previousAnimation\n );\n animation.onFrame = transformationMatrixOnFrame;\n return;\n } else if (Array.isArray(value)) {\n arrayOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = arrayOnFrame;\n return;\n } else if (typeof value === 'string') {\n prefNumberSuffOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = prefNumberSuffOnFrame;\n return;\n } else if (typeof value === 'object' && value !== null) {\n objectOnStart(animation, value, timestamp, previousAnimation);\n animation.onFrame = objectOnFrame;\n return;\n }\n baseOnStart(animation, value, timestamp, previousAnimation);\n };\n}\n\ntype AnimationToDecoration<\n T extends AnimationObject | StyleLayoutAnimation,\n U extends AnimationObject | StyleLayoutAnimation\n> = T extends StyleLayoutAnimation\n ? Record<string, unknown>\n : U | (() => U) | AnimatableValue;\n\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\nexport function defineAnimation<\n T extends AnimationObject | StyleLayoutAnimation, // type that's supposed to be returned\n U extends AnimationObject | StyleLayoutAnimation = T // type that's received\n>(starting: AnimationToDecoration<T, U>, factory: () => T): T {\n 'worklet';\n if (IN_STYLE_UPDATER) {\n return starting as unknown as T;\n }\n const create = () => {\n 'worklet';\n const animation = factory();\n decorateAnimation<U>(animation as unknown as U);\n return animation;\n };\n\n if (_WORKLET || SHOULD_BE_USE_WEB) {\n return create();\n }\n // @ts-ignore: eslint-disable-line\n return create;\n}\n\n/**\n * Lets you cancel a running animation paired to a shared value.\n *\n * @param sharedValue - The shared value of a running animation that you want to cancel.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/core/cancelAnimation\n */\nexport function cancelAnimation<T>(sharedValue: SharedValue<T>): void {\n 'worklet';\n // setting the current value cancels the animation if one is currently running\n sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign\n}\n"],"mappings":"AAAA,YAAY;;AAGZ,SACEA,OAAO,EACPC,aAAa,EACbC,oBAAoB,EACpBC,YAAY,EACZC,aAAa,QACR,WAAW;AAClB,SAASC,YAAY,QAAQ,gBAAgB;AAa7C,SACEC,OAAO,EACPC,gBAAgB,EAChBC,WAAW,EACXC,WAAW,EACXC,oCAAoC,EACpCC,kBAAkB,EAClBC,gBAAgB,EAChBC,iBAAiB,QACZ,oCAAoC;AAC3C,SAASC,eAAe,EAAEC,cAAc,QAAQ,oBAAoB;AAEpE,IAAIC,gBAAgB,GAAG,KAAK;AAC5B,MAAMC,iBAAiB,GAAGH,eAAe,EAAE;AAE3C,OAAO,SAASI,iBAAiBA,CAAIC,OAAgB,EAAE;EACrDH,gBAAgB,GAAG,IAAI;EACvB,MAAMI,MAAM,GAAGD,OAAO,EAAE;EACxBH,gBAAgB,GAAG,KAAK;EACxB,OAAOI,MAAM;AACf;AAQA,OAAO,SAASC,qBAAqBA,CACnCC,KAAsB,EACE;EACxB,SAAS;;EACT,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,MAAMC,KAAK,GAAGD,KAAK,CAACC,KAAK,CACvB,wDAAwD,CACzD;IACD,IAAI,CAACA,KAAK,EAAE;MACV,MAAM,IAAIC,KAAK,CAAC,8CAA8C,CAAC;IAC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AAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,eAAeA,CAAIC,WAA2B,EAAQ;EACpE,SAAS;;EACT;EACAA,WAAW,CAAC5F,KAAK,GAAG4F,WAAW,CAAC5F,KAAK,CAAC,CAAC;AACzC"}
@@ -1,5 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ /**
4
+ * A value that can be used both on the [JavaScript thread](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#javascript-thread) and the [UI thread](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#ui-thread).
5
+ *
6
+ * Shared values are defined using [useSharedValue](https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue) hook. You access and modify shared values by their `.value` property.
7
+ */
8
+
3
9
  // The below type is used for HostObjects returned by the JSI API that don't have
4
10
  // any accessible fields or methods but can carry data that is accessed from the
5
11
  // c++ side. We add a field to the type to make it possible for typescript to recognize
@@ -25,6 +31,11 @@ export let IOSReferenceFrame = /*#__PURE__*/function (IOSReferenceFrame) {
25
31
  IOSReferenceFrame[IOSReferenceFrame["Auto"] = 4] = "Auto";
26
32
  return IOSReferenceFrame;
27
33
  }({});
34
+
35
+ /**
36
+ * A function called upon animation completion. If the animation is cancelled, the callback will receive `false` as the argument; otherwise, it will receive `true`.
37
+ */
38
+
28
39
  export let InterfaceOrientation = /*#__PURE__*/function (InterfaceOrientation) {
29
40
  InterfaceOrientation[InterfaceOrientation["ROTATION_0"] = 0] = "ROTATION_0";
30
41
  InterfaceOrientation[InterfaceOrientation["ROTATION_90"] = 90] = "ROTATION_90";
@@ -40,10 +51,22 @@ export let KeyboardState = /*#__PURE__*/function (KeyboardState) {
40
51
  KeyboardState[KeyboardState["CLOSED"] = 4] = "CLOSED";
41
52
  return KeyboardState;
42
53
  }({});
54
+
55
+ /**
56
+ * @param x - A number representing X coordinate relative to the parent component.
57
+ * @param y - A number representing Y coordinate relative to the parent component.
58
+ * @param width - A number representing the width of the component.
59
+ * @param height - A number representing the height of the component.
60
+ * @param pageX - A number representing X coordinate relative to the screen.
61
+ * @param pageY - A number representing Y coordinate relative to the screen.
62
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/measure#returns
63
+ */
64
+
43
65
  /**
44
- * - `System` - If the `Reduce motion` accessibility setting is enabled on the device, disable the animation. Otherwise, enable the animation.
45
- * - `Always` - Disable the animation.
46
- * - `Never` - Enable the animation.
66
+ * @param System - If the `Reduce motion` accessibility setting is enabled on the device, disable the animation. Otherwise, enable the animation.
67
+ * @param Always - Disable the animation.
68
+ * @param Never - Enable the animation.
69
+ * @see https://docs.swmansion.com/react-native-reanimated/docs/guides/accessibility
47
70
  */
48
71
  export let ReduceMotion = /*#__PURE__*/function (ReduceMotion) {
49
72
  ReduceMotion["System"] = "system";
@@ -55,15 +78,15 @@ export let ReduceMotion = /*#__PURE__*/function (ReduceMotion) {
55
78
  // THE LAND OF THE DEPRECATED
56
79
 
57
80
  /**
58
- * @deprecated
81
+ * @deprecated don't use
59
82
  */
60
83
  /**
61
- * @deprecated
84
+ * @deprecated don't use
62
85
  */
63
86
  /**
64
- * @deprecated
87
+ * @deprecated don't use
65
88
  */
66
89
  /**
67
- * @deprecated
90
+ * @deprecated don't use
68
91
  */
69
92
  //# sourceMappingURL=commonTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["SensorType","IOSReferenceFrame","InterfaceOrientation","KeyboardState","ReduceMotion"],"sources":["commonTypes.ts"],"sourcesContent":["'use strict';\nimport type { ViewStyle, TextStyle } from 'react-native';\n\nexport type RequiredKeys<T, K extends keyof T> = T & Required<Pick<T, K>>;\nexport interface StyleProps extends ViewStyle, TextStyle {\n originX?: number;\n originY?: number;\n [key: string]: any;\n}\n\nexport interface SharedValue<Value> {\n value: Value;\n addListener: (listenerID: number, listener: (value: any) => void) => void;\n removeListener: (listenerID: number) => void;\n modify: (modifier?: (value: any) => any, forceUpdate?: boolean) => void;\n}\n\n// The below type is used for HostObjects returned by the JSI API that don't have\n// any accessible fields or methods but can carry data that is accessed from the\n// c++ side. We add a field to the type to make it possible for typescript to recognize\n// which JSI methods accept those types as arguments and to be able to correctly type\n// check other methods that may use them. However, this field is not actually defined\n// nor should be used for anything else as assigning any data to those objects will\n// throw an error.\nexport type ShareableRef<T> = {\n __hostObjectShareableJSRef: T;\n};\n\n// In case of objects with depth or arrays of objects or arrays of arrays etc.\n// we add this utility type that makes it a SharaebleRef of the outermost type.\nexport type FlatShareableRef<T> = T extends ShareableRef<infer U>\n ? ShareableRef<U>\n : ShareableRef<T>;\n\nexport type ShareableSyncDataHolderRef<T> = {\n __hostObjectShareableJSRefSyncDataHolder: T;\n};\n\nexport type MapperRegistry = {\n start: (\n mapperID: number,\n worklet: () => void,\n inputs: SharedValue<any>[],\n outputs?: SharedValue<any>[]\n ) => void;\n stop: (mapperID: number) => void;\n};\n\ntype WorkletClosure = Record<string, unknown>;\n\ninterface WorkletInitDataCommon {\n code: string;\n}\n\ntype WorkletInitDataRelease = WorkletInitDataCommon;\n\ninterface WorkletInitDataDev extends WorkletInitDataCommon {\n location: string;\n sourceMap: string;\n version: string;\n}\n\ninterface WorkletBaseCommon {\n __closure: WorkletClosure;\n __workletHash: number;\n}\n\ninterface WorkletBaseRelease extends WorkletBaseCommon {\n __initData: WorkletInitDataRelease;\n}\n\ninterface WorkletBaseDev extends WorkletBaseCommon {\n __initData: WorkletInitDataDev;\n __stackDetails: Error;\n}\n\nexport type WorkletFunction<\n Args extends unknown[] = unknown[],\n ReturnValue = unknown\n> = ((...args: Args) => ReturnValue) & (WorkletBaseRelease | WorkletBaseDev);\n\nexport interface NestedObject<T> {\n [key: string]: NestedObjectValues<T>;\n}\n\nexport type NestedObjectValues<T> =\n | T\n | Array<NestedObjectValues<T>>\n | NestedObject<T>;\n\ntype Animatable = number | string | Array<number>;\n\nexport type AnimatableValueObject = { [key: string]: Animatable };\n\nexport type AnimatableValue = Animatable | AnimatableValueObject;\n\nexport interface AnimationObject<T = AnimatableValue> {\n [key: string]: any;\n callback?: AnimationCallback;\n current?: T;\n toValue?: AnimationObject<T>['current'];\n startValue?: AnimationObject<T>['current'];\n finished?: boolean;\n strippedCurrent?: number;\n cancelled?: boolean;\n reduceMotion?: boolean;\n\n __prefix?: string;\n __suffix?: string;\n onFrame: (animation: any, timestamp: Timestamp) => boolean;\n onStart: (\n nextAnimation: any,\n current: any,\n timestamp: Timestamp,\n previousAnimation: any\n ) => void;\n}\n\nexport interface Animation<T extends AnimationObject> extends AnimationObject {\n onFrame: (animation: T, timestamp: Timestamp) => boolean;\n onStart: (\n nextAnimation: T,\n current: AnimatableValue,\n timestamp: Timestamp,\n previousAnimation: Animation<any> | null | T\n ) => void;\n}\n\nexport enum SensorType {\n ACCELEROMETER = 1,\n GYROSCOPE = 2,\n GRAVITY = 3,\n MAGNETIC_FIELD = 4,\n ROTATION = 5,\n}\nexport enum IOSReferenceFrame {\n XArbitraryZVertical,\n XArbitraryCorrectedZVertical,\n XMagneticNorthZVertical,\n XTrueNorthZVertical,\n Auto,\n}\n\nexport type SensorConfig = {\n interval: number | 'auto';\n adjustToInterfaceOrientation: boolean;\n iosReferenceFrame: IOSReferenceFrame;\n};\n\nexport type AnimatedSensor<T extends Value3D | ValueRotation> = {\n sensor: SharedValue<T>;\n unregister: () => void;\n isAvailable: boolean;\n config: SensorConfig;\n};\n\nexport type AnimationCallback = (\n finished?: boolean,\n current?: AnimatableValue\n) => void;\n\nexport type Timestamp = number;\n\nexport type Value3D = {\n x: number;\n y: number;\n z: number;\n interfaceOrientation: InterfaceOrientation;\n};\n\nexport type ValueRotation = {\n qw: number;\n qx: number;\n qy: number;\n qz: number;\n yaw: number;\n pitch: number;\n roll: number;\n interfaceOrientation: InterfaceOrientation;\n};\n\nexport enum InterfaceOrientation {\n ROTATION_0 = 0,\n ROTATION_90 = 90,\n ROTATION_180 = 180,\n ROTATION_270 = 270,\n}\n\nexport type ShadowNodeWrapper = {\n __hostObjectShadowNodeWrapper: never;\n};\n\nexport enum KeyboardState {\n UNKNOWN = 0,\n OPENING = 1,\n OPEN = 2,\n CLOSING = 3,\n CLOSED = 4,\n}\n\nexport type AnimatedKeyboardInfo = {\n height: SharedValue<number>;\n state: SharedValue<KeyboardState>;\n};\n\nexport interface MeasuredDimensions {\n x: number;\n y: number;\n width: number;\n height: number;\n pageX: number;\n pageY: number;\n}\n\nexport interface AnimatedKeyboardOptions {\n isStatusBarTranslucentAndroid?: boolean;\n}\n\n/**\n * - `System` - If the `Reduce motion` accessibility setting is enabled on the device, disable the animation. Otherwise, enable the animation.\n * - `Always` - Disable the animation.\n * - `Never` - Enable the animation.\n */\nexport enum ReduceMotion {\n System = 'system',\n Always = 'always',\n Never = 'never',\n}\n\n// THE LAND OF THE DEPRECATED\n\n/**\n * @deprecated\n */\nexport interface __WorkletFunction {\n __closure?: Record<string, unknown>;\n __workletHash?: number;\n}\n\n/**\n * @deprecated\n */\nexport interface __BasicWorkletFunction<T> extends __WorkletFunction {\n (): T;\n}\n\n/**\n * @deprecated\n */\nexport interface __ComplexWorkletFunction<A extends any[], R>\n extends __WorkletFunction {\n (...args: A): R;\n __remoteFunction?: (...args: A) => R;\n}\n\n/**\n * @deprecated\n */\nexport interface __AdapterWorkletFunction extends __WorkletFunction {\n (value: NestedObject<string | number | AnimationObject>): void;\n}\n"],"mappings":"AAAA,YAAY;;AAiBZ;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AAmGA,WAAYA,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;AAOtB,WAAYC,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AA8C7B,WAAYC,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;AAWhC,WAAYC,aAAa,0BAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AA0BzB;AACA;AACA;AACA;AACA;AACA,WAAYC,YAAY,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA;;AAMxB;;AAEA;AACA;AACA;AAMA;AACA;AACA;AAKA;AACA;AACA;AAOA;AACA;AACA"}
1
+ {"version":3,"names":["SensorType","IOSReferenceFrame","InterfaceOrientation","KeyboardState","ReduceMotion"],"sources":["commonTypes.ts"],"sourcesContent":["'use strict';\nimport type { ViewStyle, TextStyle } from 'react-native';\n\nexport type RequiredKeys<T, K extends keyof T> = T & Required<Pick<T, K>>;\nexport interface StyleProps extends ViewStyle, TextStyle {\n originX?: number;\n originY?: number;\n [key: string]: any;\n}\n\n/**\n * A value that can be used both on the [JavaScript thread](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#javascript-thread) and the [UI thread](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#ui-thread).\n *\n * Shared values are defined using [useSharedValue](https://docs.swmansion.com/react-native-reanimated/docs/core/useSharedValue) hook. You access and modify shared values by their `.value` property.\n */\nexport interface SharedValue<Value> {\n value: Value;\n addListener: (listenerID: number, listener: (value: any) => void) => void;\n removeListener: (listenerID: number) => void;\n modify: (modifier?: (value: any) => any, forceUpdate?: boolean) => void;\n}\n\n// The below type is used for HostObjects returned by the JSI API that don't have\n// any accessible fields or methods but can carry data that is accessed from the\n// c++ side. We add a field to the type to make it possible for typescript to recognize\n// which JSI methods accept those types as arguments and to be able to correctly type\n// check other methods that may use them. However, this field is not actually defined\n// nor should be used for anything else as assigning any data to those objects will\n// throw an error.\nexport type ShareableRef<T> = {\n __hostObjectShareableJSRef: T;\n};\n\n// In case of objects with depth or arrays of objects or arrays of arrays etc.\n// we add this utility type that makes it a SharaebleRef of the outermost type.\nexport type FlatShareableRef<T> = T extends ShareableRef<infer U>\n ? ShareableRef<U>\n : ShareableRef<T>;\n\nexport type ShareableSyncDataHolderRef<T> = {\n __hostObjectShareableJSRefSyncDataHolder: T;\n};\n\nexport type MapperRegistry = {\n start: (\n mapperID: number,\n worklet: () => void,\n inputs: SharedValue<any>[],\n outputs?: SharedValue<any>[]\n ) => void;\n stop: (mapperID: number) => void;\n};\n\ntype WorkletClosure = Record<string, unknown>;\n\ninterface WorkletInitDataCommon {\n code: string;\n}\n\ntype WorkletInitDataRelease = WorkletInitDataCommon;\n\ninterface WorkletInitDataDev extends WorkletInitDataCommon {\n location: string;\n sourceMap: string;\n version: string;\n}\n\ninterface WorkletBaseCommon {\n __closure: WorkletClosure;\n __workletHash: number;\n}\n\ninterface WorkletBaseRelease extends WorkletBaseCommon {\n __initData: WorkletInitDataRelease;\n}\n\ninterface WorkletBaseDev extends WorkletBaseCommon {\n __initData: WorkletInitDataDev;\n __stackDetails: Error;\n}\n\nexport type WorkletFunction<\n Args extends unknown[] = unknown[],\n ReturnValue = unknown\n> = ((...args: Args) => ReturnValue) & (WorkletBaseRelease | WorkletBaseDev);\n\nexport interface NestedObject<T> {\n [key: string]: NestedObjectValues<T>;\n}\n\nexport type NestedObjectValues<T> =\n | T\n | Array<NestedObjectValues<T>>\n | NestedObject<T>;\n\ntype Animatable = number | string | Array<number>;\n\nexport type AnimatableValueObject = { [key: string]: Animatable };\n\nexport type AnimatableValue = Animatable | AnimatableValueObject;\n\nexport interface AnimationObject<T = AnimatableValue> {\n [key: string]: any;\n callback?: AnimationCallback;\n current?: T;\n toValue?: AnimationObject<T>['current'];\n startValue?: AnimationObject<T>['current'];\n finished?: boolean;\n strippedCurrent?: number;\n cancelled?: boolean;\n reduceMotion?: boolean;\n\n __prefix?: string;\n __suffix?: string;\n onFrame: (animation: any, timestamp: Timestamp) => boolean;\n onStart: (\n nextAnimation: any,\n current: any,\n timestamp: Timestamp,\n previousAnimation: any\n ) => void;\n}\n\nexport interface Animation<T extends AnimationObject> extends AnimationObject {\n onFrame: (animation: T, timestamp: Timestamp) => boolean;\n onStart: (\n nextAnimation: T,\n current: AnimatableValue,\n timestamp: Timestamp,\n previousAnimation: Animation<any> | null | T\n ) => void;\n}\n\nexport enum SensorType {\n ACCELEROMETER = 1,\n GYROSCOPE = 2,\n GRAVITY = 3,\n MAGNETIC_FIELD = 4,\n ROTATION = 5,\n}\nexport enum IOSReferenceFrame {\n XArbitraryZVertical,\n XArbitraryCorrectedZVertical,\n XMagneticNorthZVertical,\n XTrueNorthZVertical,\n Auto,\n}\n\nexport type SensorConfig = {\n interval: number | 'auto';\n adjustToInterfaceOrientation: boolean;\n iosReferenceFrame: IOSReferenceFrame;\n};\n\nexport type AnimatedSensor<T extends Value3D | ValueRotation> = {\n sensor: SharedValue<T>;\n unregister: () => void;\n isAvailable: boolean;\n config: SensorConfig;\n};\n\n/**\n * A function called upon animation completion. If the animation is cancelled, the callback will receive `false` as the argument; otherwise, it will receive `true`.\n */\nexport type AnimationCallback = (\n finished?: boolean,\n current?: AnimatableValue\n) => void;\n\nexport type Timestamp = number;\n\nexport type Value3D = {\n x: number;\n y: number;\n z: number;\n interfaceOrientation: InterfaceOrientation;\n};\n\nexport type ValueRotation = {\n qw: number;\n qx: number;\n qy: number;\n qz: number;\n yaw: number;\n pitch: number;\n roll: number;\n interfaceOrientation: InterfaceOrientation;\n};\n\nexport enum InterfaceOrientation {\n ROTATION_0 = 0,\n ROTATION_90 = 90,\n ROTATION_180 = 180,\n ROTATION_270 = 270,\n}\n\nexport type ShadowNodeWrapper = {\n __hostObjectShadowNodeWrapper: never;\n};\n\nexport enum KeyboardState {\n UNKNOWN = 0,\n OPENING = 1,\n OPEN = 2,\n CLOSING = 3,\n CLOSED = 4,\n}\n\nexport type AnimatedKeyboardInfo = {\n height: SharedValue<number>;\n state: SharedValue<KeyboardState>;\n};\n\n/**\n * @param x - A number representing X coordinate relative to the parent component.\n * @param y - A number representing Y coordinate relative to the parent component.\n * @param width - A number representing the width of the component.\n * @param height - A number representing the height of the component.\n * @param pageX - A number representing X coordinate relative to the screen.\n * @param pageY - A number representing Y coordinate relative to the screen.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/measure#returns\n */\nexport interface MeasuredDimensions {\n x: number;\n y: number;\n width: number;\n height: number;\n pageX: number;\n pageY: number;\n}\n\nexport interface AnimatedKeyboardOptions {\n isStatusBarTranslucentAndroid?: boolean;\n}\n\n/**\n * @param System - If the `Reduce motion` accessibility setting is enabled on the device, disable the animation. Otherwise, enable the animation.\n * @param Always - Disable the animation.\n * @param Never - Enable the animation.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/guides/accessibility\n */\nexport enum ReduceMotion {\n System = 'system',\n Always = 'always',\n Never = 'never',\n}\n\n// THE LAND OF THE DEPRECATED\n\n/**\n * @deprecated don't use\n */\nexport interface __WorkletFunction {\n __closure?: Record<string, unknown>;\n __workletHash?: number;\n}\n\n/**\n * @deprecated don't use\n */\nexport interface __BasicWorkletFunction<T> extends __WorkletFunction {\n (): T;\n}\n\n/**\n * @deprecated don't use\n */\nexport interface __ComplexWorkletFunction<A extends any[], R>\n extends __WorkletFunction {\n (...args: A): R;\n __remoteFunction?: (...args: A) => R;\n}\n\n/**\n * @deprecated don't use\n */\nexport interface __AdapterWorkletFunction extends __WorkletFunction {\n (value: NestedObject<string | number | AnimationObject>): void;\n}\n"],"mappings":"AAAA,YAAY;;AAUZ;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AAmGA,WAAYA,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;AAOtB,WAAYC,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;;AAqB7B;AACA;AACA;;AA0BA,WAAYC,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;AAWhC,WAAYC,aAAa,0BAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAbA,aAAa,CAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;;AAazB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYC,YAAY,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA;;AAMxB;;AAEA;AACA;AACA;AAMA;AACA;AACA;AAKA;AACA;AACA;AAOA;AACA;AACA"}