react-native-reanimated 3.9.0-rc.0 → 3.9.0

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 (297) hide show
  1. package/Common/cpp/Fabric/ShadowTreeCloner.cpp +2 -1
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +11 -4
  3. package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +5 -3
  4. package/apple/REAModule.mm +14 -29
  5. package/apple/REANodesManager.mm +7 -6
  6. package/lib/module/Animated.js.map +1 -1
  7. package/lib/module/ConfigHelper.js.map +1 -1
  8. package/lib/module/animationBuilder.js.map +1 -1
  9. package/lib/module/createAnimatedComponent/InlinePropManager.js +2 -2
  10. package/lib/module/createAnimatedComponent/InlinePropManager.js.map +1 -1
  11. package/lib/module/createAnimatedComponent/JSPropsUpdater.js +4 -4
  12. package/lib/module/createAnimatedComponent/JSPropsUpdater.js.map +1 -1
  13. package/lib/module/createAnimatedComponent/JSPropsUpdater.web.js.map +1 -1
  14. package/lib/module/createAnimatedComponent/PropsFilter.js +5 -5
  15. package/lib/module/createAnimatedComponent/PropsFilter.js.map +1 -1
  16. package/lib/module/createAnimatedComponent/commonTypes.js.map +1 -1
  17. package/lib/module/createAnimatedComponent/createAnimatedComponent.js +33 -33
  18. package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
  19. package/lib/module/createAnimatedComponent/getViewInfo.js +2 -2
  20. package/lib/module/createAnimatedComponent/getViewInfo.js.map +1 -1
  21. package/lib/module/createAnimatedComponent/index.js.map +1 -1
  22. package/lib/module/createAnimatedComponent/setAndForwardRef.js +4 -5
  23. package/lib/module/createAnimatedComponent/setAndForwardRef.js.map +1 -1
  24. package/lib/module/createAnimatedComponent/utils.js.map +1 -1
  25. package/lib/module/index.js.map +1 -1
  26. package/lib/module/index.web.js +1 -2
  27. package/lib/module/index.web.js.map +1 -1
  28. package/lib/module/mock.js +3 -8
  29. package/lib/module/mock.js.map +1 -1
  30. package/lib/module/propsAllowlists.js.map +1 -1
  31. package/lib/module/reanimated2/Bezier.js.map +1 -1
  32. package/lib/module/reanimated2/Colors.js +4 -11
  33. package/lib/module/reanimated2/Colors.js.map +1 -1
  34. package/lib/module/reanimated2/Easing.js +3 -7
  35. package/lib/module/reanimated2/Easing.js.map +1 -1
  36. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +3 -3
  37. package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
  38. package/lib/module/reanimated2/NativeReanimated/index.js.map +1 -1
  39. package/lib/module/reanimated2/NativeReanimated/index.web.js.map +1 -1
  40. package/lib/module/reanimated2/PlatformChecker.js +1 -0
  41. package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
  42. package/lib/module/reanimated2/PropAdapters.js +1 -1
  43. package/lib/module/reanimated2/PropAdapters.js.map +1 -1
  44. package/lib/module/reanimated2/PropsRegistry.js.map +1 -1
  45. package/lib/module/reanimated2/Sensor.js +2 -2
  46. package/lib/module/reanimated2/Sensor.js.map +1 -1
  47. package/lib/module/reanimated2/SensorContainer.js +2 -2
  48. package/lib/module/reanimated2/SensorContainer.js.map +1 -1
  49. package/lib/module/reanimated2/UpdateLayoutAnimations.js.map +1 -1
  50. package/lib/module/reanimated2/UpdateProps.js.map +1 -1
  51. package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
  52. package/lib/module/reanimated2/WorkletEventHandler.js +74 -31
  53. package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
  54. package/lib/module/reanimated2/animation/clamp.js.map +1 -1
  55. package/lib/module/reanimated2/animation/commonTypes.js.map +1 -1
  56. package/lib/module/reanimated2/animation/decay/decay.js.map +1 -1
  57. package/lib/module/reanimated2/animation/decay/index.js.map +1 -1
  58. package/lib/module/reanimated2/animation/decay/rigidDecay.js.map +1 -1
  59. package/lib/module/reanimated2/animation/decay/rubberBandDecay.js.map +1 -1
  60. package/lib/module/reanimated2/animation/decay/utils.js.map +1 -1
  61. package/lib/module/reanimated2/animation/delay.js.map +1 -1
  62. package/lib/module/reanimated2/animation/index.js.map +1 -1
  63. package/lib/module/reanimated2/animation/repeat.js +1 -6
  64. package/lib/module/reanimated2/animation/repeat.js.map +1 -1
  65. package/lib/module/reanimated2/animation/sequence.js +1 -5
  66. package/lib/module/reanimated2/animation/sequence.js.map +1 -1
  67. package/lib/module/reanimated2/animation/spring.js.map +1 -1
  68. package/lib/module/reanimated2/animation/springUtils.js +8 -10
  69. package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
  70. package/lib/module/reanimated2/animation/styleAnimation.js +5 -4
  71. package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
  72. package/lib/module/reanimated2/animation/timing.js.map +1 -1
  73. package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js +1 -2
  74. package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js.map +1 -1
  75. package/lib/module/reanimated2/animation/util.js.map +1 -1
  76. package/lib/module/reanimated2/commonTypes.js +2 -0
  77. package/lib/module/reanimated2/commonTypes.js.map +1 -1
  78. package/lib/module/reanimated2/component/FlatList.js +1 -0
  79. package/lib/module/reanimated2/component/FlatList.js.map +1 -1
  80. package/lib/module/reanimated2/component/Image.js +1 -0
  81. package/lib/module/reanimated2/component/Image.js.map +1 -1
  82. package/lib/module/reanimated2/component/LayoutAnimationConfig.js +1 -0
  83. package/lib/module/reanimated2/component/LayoutAnimationConfig.js.map +1 -1
  84. package/lib/module/reanimated2/component/PerformanceMonitor.js +3 -4
  85. package/lib/module/reanimated2/component/PerformanceMonitor.js.map +1 -1
  86. package/lib/module/reanimated2/component/ScrollView.js +1 -0
  87. package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
  88. package/lib/module/reanimated2/component/Text.js +1 -0
  89. package/lib/module/reanimated2/component/Text.js.map +1 -1
  90. package/lib/module/reanimated2/component/View.js +1 -0
  91. package/lib/module/reanimated2/component/View.js.map +1 -1
  92. package/lib/module/reanimated2/core.js +2 -4
  93. package/lib/module/reanimated2/core.js.map +1 -1
  94. package/lib/module/reanimated2/errors.js +7 -8
  95. package/lib/module/reanimated2/errors.js.map +1 -1
  96. package/lib/module/reanimated2/fabricUtils.js +4 -4
  97. package/lib/module/reanimated2/fabricUtils.js.map +1 -1
  98. package/lib/module/reanimated2/fabricUtils.web.js.map +1 -1
  99. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +2 -2
  100. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
  101. package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
  102. package/lib/module/reanimated2/frameCallback/index.js.map +1 -1
  103. package/lib/module/reanimated2/globals.d.js.map +1 -1
  104. package/lib/module/reanimated2/helperTypes.js.map +1 -1
  105. package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
  106. package/lib/module/reanimated2/hook/index.js.map +1 -1
  107. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +1 -0
  108. package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
  109. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +3 -4
  110. package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
  111. package/lib/module/reanimated2/hook/useAnimatedProps.js.map +1 -1
  112. package/lib/module/reanimated2/hook/useAnimatedReaction.js +1 -0
  113. package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
  114. package/lib/module/reanimated2/hook/useAnimatedRef.js +1 -1
  115. package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
  116. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +3 -1
  117. package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
  118. package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
  119. package/lib/module/reanimated2/hook/useAnimatedStyle.js +3 -6
  120. package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
  121. package/lib/module/reanimated2/hook/useDerivedValue.js +3 -1
  122. package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
  123. package/lib/module/reanimated2/hook/useEvent.js +4 -5
  124. package/lib/module/reanimated2/hook/useEvent.js.map +1 -1
  125. package/lib/module/reanimated2/hook/useFrameCallback.js +1 -2
  126. package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
  127. package/lib/module/reanimated2/hook/useHandler.js +3 -1
  128. package/lib/module/reanimated2/hook/useHandler.js.map +1 -1
  129. package/lib/module/reanimated2/hook/useReducedMotion.js.map +1 -1
  130. package/lib/module/reanimated2/hook/useScrollViewOffset.js +14 -6
  131. package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
  132. package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
  133. package/lib/module/reanimated2/hook/useWorkletCallback.js.map +1 -1
  134. package/lib/module/reanimated2/hook/utils.js.map +1 -1
  135. package/lib/module/reanimated2/index.js.map +1 -1
  136. package/lib/module/reanimated2/initializers.js +1 -5
  137. package/lib/module/reanimated2/initializers.js.map +1 -1
  138. package/lib/module/reanimated2/interpolateColor.js +2 -6
  139. package/lib/module/reanimated2/interpolateColor.js.map +1 -1
  140. package/lib/module/reanimated2/interpolation.js +1 -1
  141. package/lib/module/reanimated2/interpolation.js.map +1 -1
  142. package/lib/module/reanimated2/isSharedValue.js.map +1 -1
  143. package/lib/module/reanimated2/jestUtils.js +3 -6
  144. package/lib/module/reanimated2/jestUtils.js.map +1 -1
  145. package/lib/module/reanimated2/jestUtils.web.js.map +1 -1
  146. package/lib/module/reanimated2/js-reanimated/JSReanimated.js +4 -5
  147. package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
  148. package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -1
  149. package/lib/module/reanimated2/js-reanimated/index.js +2 -2
  150. package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
  151. package/lib/module/reanimated2/js-reanimated/react-native-web.d.js.map +1 -1
  152. package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +4 -2
  153. package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
  154. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +8 -11
  155. package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
  156. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +8 -9
  157. package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
  158. package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
  159. package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
  160. package/lib/module/reanimated2/layoutReanimation/animationsManager.js +1 -2
  161. package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
  162. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +22 -22
  163. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
  164. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +22 -22
  165. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
  166. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +26 -26
  167. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
  168. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +10 -10
  169. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
  170. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +6 -6
  171. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
  172. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +10 -10
  173. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
  174. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +18 -18
  175. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
  176. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +18 -18
  177. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
  178. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +10 -10
  179. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
  180. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +34 -34
  181. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
  182. package/lib/module/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
  183. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +4 -4
  184. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  185. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +4 -4
  186. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
  187. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +4 -4
  188. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
  189. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +4 -4
  190. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
  191. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +4 -4
  192. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
  193. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +4 -4
  194. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
  195. package/lib/module/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
  196. package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
  197. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.js +4 -6
  198. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.js.map +1 -1
  199. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js +4 -6
  200. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js.map +1 -1
  201. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.web.js.map +1 -1
  202. package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
  203. package/lib/module/reanimated2/layoutReanimation/web/animation/Bounce.web.js.map +1 -1
  204. package/lib/module/reanimated2/layoutReanimation/web/animation/Fade.web.js.map +1 -1
  205. package/lib/module/reanimated2/layoutReanimation/web/animation/Flip.web.js.map +1 -1
  206. package/lib/module/reanimated2/layoutReanimation/web/animation/Lightspeed.web.js.map +1 -1
  207. package/lib/module/reanimated2/layoutReanimation/web/animation/Pinwheel.web.js.map +1 -1
  208. package/lib/module/reanimated2/layoutReanimation/web/animation/Roll.web.js.map +1 -1
  209. package/lib/module/reanimated2/layoutReanimation/web/animation/Rotate.web.js.map +1 -1
  210. package/lib/module/reanimated2/layoutReanimation/web/animation/Slide.web.js.map +1 -1
  211. package/lib/module/reanimated2/layoutReanimation/web/animation/Stretch.web.js.map +1 -1
  212. package/lib/module/reanimated2/layoutReanimation/web/animation/Zoom.web.js.map +1 -1
  213. package/lib/module/reanimated2/layoutReanimation/web/animationParser.js +0 -2
  214. package/lib/module/reanimated2/layoutReanimation/web/animationParser.js.map +1 -1
  215. package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js +1 -2
  216. package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js.map +1 -1
  217. package/lib/module/reanimated2/layoutReanimation/web/componentStyle.js +3 -1
  218. package/lib/module/reanimated2/layoutReanimation/web/componentStyle.js.map +1 -1
  219. package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js +6 -7
  220. package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js.map +1 -1
  221. package/lib/module/reanimated2/layoutReanimation/web/config.js.map +1 -1
  222. package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js +2 -2
  223. package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js.map +1 -1
  224. package/lib/module/reanimated2/layoutReanimation/web/domUtils.js +4 -4
  225. package/lib/module/reanimated2/layoutReanimation/web/domUtils.js.map +1 -1
  226. package/lib/module/reanimated2/layoutReanimation/web/index.js.map +1 -1
  227. package/lib/module/reanimated2/layoutReanimation/web/transition/Fading.web.js.map +1 -1
  228. package/lib/module/reanimated2/layoutReanimation/web/transition/Linear.web.js.map +1 -1
  229. package/lib/module/reanimated2/layoutReanimation/web/transition/Sequenced.web.js.map +1 -1
  230. package/lib/module/reanimated2/mappers.js +2 -4
  231. package/lib/module/reanimated2/mappers.js.map +1 -1
  232. package/lib/module/reanimated2/mockedRequestAnimationFrame.js.map +1 -1
  233. package/lib/module/reanimated2/mutables.js +2 -4
  234. package/lib/module/reanimated2/mutables.js.map +1 -1
  235. package/lib/module/reanimated2/platform-specific/RNRenderer.js.map +1 -1
  236. package/lib/module/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
  237. package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -1
  238. package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
  239. package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
  240. package/lib/module/reanimated2/platformFunctions/dispatchCommand.js +2 -4
  241. package/lib/module/reanimated2/platformFunctions/dispatchCommand.js.map +1 -1
  242. package/lib/module/reanimated2/platformFunctions/dispatchCommand.web.js.map +1 -1
  243. package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js +2 -2
  244. package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js.map +1 -1
  245. package/lib/module/reanimated2/platformFunctions/index.js.map +1 -1
  246. package/lib/module/reanimated2/platformFunctions/measure.js.map +1 -1
  247. package/lib/module/reanimated2/platformFunctions/measure.web.js.map +1 -1
  248. package/lib/module/reanimated2/platformFunctions/scrollTo.js.map +1 -1
  249. package/lib/module/reanimated2/platformFunctions/scrollTo.web.js +1 -1
  250. package/lib/module/reanimated2/platformFunctions/scrollTo.web.js.map +1 -1
  251. package/lib/module/reanimated2/platformFunctions/setGestureState.js.map +1 -1
  252. package/lib/module/reanimated2/platformFunctions/setGestureState.web.js.map +1 -1
  253. package/lib/module/reanimated2/platformFunctions/setNativeProps.js.map +1 -1
  254. package/lib/module/reanimated2/platformFunctions/setNativeProps.web.js.map +1 -1
  255. package/lib/module/reanimated2/pluginUtils.js.map +1 -1
  256. package/lib/module/reanimated2/publicGlobals.js.map +1 -1
  257. package/lib/module/reanimated2/runtimes.js +11 -19
  258. package/lib/module/reanimated2/runtimes.js.map +1 -1
  259. package/lib/module/reanimated2/screenTransition/RNScreensTurboModule.js.map +1 -1
  260. package/lib/module/reanimated2/screenTransition/animationManager.js.map +1 -1
  261. package/lib/module/reanimated2/screenTransition/commonTypes.js.map +1 -1
  262. package/lib/module/reanimated2/screenTransition/index.js.map +1 -1
  263. package/lib/module/reanimated2/screenTransition/presets.js.map +1 -1
  264. package/lib/module/reanimated2/screenTransition/styleUpdater.js.map +1 -1
  265. package/lib/module/reanimated2/screenTransition/swipeSimulator.js +1 -1
  266. package/lib/module/reanimated2/screenTransition/swipeSimulator.js.map +1 -1
  267. package/lib/module/reanimated2/shareableMappingCache.js.map +1 -1
  268. package/lib/module/reanimated2/shareables.js +2 -4
  269. package/lib/module/reanimated2/shareables.js.map +1 -1
  270. package/lib/module/reanimated2/threads.js +9 -34
  271. package/lib/module/reanimated2/threads.js.map +1 -1
  272. package/lib/module/reanimated2/valueSetter.js +1 -2
  273. package/lib/module/reanimated2/valueSetter.js.map +1 -1
  274. package/lib/module/reanimated2/valueUnpacker.js.map +1 -1
  275. package/lib/module/specs/NativeReanimatedModule.js.map +1 -1
  276. package/lib/typescript/reanimated2/WorkletEventHandler.d.ts +16 -9
  277. package/lib/typescript/reanimated2/component/LayoutAnimationConfig.d.ts +1 -1
  278. package/lib/typescript/reanimated2/component/PerformanceMonitor.d.ts +2 -1
  279. package/lib/typescript/reanimated2/hook/commonTypes.d.ts +5 -0
  280. package/lib/typescript/reanimated2/hook/useEvent.d.ts +2 -3
  281. package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
  282. package/package.json +18 -14
  283. package/plugin/build/plugin.js +7 -2
  284. package/src/createAnimatedComponent/PropsFilter.tsx +1 -1
  285. package/src/createAnimatedComponent/createAnimatedComponent.tsx +29 -33
  286. package/src/reanimated2/WorkletEventHandler.ts +98 -39
  287. package/src/reanimated2/animation/styleAnimation.ts +8 -6
  288. package/src/reanimated2/hook/commonTypes.ts +9 -0
  289. package/src/reanimated2/hook/useEvent.ts +4 -4
  290. package/src/reanimated2/hook/useScrollViewOffset.ts +21 -5
  291. package/src/reanimated2/js-reanimated/JSReanimated.ts +6 -3
  292. package/src/reanimated2/layoutReanimation/web/animationsManager.ts +1 -1
  293. package/src/reanimated2/layoutReanimation/web/componentStyle.ts +3 -1
  294. package/src/reanimated2/layoutReanimation/web/componentUtils.ts +1 -1
  295. package/src/reanimated2/layoutReanimation/web/createAnimation.ts +2 -2
  296. package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
  297. package/src/reanimated2/platformFunctions/getRelativeCoords.ts +2 -2
@@ -1 +1 @@
1
- {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","rubberBandDecay","isValidRubberBandConfig","rigidDecay","validateConfig","config","clamp","Array","isArray","Error","length","velocityFactor","rubberBandEffect","withDecay","userConfig","callback","deceleration","velocity","rubberBandFactor","Object","keys","forEach","key","decay","animation","now","onStart","value","current","lastTimestamp","startTimestamp","initialVelocity","reduceMotion","onFrame"],"sources":["decay.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from '../util';\nimport type {\n AnimationCallback,\n Timestamp,\n Animation,\n} from '../../commonTypes';\nimport { rubberBandDecay } from './rubberBandDecay';\nimport { isValidRubberBandConfig } from './utils';\nimport type {\n DecayAnimation,\n DecayConfig,\n DefaultDecayConfig,\n InnerDecayAnimation,\n} from './utils';\nimport { rigidDecay } from './rigidDecay';\n\nexport type WithDecayConfig = DecayConfig;\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withDecayType = (\n userConfig: DecayConfig,\n callback?: AnimationCallback\n) => number;\n\nfunction validateConfig(config: DefaultDecayConfig): void {\n 'worklet';\n if (config.clamp) {\n if (!Array.isArray(config.clamp)) {\n throw new Error(\n `[Reanimated] \\`config.clamp\\` must be an array but is ${typeof config.clamp}.`\n );\n }\n if (config.clamp.length !== 2) {\n throw new Error(\n `[Reanimated] \\`clamp array\\` must contain 2 items but is given ${\n config.clamp.length as number\n }.`\n );\n }\n }\n if (config.velocityFactor <= 0) {\n throw new Error(\n `[Reanimated] \\`config.velocityFactor\\` must be greather then 0 but is ${config.velocityFactor}.`\n );\n }\n if (config.rubberBandEffect && !config.clamp) {\n throw new Error(\n '[Reanimated] You need to set `clamp` property when using `rubberBandEffect`.'\n );\n }\n}\n\n/**\n * Lets you create animations that mimic objects in motion with friction.\n *\n * @param config - The decay animation configuration - {@link DecayConfig}.\n * @param callback - A function called upon animation completion - {@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/withDecay\n */\nexport const withDecay = function (\n userConfig: DecayConfig,\n callback?: AnimationCallback\n): Animation<DecayAnimation> {\n 'worklet';\n\n return defineAnimation<DecayAnimation>(0, () => {\n 'worklet';\n const config: DefaultDecayConfig = {\n deceleration: 0.998,\n velocityFactor: 1,\n velocity: 0,\n rubberBandFactor: 0.6,\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 const decay: (animation: InnerDecayAnimation, now: number) => boolean =\n isValidRubberBandConfig(config)\n ? (animation, now) => rubberBandDecay(animation, now, config)\n : (animation, now) => rigidDecay(animation, now, config);\n\n function onStart(\n animation: DecayAnimation,\n value: number,\n now: Timestamp\n ): void {\n animation.current = value;\n animation.lastTimestamp = now;\n animation.startTimestamp = now;\n animation.initialVelocity = config.velocity;\n validateConfig(config);\n\n if (animation.reduceMotion && config.clamp) {\n if (value < config.clamp[0]) {\n animation.current = config.clamp[0];\n } else if (value > config.clamp[1]) {\n animation.current = config.clamp[1];\n }\n }\n }\n\n return {\n onFrame: decay,\n onStart,\n callback,\n velocity: config.velocity ?? 0,\n initialVelocity: 0,\n current: 0,\n lastTimestamp: 0,\n startTimestamp: 0,\n reduceMotion: getReduceMotionForAnimation(config.reduceMotion),\n } as DecayAnimation;\n });\n} as unknown as withDecayType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,SAAS;AAMtE,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,uBAAuB,QAAQ,SAAS;AAOjD,SAASC,UAAU,QAAQ,cAAc;;AAIzC;;AAMA,SAASC,cAAcA,CAACC,MAA0B,EAAQ;EACxD,SAAS;;EACT,IAAIA,MAAM,CAACC,KAAK,EAAE;IAChB,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,MAAM,CAACC,KAAK,CAAC,EAAE;MAChC,MAAM,IAAIG,KAAK,CACZ,yDAAwD,OAAOJ,MAAM,CAACC,KAAM,GAAE,CAChF;IACH;IACA,IAAID,MAAM,CAACC,KAAK,CAACI,MAAM,KAAK,CAAC,EAAE;MAC7B,MAAM,IAAID,KAAK,CACZ,kEACCJ,MAAM,CAACC,KAAK,CAACI,MACd,GAAE,CACJ;IACH;EACF;EACA,IAAIL,MAAM,CAACM,cAAc,IAAI,CAAC,EAAE;IAC9B,MAAM,IAAIF,KAAK,CACZ,yEAAwEJ,MAAM,CAACM,cAAe,GAAE,CAClG;EACH;EACA,IAAIN,MAAM,CAACO,gBAAgB,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E;UAC3BkB,SAAS,CAACI,OAAO,GAAGvB,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;QACrC,CAAC,MAAM,IAAIqB,KAAK,GAAGtB,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC,EAAE;UAClCkB,SAAS,CAACI,OAAO,GAAGvB,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;QACrC;MACF;IACF;IAEA,OAAO;MACL2B,OAAO,EAAEV,KAAK;MACdG,OAAO;MACPX,QAAQ;MACRE,QAAQ,EAAEZ,MAAM,CAACY,QAAQ,IAAI,CAAC;MAC9Bc,eAAe,EAAE,CAAC;MAClBH,OAAO,EAAE,CAAC;MACVC,aAAa,EAAE,CAAC;MAChBC,cAAc,EAAE,CAAC;MACjBE,YAAY,EAAEhC,2BAA2B,CAACK,MAAM,CAAC2B,YAAY;IAC/D,CAAC;EACH,CAAC,CAAC;AACJ,CAA6B"}
1
+ {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","rubberBandDecay","isValidRubberBandConfig","rigidDecay","validateConfig","config","clamp","Array","isArray","Error","length","velocityFactor","rubberBandEffect","withDecay","userConfig","callback","deceleration","velocity","rubberBandFactor","Object","keys","forEach","key","decay","animation","now","onStart","value","current","lastTimestamp","startTimestamp","initialVelocity","reduceMotion","onFrame"],"sources":["decay.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from '../util';\nimport type {\n AnimationCallback,\n Timestamp,\n Animation,\n} from '../../commonTypes';\nimport { rubberBandDecay } from './rubberBandDecay';\nimport { isValidRubberBandConfig } from './utils';\nimport type {\n DecayAnimation,\n DecayConfig,\n DefaultDecayConfig,\n InnerDecayAnimation,\n} from './utils';\nimport { rigidDecay } from './rigidDecay';\n\nexport type WithDecayConfig = DecayConfig;\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withDecayType = (\n userConfig: DecayConfig,\n callback?: AnimationCallback\n) => number;\n\nfunction validateConfig(config: DefaultDecayConfig): void {\n 'worklet';\n if (config.clamp) {\n if (!Array.isArray(config.clamp)) {\n throw new Error(\n `[Reanimated] \\`config.clamp\\` must be an array but is ${typeof config.clamp}.`\n );\n }\n if (config.clamp.length !== 2) {\n throw new Error(\n `[Reanimated] \\`clamp array\\` must contain 2 items but is given ${\n config.clamp.length as number\n }.`\n );\n }\n }\n if (config.velocityFactor <= 0) {\n throw new Error(\n `[Reanimated] \\`config.velocityFactor\\` must be greather then 0 but is ${config.velocityFactor}.`\n );\n }\n if (config.rubberBandEffect && !config.clamp) {\n throw new Error(\n '[Reanimated] You need to set `clamp` property when using `rubberBandEffect`.'\n );\n }\n}\n\n/**\n * Lets you create animations that mimic objects in motion with friction.\n *\n * @param config - The decay animation configuration - {@link DecayConfig}.\n * @param callback - A function called upon animation completion - {@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/withDecay\n */\nexport const withDecay = function (\n userConfig: DecayConfig,\n callback?: AnimationCallback\n): Animation<DecayAnimation> {\n 'worklet';\n\n return defineAnimation<DecayAnimation>(0, () => {\n 'worklet';\n const config: DefaultDecayConfig = {\n deceleration: 0.998,\n velocityFactor: 1,\n velocity: 0,\n rubberBandFactor: 0.6,\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 const decay: (animation: InnerDecayAnimation, now: number) => boolean =\n isValidRubberBandConfig(config)\n ? (animation, now) => rubberBandDecay(animation, now, config)\n : (animation, now) => rigidDecay(animation, now, config);\n\n function onStart(\n animation: DecayAnimation,\n value: number,\n now: Timestamp\n ): void {\n animation.current = value;\n animation.lastTimestamp = now;\n animation.startTimestamp = now;\n animation.initialVelocity = config.velocity;\n validateConfig(config);\n\n if (animation.reduceMotion && config.clamp) {\n if (value < config.clamp[0]) {\n animation.current = config.clamp[0];\n } else if (value > config.clamp[1]) {\n animation.current = config.clamp[1];\n }\n }\n }\n\n return {\n onFrame: decay,\n onStart,\n callback,\n velocity: config.velocity ?? 0,\n initialVelocity: 0,\n current: 0,\n lastTimestamp: 0,\n startTimestamp: 0,\n reduceMotion: getReduceMotionForAnimation(config.reduceMotion),\n } as DecayAnimation;\n });\n} as unknown as withDecayType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,SAAS;AAMtE,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,uBAAuB,QAAQ,SAAS;AAOjD,SAASC,UAAU,QAAQ,cAAc;;AAIzC;;AAMA,SAASC,cAAcA,CAACC,MAA0B,EAAQ;EACxD,SAAS;;EACT,IAAIA,MAAM,CAACC,KAAK,EAAE;IAChB,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,MAAM,CAACC,KAAK,CAAC,EAAE;MAChC,MAAM,IAAIG,KAAK,CACZ,yDAAwD,OAAOJ,MAAM,CAACC,KAAM,GAC/E,CAAC;IACH;IACA,IAAID,MAAM,CAACC,KAAK,CAACI,MAAM,KAAK,CAAC,EAAE;MAC7B,MAAM,IAAID,KAAK,CACZ,kEACCJ,MAAM,CAACC,KAAK,CAACI,MACd,GACH,CAAC;IACH;EACF;EACA,IAAIL,MAAM,CAACM,cAAc,IAAI,CAAC,EAAE;IAC9B,MAAM,IAAIF,KAAK,CACZ,yEAAwEJ,MAAM,CAACM,cAAe,GACjG,CAAC;EACH;EACA,IAAIN,MAAM,CAACO,gBAAgB,IAAI,CAACP,MAAM,CAACC,KAAK,EAAE;IAC5C,MAAM,IAAIG,KAAK,CACb,8EACF,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,SAAS,GAAG,SAAAA,CACvBC,UAAuB,EACvBC,QAA4B,EACD;EAC3B,SAAS;;EAET,OAAOhB,eAAe,CAAiB,CAAC,EAAE,MAAM;IAC9C,SAAS;;IACT,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MACdG,OAAO;MACPX,QAAQ;MACRE,QAAQ,EAAEZ,MAAM,CAACY,QAAQ,IAAI,CAAC;MAC9Bc,eAAe,EAAE,CAAC;MAClBH,OAAO,EAAE,CAAC;MACVC,aAAa,EAAE,CAAC;MAChBC,cAAc,EAAE,CAAC;MACjBE,YAAY,EAAEhC,2BAA2B,CAACK,MAAM,CAAC2B,YAAY;IAC/D,CAAC;EACH,CAAC,CAAC;AACJ,CAA6B","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["withDecay"],"sources":["index.ts"],"sourcesContent":["'use strict';\nexport type { WithDecayConfig } from './decay';\nexport { withDecay } from './decay';\nexport type { DecayAnimation } from './utils';\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,SAAS,QAAQ,SAAS"}
1
+ {"version":3,"names":["withDecay"],"sources":["index.ts"],"sourcesContent":["'use strict';\nexport type { WithDecayConfig } from './decay';\nexport { withDecay } from './decay';\nexport type { DecayAnimation } from './utils';\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,SAAS,QAAQ,SAAS","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["SLOPE_FACTOR","VELOCITY_EPS","rigidDecay","animation","now","config","lastTimestamp","startTimestamp","initialVelocity","current","velocity","deltaTime","Math","min","v","exp","deceleration","velocityFactor","clamp","abs"],"sources":["rigidDecay.ts"],"sourcesContent":["'use strict';\nimport { SLOPE_FACTOR, VELOCITY_EPS } from './utils';\nimport type { DefaultDecayConfig, InnerDecayAnimation } from './utils';\n\nexport function rigidDecay(\n animation: InnerDecayAnimation,\n now: number,\n config: DefaultDecayConfig\n): boolean {\n 'worklet';\n const { lastTimestamp, startTimestamp, initialVelocity, current, velocity } =\n animation;\n\n const deltaTime = Math.min(now - lastTimestamp, 64);\n const v =\n velocity *\n Math.exp(\n -(1 - config.deceleration) * (now - startTimestamp) * SLOPE_FACTOR\n );\n animation.current = current + (v * config.velocityFactor * deltaTime) / 1000;\n animation.velocity = v;\n animation.lastTimestamp = now;\n\n if (config.clamp) {\n if (initialVelocity < 0 && animation.current <= config.clamp[0]) {\n animation.current = config.clamp[0];\n return true;\n } else if (initialVelocity > 0 && animation.current >= config.clamp[1]) {\n animation.current = config.clamp[1];\n return true;\n }\n }\n return Math.abs(v) < VELOCITY_EPS;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,YAAY,EAAEC,YAAY,QAAQ,SAAS;AAGpD,OAAO,SAASC,UAAUA,CACxBC,SAA8B,EAC9BC,GAAW,EACXC,MAA0B,EACjB;EACT,SAAS;;EACT,MAAM;IAAEC,aAAa;IAAEC,cAAc;IAAEC,eAAe;IAAEC,OAAO;IAAEC;EAAS,CAAC,GACzEP,SAAS;EAEX,MAAMQ,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACT,GAAG,GAAGE,aAAa,EAAE,EAAE,CAAC;EACnD,MAAMQ,CAAC,GACLJ,QAAQ,GACRE,IAAI,CAACG,GAAG,CACN,EAAE,CAAC,GAAGV,MAAM,CAACW,YAAY,CAAC,IAAIZ,GAAG,GAAGG,cAAc,CAAC,GAAGP,YAAY,CACnE;EACHG,SAAS,CAACM,OAAO,GAAGA,OAAO,GAAIK,CAAC,GAAGT,MAAM,CAACY,cAAc,GAAGN,SAAS,GAAI,IAAI;EAC5ER,SAAS,CAACO,QAAQ,GAAGI,CAAC;EACtBX,SAAS,CAACG,aAAa,GAAGF,GAAG;EAE7B,IAAIC,MAAM,CAACa,KAAK,EAAE;IAChB,IAAIV,eAAe,GAAG,CAAC,IAAIL,SAAS,CAACM,OAAO,IAAIJ,MAAM,CAACa,KAAK,CAAC,CAAC,CAAC,EAAE;MAC/Df,SAAS,CAACM,OAAO,GAAGJ,MAAM,CAACa,KAAK,CAAC,CAAC,CAAC;MACnC,OAAO,IAAI;IACb,CAAC,MAAM,IAAIV,eAAe,GAAG,CAAC,IAAIL,SAAS,CAACM,OAAO,IAAIJ,MAAM,CAACa,KAAK,CAAC,CAAC,CAAC,EAAE;MACtEf,SAAS,CAACM,OAAO,GAAGJ,MAAM,CAACa,KAAK,CAAC,CAAC,CAAC;MACnC,OAAO,IAAI;IACb;EACF;EACA,OAAON,IAAI,CAACO,GAAG,CAACL,CAAC,CAAC,GAAGb,YAAY;AACnC"}
1
+ {"version":3,"names":["SLOPE_FACTOR","VELOCITY_EPS","rigidDecay","animation","now","config","lastTimestamp","startTimestamp","initialVelocity","current","velocity","deltaTime","Math","min","v","exp","deceleration","velocityFactor","clamp","abs"],"sources":["rigidDecay.ts"],"sourcesContent":["'use strict';\nimport { SLOPE_FACTOR, VELOCITY_EPS } from './utils';\nimport type { DefaultDecayConfig, InnerDecayAnimation } from './utils';\n\nexport function rigidDecay(\n animation: InnerDecayAnimation,\n now: number,\n config: DefaultDecayConfig\n): boolean {\n 'worklet';\n const { lastTimestamp, startTimestamp, initialVelocity, current, velocity } =\n animation;\n\n const deltaTime = Math.min(now - lastTimestamp, 64);\n const v =\n velocity *\n Math.exp(\n -(1 - config.deceleration) * (now - startTimestamp) * SLOPE_FACTOR\n );\n animation.current = current + (v * config.velocityFactor * deltaTime) / 1000;\n animation.velocity = v;\n animation.lastTimestamp = now;\n\n if (config.clamp) {\n if (initialVelocity < 0 && animation.current <= config.clamp[0]) {\n animation.current = config.clamp[0];\n return true;\n } else if (initialVelocity > 0 && animation.current >= config.clamp[1]) {\n animation.current = config.clamp[1];\n return true;\n }\n }\n return Math.abs(v) < VELOCITY_EPS;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,YAAY,EAAEC,YAAY,QAAQ,SAAS;AAGpD,OAAO,SAASC,UAAUA,CACxBC,SAA8B,EAC9BC,GAAW,EACXC,MAA0B,EACjB;EACT,SAAS;;EACT,MAAM;IAAEC,aAAa;IAAEC,cAAc;IAAEC,eAAe;IAAEC,OAAO;IAAEC;EAAS,CAAC,GACzEP,SAAS;EAEX,MAAMQ,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACT,GAAG,GAAGE,aAAa,EAAE,EAAE,CAAC;EACnD,MAAMQ,CAAC,GACLJ,QAAQ,GACRE,IAAI,CAACG,GAAG,CACN,EAAE,CAAC,GAAGV,MAAM,CAACW,YAAY,CAAC,IAAIZ,GAAG,GAAGG,cAAc,CAAC,GAAGP,YACxD,CAAC;EACHG,SAAS,CAACM,OAAO,GAAGA,OAAO,GAAIK,CAAC,GAAGT,MAAM,CAACY,cAAc,GAAGN,SAAS,GAAI,IAAI;EAC5ER,SAAS,CAACO,QAAQ,GAAGI,CAAC;EACtBX,SAAS,CAACG,aAAa,GAAGF,GAAG;EAE7B,IAAIC,MAAM,CAACa,KAAK,EAAE;IAChB,IAAIV,eAAe,GAAG,CAAC,IAAIL,SAAS,CAACM,OAAO,IAAIJ,MAAM,CAACa,KAAK,CAAC,CAAC,CAAC,EAAE;MAC/Df,SAAS,CAACM,OAAO,GAAGJ,MAAM,CAACa,KAAK,CAAC,CAAC,CAAC;MACnC,OAAO,IAAI;IACb,CAAC,MAAM,IAAIV,eAAe,GAAG,CAAC,IAAIL,SAAS,CAACM,OAAO,IAAIJ,MAAM,CAACa,KAAK,CAAC,CAAC,CAAC,EAAE;MACtEf,SAAS,CAACM,OAAO,GAAGJ,MAAM,CAACa,KAAK,CAAC,CAAC,CAAC;MACnC,OAAO,IAAI;IACb;EACF;EACA,OAAON,IAAI,CAACO,GAAG,CAACL,CAAC,CAAC,GAAGb,YAAY;AACnC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["SLOPE_FACTOR","VELOCITY_EPS","DERIVATIVE_EPS","rubberBandDecay","animation","now","config","lastTimestamp","startTimestamp","current","velocity","deltaTime","Math","min","clampIndex","abs","clamp","derivative","v","exp","deceleration","rubberBandFactor","springActive","velocityFactor"],"sources":["rubberBandDecay.ts"],"sourcesContent":["'use strict';\nimport type { RubberBandDecayConfig, InnerDecayAnimation } from './utils';\nimport { SLOPE_FACTOR, VELOCITY_EPS } from './utils';\n\nconst DERIVATIVE_EPS = 0.1;\n\nexport function rubberBandDecay(\n animation: InnerDecayAnimation,\n now: number,\n config: RubberBandDecayConfig\n): boolean {\n 'worklet';\n const { lastTimestamp, startTimestamp, current, velocity } = animation;\n\n const deltaTime = Math.min(now - lastTimestamp, 64);\n const clampIndex =\n Math.abs(current - config.clamp[0]) < Math.abs(current - config.clamp[1])\n ? 0\n : 1;\n\n let derivative = 0;\n if (current < config.clamp[0] || current > config.clamp[1]) {\n derivative = current - config.clamp[clampIndex];\n }\n\n const v =\n velocity *\n Math.exp(\n -(1 - config.deceleration) * (now - startTimestamp) * SLOPE_FACTOR\n ) -\n derivative * config.rubberBandFactor;\n\n if (Math.abs(derivative) > DERIVATIVE_EPS) {\n animation.springActive = true;\n } else if (animation.springActive) {\n animation.current = config.clamp[clampIndex];\n return true;\n } else if (Math.abs(v) < VELOCITY_EPS) {\n return true;\n }\n\n animation.current = current + (v * config.velocityFactor * deltaTime) / 1000;\n animation.velocity = v;\n animation.lastTimestamp = now;\n return false;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,YAAY,EAAEC,YAAY,QAAQ,SAAS;AAEpD,MAAMC,cAAc,GAAG,GAAG;AAE1B,OAAO,SAASC,eAAeA,CAC7BC,SAA8B,EAC9BC,GAAW,EACXC,MAA6B,EACpB;EACT,SAAS;;EACT,MAAM;IAAEC,aAAa;IAAEC,cAAc;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAGN,SAAS;EAEtE,MAAMO,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACR,GAAG,GAAGE,aAAa,EAAE,EAAE,CAAC;EACnD,MAAMO,UAAU,GACdF,IAAI,CAACG,GAAG,CAACN,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,CAAC,GAAGJ,IAAI,CAACG,GAAG,CAACN,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,CAAC,GACrE,CAAC,GACD,CAAC;EAEP,IAAIC,UAAU,GAAG,CAAC;EAClB,IAAIR,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,IAAIP,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,EAAE;IAC1DC,UAAU,GAAGR,OAAO,GAAGH,MAAM,CAACU,KAAK,CAACF,UAAU,CAAC;EACjD;EAEA,MAAMI,CAAC,GACLR,QAAQ,GACNE,IAAI,CAACO,GAAG,CACN,EAAE,CAAC,GAAGb,MAAM,CAACc,YAAY,CAAC,IAAIf,GAAG,GAAGG,cAAc,CAAC,GAAGR,YAAY,CACnE,GACHiB,UAAU,GAAGX,MAAM,CAACe,gBAAgB;EAEtC,IAAIT,IAAI,CAACG,GAAG,CAACE,UAAU,CAAC,GAAGf,cAAc,EAAE;IACzCE,SAAS,CAACkB,YAAY,GAAG,IAAI;EAC/B,CAAC,MAAM,IAAIlB,SAAS,CAACkB,YAAY,EAAE;IACjClB,SAAS,CAACK,OAAO,GAAGH,MAAM,CAACU,KAAK,CAACF,UAAU,CAAC;IAC5C,OAAO,IAAI;EACb,CAAC,MAAM,IAAIF,IAAI,CAACG,GAAG,CAACG,CAAC,CAAC,GAAGjB,YAAY,EAAE;IACrC,OAAO,IAAI;EACb;EAEAG,SAAS,CAACK,OAAO,GAAGA,OAAO,GAAIS,CAAC,GAAGZ,MAAM,CAACiB,cAAc,GAAGZ,SAAS,GAAI,IAAI;EAC5EP,SAAS,CAACM,QAAQ,GAAGQ,CAAC;EACtBd,SAAS,CAACG,aAAa,GAAGF,GAAG;EAC7B,OAAO,KAAK;AACd"}
1
+ {"version":3,"names":["SLOPE_FACTOR","VELOCITY_EPS","DERIVATIVE_EPS","rubberBandDecay","animation","now","config","lastTimestamp","startTimestamp","current","velocity","deltaTime","Math","min","clampIndex","abs","clamp","derivative","v","exp","deceleration","rubberBandFactor","springActive","velocityFactor"],"sources":["rubberBandDecay.ts"],"sourcesContent":["'use strict';\nimport type { RubberBandDecayConfig, InnerDecayAnimation } from './utils';\nimport { SLOPE_FACTOR, VELOCITY_EPS } from './utils';\n\nconst DERIVATIVE_EPS = 0.1;\n\nexport function rubberBandDecay(\n animation: InnerDecayAnimation,\n now: number,\n config: RubberBandDecayConfig\n): boolean {\n 'worklet';\n const { lastTimestamp, startTimestamp, current, velocity } = animation;\n\n const deltaTime = Math.min(now - lastTimestamp, 64);\n const clampIndex =\n Math.abs(current - config.clamp[0]) < Math.abs(current - config.clamp[1])\n ? 0\n : 1;\n\n let derivative = 0;\n if (current < config.clamp[0] || current > config.clamp[1]) {\n derivative = current - config.clamp[clampIndex];\n }\n\n const v =\n velocity *\n Math.exp(\n -(1 - config.deceleration) * (now - startTimestamp) * SLOPE_FACTOR\n ) -\n derivative * config.rubberBandFactor;\n\n if (Math.abs(derivative) > DERIVATIVE_EPS) {\n animation.springActive = true;\n } else if (animation.springActive) {\n animation.current = config.clamp[clampIndex];\n return true;\n } else if (Math.abs(v) < VELOCITY_EPS) {\n return true;\n }\n\n animation.current = current + (v * config.velocityFactor * deltaTime) / 1000;\n animation.velocity = v;\n animation.lastTimestamp = now;\n return false;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,YAAY,EAAEC,YAAY,QAAQ,SAAS;AAEpD,MAAMC,cAAc,GAAG,GAAG;AAE1B,OAAO,SAASC,eAAeA,CAC7BC,SAA8B,EAC9BC,GAAW,EACXC,MAA6B,EACpB;EACT,SAAS;;EACT,MAAM;IAAEC,aAAa;IAAEC,cAAc;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAGN,SAAS;EAEtE,MAAMO,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACR,GAAG,GAAGE,aAAa,EAAE,EAAE,CAAC;EACnD,MAAMO,UAAU,GACdF,IAAI,CAACG,GAAG,CAACN,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,CAAC,GAAGJ,IAAI,CAACG,GAAG,CAACN,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,CAAC,GACrE,CAAC,GACD,CAAC;EAEP,IAAIC,UAAU,GAAG,CAAC;EAClB,IAAIR,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,IAAIP,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,EAAE;IAC1DC,UAAU,GAAGR,OAAO,GAAGH,MAAM,CAACU,KAAK,CAACF,UAAU,CAAC;EACjD;EAEA,MAAMI,CAAC,GACLR,QAAQ,GACNE,IAAI,CAACO,GAAG,CACN,EAAE,CAAC,GAAGb,MAAM,CAACc,YAAY,CAAC,IAAIf,GAAG,GAAGG,cAAc,CAAC,GAAGR,YACxD,CAAC,GACHiB,UAAU,GAAGX,MAAM,CAACe,gBAAgB;EAEtC,IAAIT,IAAI,CAACG,GAAG,CAACE,UAAU,CAAC,GAAGf,cAAc,EAAE;IACzCE,SAAS,CAACkB,YAAY,GAAG,IAAI;EAC/B,CAAC,MAAM,IAAIlB,SAAS,CAACkB,YAAY,EAAE;IACjClB,SAAS,CAACK,OAAO,GAAGH,MAAM,CAACU,KAAK,CAACF,UAAU,CAAC;IAC5C,OAAO,IAAI;EACb,CAAC,MAAM,IAAIF,IAAI,CAACG,GAAG,CAACG,CAAC,CAAC,GAAGjB,YAAY,EAAE;IACrC,OAAO,IAAI;EACb;EAEAG,SAAS,CAACK,OAAO,GAAGA,OAAO,GAAIS,CAAC,GAAGZ,MAAM,CAACiB,cAAc,GAAGZ,SAAS,GAAI,IAAI;EAC5EP,SAAS,CAACM,QAAQ,GAAGQ,CAAC;EACtBd,SAAS,CAACG,aAAa,GAAGF,GAAG;EAC7B,OAAO,KAAK;AACd","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["isWeb","IS_WEB","VELOCITY_EPS","SLOPE_FACTOR","isValidRubberBandConfig","config","rubberBandEffect","Array","isArray","clamp","length"],"sources":["utils.ts"],"sourcesContent":["'use strict';\nimport type {\n AnimatableValue,\n AnimationObject,\n Animation,\n ReduceMotion,\n Timestamp,\n RequiredKeys,\n} from '../../../reanimated2/commonTypes';\nimport { isWeb } from '../../PlatformChecker';\n\nconst IS_WEB = isWeb();\nexport const VELOCITY_EPS = IS_WEB ? 1 / 20 : 1;\nexport const SLOPE_FACTOR = 0.1;\n\nexport interface DecayAnimation extends Animation<DecayAnimation> {\n lastTimestamp: Timestamp;\n startTimestamp: Timestamp;\n initialVelocity: number;\n velocity: number;\n current: AnimatableValue;\n}\n\nexport interface InnerDecayAnimation\n extends Omit<DecayAnimation, 'current'>,\n AnimationObject {\n current: number;\n springActive?: boolean;\n}\n\n/**\n * The decay animation configuration.\n *\n * @param velocity - Initial velocity of the animation. Defaults to 0.\n * @param deceleration - The rate at which the velocity decreases over time. Defaults to 0.998.\n * @param clamp - Array of two numbers which restricts animation's range. Defaults to [].\n * @param velocityFactor - Velocity multiplier. Defaults to 1.\n * @param rubberBandEffect - Makes the animation bounce over the limit specified in `clamp`. Defaults to `false`.\n * @param rubberBandFactor - Strength of the rubber band effect. Defaults to 0.6.\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/withDecay#config\n */\nexport type DecayConfig = {\n deceleration?: number;\n velocityFactor?: number;\n velocity?: number;\n reduceMotion?: ReduceMotion;\n} & (\n | {\n rubberBandEffect?: false;\n clamp?: [min: number, max: number];\n }\n | {\n rubberBandEffect: true;\n clamp: [min: number, max: number];\n rubberBandFactor?: number;\n }\n);\n\nexport type DefaultDecayConfig = RequiredKeys<\n DecayConfig,\n 'deceleration' | 'velocityFactor' | 'velocity'\n> & { rubberBandFactor: number };\n\n// If user wants to use rubber band decay animation we have to make sure he has provided clamp\nexport type RubberBandDecayConfig = RequiredKeys<\n DefaultDecayConfig,\n 'clamp'\n> & { rubberBandEffect: true };\n\nexport function isValidRubberBandConfig(\n config: DefaultDecayConfig\n): config is RubberBandDecayConfig {\n 'worklet';\n return (\n !!config.rubberBandEffect &&\n Array.isArray(config.clamp) &&\n config.clamp.length === 2\n );\n}\n"],"mappings":"AAAA,YAAY;;AASZ,SAASA,KAAK,QAAQ,uBAAuB;AAE7C,MAAMC,MAAM,GAAGD,KAAK,EAAE;AACtB,OAAO,MAAME,YAAY,GAAGD,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;AAC/C,OAAO,MAAME,YAAY,GAAG,GAAG;;AAiB/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA;;AAMA,OAAO,SAASC,uBAAuBA,CACrCC,MAA0B,EACO;EACjC,SAAS;;EACT,OACE,CAAC,CAACA,MAAM,CAACC,gBAAgB,IACzBC,KAAK,CAACC,OAAO,CAACH,MAAM,CAACI,KAAK,CAAC,IAC3BJ,MAAM,CAACI,KAAK,CAACC,MAAM,KAAK,CAAC;AAE7B"}
1
+ {"version":3,"names":["isWeb","IS_WEB","VELOCITY_EPS","SLOPE_FACTOR","isValidRubberBandConfig","config","rubberBandEffect","Array","isArray","clamp","length"],"sources":["utils.ts"],"sourcesContent":["'use strict';\nimport type {\n AnimatableValue,\n AnimationObject,\n Animation,\n ReduceMotion,\n Timestamp,\n RequiredKeys,\n} from '../../../reanimated2/commonTypes';\nimport { isWeb } from '../../PlatformChecker';\n\nconst IS_WEB = isWeb();\nexport const VELOCITY_EPS = IS_WEB ? 1 / 20 : 1;\nexport const SLOPE_FACTOR = 0.1;\n\nexport interface DecayAnimation extends Animation<DecayAnimation> {\n lastTimestamp: Timestamp;\n startTimestamp: Timestamp;\n initialVelocity: number;\n velocity: number;\n current: AnimatableValue;\n}\n\nexport interface InnerDecayAnimation\n extends Omit<DecayAnimation, 'current'>,\n AnimationObject {\n current: number;\n springActive?: boolean;\n}\n\n/**\n * The decay animation configuration.\n *\n * @param velocity - Initial velocity of the animation. Defaults to 0.\n * @param deceleration - The rate at which the velocity decreases over time. Defaults to 0.998.\n * @param clamp - Array of two numbers which restricts animation's range. Defaults to [].\n * @param velocityFactor - Velocity multiplier. Defaults to 1.\n * @param rubberBandEffect - Makes the animation bounce over the limit specified in `clamp`. Defaults to `false`.\n * @param rubberBandFactor - Strength of the rubber band effect. Defaults to 0.6.\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/withDecay#config\n */\nexport type DecayConfig = {\n deceleration?: number;\n velocityFactor?: number;\n velocity?: number;\n reduceMotion?: ReduceMotion;\n} & (\n | {\n rubberBandEffect?: false;\n clamp?: [min: number, max: number];\n }\n | {\n rubberBandEffect: true;\n clamp: [min: number, max: number];\n rubberBandFactor?: number;\n }\n);\n\nexport type DefaultDecayConfig = RequiredKeys<\n DecayConfig,\n 'deceleration' | 'velocityFactor' | 'velocity'\n> & { rubberBandFactor: number };\n\n// If user wants to use rubber band decay animation we have to make sure he has provided clamp\nexport type RubberBandDecayConfig = RequiredKeys<\n DefaultDecayConfig,\n 'clamp'\n> & { rubberBandEffect: true };\n\nexport function isValidRubberBandConfig(\n config: DefaultDecayConfig\n): config is RubberBandDecayConfig {\n 'worklet';\n return (\n !!config.rubberBandEffect &&\n Array.isArray(config.clamp) &&\n config.clamp.length === 2\n );\n}\n"],"mappings":"AAAA,YAAY;;AASZ,SAASA,KAAK,QAAQ,uBAAuB;AAE7C,MAAMC,MAAM,GAAGD,KAAK,CAAC,CAAC;AACtB,OAAO,MAAME,YAAY,GAAGD,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;AAC/C,OAAO,MAAME,YAAY,GAAG,GAAG;;AAiB/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA;;AAMA,OAAO,SAASC,uBAAuBA,CACrCC,MAA0B,EACO;EACjC,SAAS;;EACT,OACE,CAAC,CAACA,MAAM,CAACC,gBAAgB,IACzBC,KAAK,CAACC,OAAO,CAACH,MAAM,CAACI,KAAK,CAAC,IAC3BJ,MAAM,CAACI,KAAK,CAACC,MAAM,KAAK,CAAC;AAE7B","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withDelay","delayMs","_nextAnimation","reduceMotion","nextAnimation","delay","animation","now","startTime","started","previousAnimation","current","onStart","finished","onFrame","value","undefined","callback","isHigherOrder"],"sources":["delay.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n Timestamp,\n AnimatableValue,\n AnimationObject,\n ReduceMotion,\n} from '../commonTypes';\nimport type { DelayAnimation } from './commonTypes';\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withDelayType = <T extends AnimatableValue>(\n delayMs: number,\n delayedAnimation: T,\n reduceMotion?: ReduceMotion\n) => T;\n\n/**\n * An animation modifier that lets you start an animation with a delay.\n *\n * @param delayMs - Duration (in milliseconds) before the animation starts.\n * @param nextAnimation - The animation to delay.\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\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/withDelay\n */\nexport const withDelay = function <T extends AnimationObject>(\n delayMs: number,\n _nextAnimation: T | (() => T),\n reduceMotion?: ReduceMotion\n): Animation<DelayAnimation> {\n 'worklet';\n return defineAnimation<DelayAnimation, T>(\n _nextAnimation,\n (): DelayAnimation => {\n 'worklet';\n const nextAnimation =\n typeof _nextAnimation === 'function'\n ? _nextAnimation()\n : _nextAnimation;\n\n function delay(animation: DelayAnimation, now: Timestamp): boolean {\n const { startTime, started, previousAnimation } = animation;\n const current: AnimatableValue = animation.current;\n\n if (now - startTime > delayMs || animation.reduceMotion) {\n if (!started) {\n nextAnimation.onStart(\n nextAnimation,\n current,\n now,\n previousAnimation!\n );\n animation.previousAnimation = null;\n animation.started = true;\n }\n const finished = nextAnimation.onFrame(nextAnimation, now);\n animation.current = nextAnimation.current!;\n return finished;\n } else if (previousAnimation) {\n const finished =\n previousAnimation.finished ||\n previousAnimation.onFrame(previousAnimation, now);\n animation.current = previousAnimation.current;\n if (finished) {\n animation.previousAnimation = null;\n }\n }\n return false;\n }\n\n function onStart(\n animation: Animation<any>,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: Animation<any> | null\n ): void {\n animation.startTime = now;\n animation.started = false;\n animation.current = value;\n if (previousAnimation === animation) {\n animation.previousAnimation = previousAnimation.previousAnimation;\n } else {\n animation.previousAnimation = previousAnimation;\n }\n\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 if (nextAnimation.reduceMotion === undefined) {\n nextAnimation.reduceMotion = animation.reduceMotion;\n }\n }\n\n const callback = (finished?: boolean): void => {\n if (nextAnimation.callback) {\n nextAnimation.callback(finished);\n }\n };\n\n return {\n isHigherOrder: true,\n onFrame: delay,\n onStart,\n current: nextAnimation.current!,\n callback,\n previousAnimation: null,\n startTime: 0,\n started: false,\n reduceMotion: getReduceMotionForAnimation(reduceMotion),\n };\n }\n );\n} as withDelayType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;;AAUrE;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAG,SAAAA,CACvBC,OAAe,EACfC,cAA6B,EAC7BC,YAA2B,EACA;EAC3B,SAAS;;EACT,OAAOL,eAAe,CACpBI,cAAc,EACd,MAAsB;IACpB,SAAS;;IACT,MAAME,aAAa,GACjB,OAAOF,cAAc,KAAK,UAAU,GAChCA,cAAc,EAAE,GAChBA,cAAc;IAEpB,SAASG,KAAKA,CAACC,SAAyB,EAAEC,GAAc,EAAW;MACjE,MAAM;QAAEC,SAAS;QAAEC,OAAO;QAAEC;MAAkB,CAAC,GAAGJ,SAAS;MAC3D,MAAMK,OAAwB,GAAGL,SAAS,CAAC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A,MAAMc,QAAQ,GAAIJ,QAAkB,IAAW;MAC7C,IAAIT,aAAa,CAACa,QAAQ,EAAE;QAC1Bb,aAAa,CAACa,QAAQ,CAACJ,QAAQ,CAAC;MAClC;IACF,CAAC;IAED,OAAO;MACLK,aAAa,EAAE,IAAI;MACnBJ,OAAO,EAAET,KAAK;MACdO,OAAO;MACPD,OAAO,EAAEP,aAAa,CAACO,OAAQ;MAC/BM,QAAQ;MACRP,iBAAiB,EAAE,IAAI;MACvBF,SAAS,EAAE,CAAC;MACZC,OAAO,EAAE,KAAK;MACdN,YAAY,EAAEJ,2BAA2B,CAACI,YAAY;IACxD,CAAC;EACH,CAAC,CACF;AACH,CAAkB"}
1
+ {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withDelay","delayMs","_nextAnimation","reduceMotion","nextAnimation","delay","animation","now","startTime","started","previousAnimation","current","onStart","finished","onFrame","value","undefined","callback","isHigherOrder"],"sources":["delay.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n Timestamp,\n AnimatableValue,\n AnimationObject,\n ReduceMotion,\n} from '../commonTypes';\nimport type { DelayAnimation } from './commonTypes';\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withDelayType = <T extends AnimatableValue>(\n delayMs: number,\n delayedAnimation: T,\n reduceMotion?: ReduceMotion\n) => T;\n\n/**\n * An animation modifier that lets you start an animation with a delay.\n *\n * @param delayMs - Duration (in milliseconds) before the animation starts.\n * @param nextAnimation - The animation to delay.\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\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/withDelay\n */\nexport const withDelay = function <T extends AnimationObject>(\n delayMs: number,\n _nextAnimation: T | (() => T),\n reduceMotion?: ReduceMotion\n): Animation<DelayAnimation> {\n 'worklet';\n return defineAnimation<DelayAnimation, T>(\n _nextAnimation,\n (): DelayAnimation => {\n 'worklet';\n const nextAnimation =\n typeof _nextAnimation === 'function'\n ? _nextAnimation()\n : _nextAnimation;\n\n function delay(animation: DelayAnimation, now: Timestamp): boolean {\n const { startTime, started, previousAnimation } = animation;\n const current: AnimatableValue = animation.current;\n\n if (now - startTime > delayMs || animation.reduceMotion) {\n if (!started) {\n nextAnimation.onStart(\n nextAnimation,\n current,\n now,\n previousAnimation!\n );\n animation.previousAnimation = null;\n animation.started = true;\n }\n const finished = nextAnimation.onFrame(nextAnimation, now);\n animation.current = nextAnimation.current!;\n return finished;\n } else if (previousAnimation) {\n const finished =\n previousAnimation.finished ||\n previousAnimation.onFrame(previousAnimation, now);\n animation.current = previousAnimation.current;\n if (finished) {\n animation.previousAnimation = null;\n }\n }\n return false;\n }\n\n function onStart(\n animation: Animation<any>,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: Animation<any> | null\n ): void {\n animation.startTime = now;\n animation.started = false;\n animation.current = value;\n if (previousAnimation === animation) {\n animation.previousAnimation = previousAnimation.previousAnimation;\n } else {\n animation.previousAnimation = previousAnimation;\n }\n\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 if (nextAnimation.reduceMotion === undefined) {\n nextAnimation.reduceMotion = animation.reduceMotion;\n }\n }\n\n const callback = (finished?: boolean): void => {\n if (nextAnimation.callback) {\n nextAnimation.callback(finished);\n }\n };\n\n return {\n isHigherOrder: true,\n onFrame: delay,\n onStart,\n current: nextAnimation.current!,\n callback,\n previousAnimation: null,\n startTime: 0,\n started: false,\n reduceMotion: getReduceMotionForAnimation(reduceMotion),\n };\n }\n );\n} as withDelayType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;;AAUrE;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO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ACE,SAAS,GAAGD,GAAG;MACzBD,SAAS,CAACG,OAAO,GAAG,KAAK;MACzBH,SAAS,CAACK,OAAO,GAAGI,KAAK;MACzB,IAAIL,iBAAiB,KAAKJ,SAAS,EAAE;QACnCA,SAAS,CAACI,iBAAiB,GAAGA,iBAAiB,CAACA,iBAAiB;MACnE,CAAC,MAAM;QACLJ,SAAS,CAACI,iBAAiB,GAAGA,iBAAiB;MACjD;;MAEA;MACA;MACA,IAAIN,aAAa,CAACD,YAAY,KAAKa,SAAS,EAAE;QAC5CZ,aAAa,CAACD,YAAY,GAAGG,SAAS,CAACH,YAAY;MACrD;IACF;IAEA,MAAMc,QAAQ,GAAIJ,QAAkB,IAAW;MAC7C,IAAIT,aAAa,CAACa,QAAQ,EAAE;QAC1Bb,aAAa,CAACa,QAAQ,CAACJ,QAAQ,CAAC;MAClC;IACF,CAAC;IAED,OAAO;MACLK,aAAa,EAAE,IAAI;MACnBJ,OAAO,EAAET,KAAK;MACdO,OAAO;MACPD,OAAO,EAAEP,aAAa,CAACO,OAAQ;MAC/BM,QAAQ;MACRP,iBAAiB,EAAE,IAAI;MACvBF,SAAS,EAAE,CAAC;MACZC,OAAO,EAAE,KAAK;MACdN,YAAY,EAAEJ,2BAA2B,CAACI,YAAY;IACxD,CAAC;EACH,CACF,CAAC;AACH,CAAkB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["cancelAnimation","defineAnimation","initialUpdaterRun","withTiming","withSpring","withDecay","withClamp","withDelay","withRepeat","withSequence","withStyleAnimation"],"sources":["index.ts"],"sourcesContent":["'use strict';\nexport type {\n HigherOrderAnimation,\n NextAnimation,\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n} from './commonTypes';\nexport { cancelAnimation, defineAnimation, initialUpdaterRun } from './util';\nexport { withTiming } from './timing';\nexport type { TimingAnimation, WithTimingConfig } from './timing';\nexport { withSpring } from './spring';\nexport type { SpringAnimation, WithSpringConfig } from './springUtils';\nexport { withDecay } from './decay';\nexport type { DecayAnimation, WithDecayConfig } from './decay';\nexport { withClamp } from './clamp';\nexport { withDelay } from './delay';\nexport { withRepeat } from './repeat';\nexport { withSequence } from './sequence';\nexport { withStyleAnimation } from './styleAnimation';\n"],"mappings":"AAAA,YAAY;;AASZ,SAASA,eAAe,EAAEC,eAAe,EAAEC,iBAAiB,QAAQ,QAAQ;AAC5E,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,SAAS,QAAQ,SAAS;AAEnC,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,YAAY,QAAQ,YAAY;AACzC,SAASC,kBAAkB,QAAQ,kBAAkB"}
1
+ {"version":3,"names":["cancelAnimation","defineAnimation","initialUpdaterRun","withTiming","withSpring","withDecay","withClamp","withDelay","withRepeat","withSequence","withStyleAnimation"],"sources":["index.ts"],"sourcesContent":["'use strict';\nexport type {\n HigherOrderAnimation,\n NextAnimation,\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n} from './commonTypes';\nexport { cancelAnimation, defineAnimation, initialUpdaterRun } from './util';\nexport { withTiming } from './timing';\nexport type { TimingAnimation, WithTimingConfig } from './timing';\nexport { withSpring } from './spring';\nexport type { SpringAnimation, WithSpringConfig } from './springUtils';\nexport { withDecay } from './decay';\nexport type { DecayAnimation, WithDecayConfig } from './decay';\nexport { withClamp } from './clamp';\nexport { withDelay } from './delay';\nexport { withRepeat } from './repeat';\nexport { withSequence } from './sequence';\nexport { withStyleAnimation } from './styleAnimation';\n"],"mappings":"AAAA,YAAY;;AASZ,SAASA,eAAe,EAAEC,eAAe,EAAEC,iBAAiB,QAAQ,QAAQ;AAC5E,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,SAAS,QAAQ,SAAS;AAEnC,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,YAAY,QAAQ,YAAY;AACzC,SAASC,kBAAkB,QAAQ,kBAAkB","ignoreList":[]}
@@ -15,13 +15,9 @@ import { defineAnimation, getReduceMotionForAnimation } from './util';
15
15
  * @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.
16
16
  * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withRepeat
17
17
  */
18
- export const withRepeat = function (_nextAnimation) {
18
+ export const withRepeat = function (_nextAnimation, numberOfReps = 2, reverse = false, callback, reduceMotion) {
19
19
  'worklet';
20
20
 
21
- let numberOfReps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
22
- let reverse = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
23
- let callback = arguments.length > 3 ? arguments[3] : undefined;
24
- let reduceMotion = arguments.length > 4 ? arguments[4] : undefined;
25
21
  return defineAnimation(_nextAnimation, () => {
26
22
  'worklet';
27
23
 
@@ -58,7 +54,6 @@ export const withRepeat = function (_nextAnimation) {
58
54
  nextAnimation.callback(false /* finished */);
59
55
  }
60
56
  };
61
-
62
57
  function onStart(animation, value, now, previousAnimation) {
63
58
  animation.startValue = value;
64
59
  animation.reps = 0;
@@ -1 +1 @@
1
- {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withRepeat","_nextAnimation","numberOfReps","arguments","length","undefined","reverse","callback","reduceMotion","nextAnimation","repeat","animation","now","finished","onFrame","current","reps","startValue","toValue","onStart","previousAnimation","repCallback","value","isHigherOrder"],"sources":["repeat.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n AnimationCallback,\n AnimatableValue,\n Timestamp,\n AnimationObject,\n ReduceMotion,\n} from '../commonTypes';\nimport type { RepeatAnimation } from './commonTypes';\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withRepeatType = <T extends AnimatableValue>(\n animation: T,\n numberOfReps?: number,\n reverse?: boolean,\n callback?: AnimationCallback,\n reduceMotion?: ReduceMotion\n) => T;\n\n/**\n * Lets you repeat an animation given number of times or run it indefinitely.\n *\n * @param animation - An animation object you want to repeat.\n * @param numberOfReps - The number of times the animation is going to be repeated. Defaults to 2.\n * @param reverse - Whether the animation should run in reverse every other repetition. Defaults to false.\n * @param callback - A function called on animation complete.\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\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/withRepeat\n */\nexport const withRepeat = function <T extends AnimationObject>(\n _nextAnimation: T | (() => T),\n numberOfReps = 2,\n reverse = false,\n callback?: AnimationCallback,\n reduceMotion?: ReduceMotion\n): Animation<RepeatAnimation> {\n 'worklet';\n\n return defineAnimation<RepeatAnimation, T>(\n _nextAnimation,\n (): RepeatAnimation => {\n 'worklet';\n\n const nextAnimation =\n typeof _nextAnimation === 'function'\n ? _nextAnimation()\n : _nextAnimation;\n\n function repeat(animation: RepeatAnimation, now: Timestamp): boolean {\n const finished = nextAnimation.onFrame(nextAnimation, now);\n animation.current = nextAnimation.current;\n if (finished) {\n animation.reps += 1;\n // call inner animation's callback on every repetition\n // as the second argument the animation's current value is passed\n if (nextAnimation.callback) {\n nextAnimation.callback(true /* finished */, animation.current);\n }\n if (\n animation.reduceMotion ||\n (numberOfReps > 0 && animation.reps >= numberOfReps)\n ) {\n return true;\n }\n\n const startValue = reverse\n ? (nextAnimation.current as number)\n : animation.startValue;\n if (reverse) {\n nextAnimation.toValue = animation.startValue;\n animation.startValue = startValue;\n }\n nextAnimation.onStart(\n nextAnimation,\n startValue,\n now,\n nextAnimation.previousAnimation as RepeatAnimation\n );\n return false;\n }\n return false;\n }\n\n const repCallback = (finished?: boolean): void => {\n if (callback) {\n callback(finished);\n }\n // when cancelled call inner animation's callback\n if (!finished && nextAnimation.callback) {\n nextAnimation.callback(false /* finished */);\n }\n };\n\n function onStart(\n animation: RepeatAnimation,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: Animation<any> | null\n ): void {\n animation.startValue = value;\n animation.reps = 0;\n\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 if (nextAnimation.reduceMotion === undefined) {\n nextAnimation.reduceMotion = animation.reduceMotion;\n }\n\n // don't start the animation if reduced motion is enabled and\n // the animation would end at its starting point\n if (\n animation.reduceMotion &&\n reverse &&\n (numberOfReps <= 0 || numberOfReps % 2 === 0)\n ) {\n animation.current = animation.startValue;\n animation.onFrame = () => true;\n } else {\n nextAnimation.onStart(nextAnimation, value, now, previousAnimation);\n }\n }\n\n return {\n isHigherOrder: true,\n onFrame: repeat,\n onStart,\n reps: 0,\n current: nextAnimation.current,\n callback: repCallback,\n startValue: 0,\n reduceMotion: getReduceMotionForAnimation(reduceMotion),\n };\n }\n );\n} as withRepeatType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;;AAWrE;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAG,SAAAA,CACxBC,cAA6B,EAKD;EAC5B,SAAS;;EAAC,IALVC,YAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAAA,IAChBG,OAAO,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAAA,IACfI,QAA4B,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAAA,IAC5BG,YAA2B,GAAAL,SAAA,CAAAC,MAAA,OAAA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ACF,CAAC;;IAED,SAASY,OAAOA,CACdR,SAA0B,EAC1BW,KAAsB,EACtBV,GAAc,EACdQ,iBAAwC,EAClC;MACNT,SAAS,CAACM,UAAU,GAAGK,KAAK;MAC5BX,SAAS,CAACK,IAAI,GAAG,CAAC;;MAElB;MACA;MACA,IAAIP,aAAa,CAACD,YAAY,KAAKH,SAAS,EAAE;QAC5CI,aAAa,CAACD,YAAY,GAAGG,SAAS,CAACH,YAAY;MACrD;;MAEA;MACA;MACA,IACEG,SAAS,CAACH,YAAY,IACtBF,OAAO,KACNJ,YAAY,IAAI,CAAC,IAAIA,YAAY,GAAG,CAAC,KAAK,CAAC,CAAC,EAC7C;QACAS,SAAS,CAACI,OAAO,GAAGJ,SAAS,CAACM,UAAU;QACxCN,SAAS,CAACG,OAAO,GAAG,MAAM,IAAI;MAChC,CAAC,MAAM;QACLL,aAAa,CAACU,OAAO,CAACV,aAAa,EAAEa,KAAK,EAAEV,GAAG,EAAEQ,iBAAiB,CAAC;MACrE;IACF;IAEA,OAAO;MACLG,aAAa,EAAE,IAAI;MACnBT,OAAO,EAAEJ,MAAM;MACfS,OAAO;MACPH,IAAI,EAAE,CAAC;MACPD,OAAO,EAAEN,aAAa,CAACM,OAAO;MAC9BR,QAAQ,EAAEc,WAAW;MACrBJ,UAAU,EAAE,CAAC;MACbT,YAAY,EAAET,2BAA2B,CAACS,YAAY;IACxD,CAAC;EACH,CAAC,CACF;AACH,CAAmB"}
1
+ {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withRepeat","_nextAnimation","numberOfReps","reverse","callback","reduceMotion","nextAnimation","repeat","animation","now","finished","onFrame","current","reps","startValue","toValue","onStart","previousAnimation","repCallback","value","undefined","isHigherOrder"],"sources":["repeat.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n AnimationCallback,\n AnimatableValue,\n Timestamp,\n AnimationObject,\n ReduceMotion,\n} from '../commonTypes';\nimport type { RepeatAnimation } from './commonTypes';\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withRepeatType = <T extends AnimatableValue>(\n animation: T,\n numberOfReps?: number,\n reverse?: boolean,\n callback?: AnimationCallback,\n reduceMotion?: ReduceMotion\n) => T;\n\n/**\n * Lets you repeat an animation given number of times or run it indefinitely.\n *\n * @param animation - An animation object you want to repeat.\n * @param numberOfReps - The number of times the animation is going to be repeated. Defaults to 2.\n * @param reverse - Whether the animation should run in reverse every other repetition. Defaults to false.\n * @param callback - A function called on animation complete.\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\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/withRepeat\n */\nexport const withRepeat = function <T extends AnimationObject>(\n _nextAnimation: T | (() => T),\n numberOfReps = 2,\n reverse = false,\n callback?: AnimationCallback,\n reduceMotion?: ReduceMotion\n): Animation<RepeatAnimation> {\n 'worklet';\n\n return defineAnimation<RepeatAnimation, T>(\n _nextAnimation,\n (): RepeatAnimation => {\n 'worklet';\n\n const nextAnimation =\n typeof _nextAnimation === 'function'\n ? _nextAnimation()\n : _nextAnimation;\n\n function repeat(animation: RepeatAnimation, now: Timestamp): boolean {\n const finished = nextAnimation.onFrame(nextAnimation, now);\n animation.current = nextAnimation.current;\n if (finished) {\n animation.reps += 1;\n // call inner animation's callback on every repetition\n // as the second argument the animation's current value is passed\n if (nextAnimation.callback) {\n nextAnimation.callback(true /* finished */, animation.current);\n }\n if (\n animation.reduceMotion ||\n (numberOfReps > 0 && animation.reps >= numberOfReps)\n ) {\n return true;\n }\n\n const startValue = reverse\n ? (nextAnimation.current as number)\n : animation.startValue;\n if (reverse) {\n nextAnimation.toValue = animation.startValue;\n animation.startValue = startValue;\n }\n nextAnimation.onStart(\n nextAnimation,\n startValue,\n now,\n nextAnimation.previousAnimation as RepeatAnimation\n );\n return false;\n }\n return false;\n }\n\n const repCallback = (finished?: boolean): void => {\n if (callback) {\n callback(finished);\n }\n // when cancelled call inner animation's callback\n if (!finished && nextAnimation.callback) {\n nextAnimation.callback(false /* finished */);\n }\n };\n\n function onStart(\n animation: RepeatAnimation,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: Animation<any> | null\n ): void {\n animation.startValue = value;\n animation.reps = 0;\n\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 if (nextAnimation.reduceMotion === undefined) {\n nextAnimation.reduceMotion = animation.reduceMotion;\n }\n\n // don't start the animation if reduced motion is enabled and\n // the animation would end at its starting point\n if (\n animation.reduceMotion &&\n reverse &&\n (numberOfReps <= 0 || numberOfReps % 2 === 0)\n ) {\n animation.current = animation.startValue;\n animation.onFrame = () => true;\n } else {\n nextAnimation.onStart(nextAnimation, value, now, previousAnimation);\n }\n }\n\n return {\n isHigherOrder: true,\n onFrame: repeat,\n onStart,\n reps: 0,\n current: nextAnimation.current,\n callback: repCallback,\n startValue: 0,\n reduceMotion: getReduceMotionForAnimation(reduceMotion),\n };\n }\n );\n} as withRepeatType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;;AAWrE;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAG,SAAAA,CACxBC,cAA6B,EAC7BC,YAAY,GAAG,CAAC,EAChBC,OAAO,GAAG,KAAK,EACfC,QAA4B,EAC5BC,YAA2B,EACC;EAC5B,SAAS;;EAET,OAAOP,eAAe,CACpBG,cAAc,EACd,MAAuB;IACrB,SAAS;;IAET,MAAMK,aAAa,GACjB,OAAOL,cAAc,KAAK,UAAU,GAChCA,cAAc,CAAC,CAAC,GAChBA,cAAc;IAEpB,SAASM,MAAMA,CAACC,SAA0B,EAAEC,GAAc,EAAW;MACnE,MAAMC,QA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E;QAC5Cd,aAAa,CAACD,YAAY,GAAGG,SAAS,CAACH,YAAY;MACrD;;MAEA;MACA;MACA,IACEG,SAAS,CAACH,YAAY,IACtBF,OAAO,KACND,YAAY,IAAI,CAAC,IAAIA,YAAY,GAAG,CAAC,KAAK,CAAC,CAAC,EAC7C;QACAM,SAAS,CAACI,OAAO,GAAGJ,SAAS,CAACM,UAAU;QACxCN,SAAS,CAACG,OAAO,GAAG,MAAM,IAAI;MAChC,CAAC,MAAM;QACLL,aAAa,CAACU,OAAO,CAACV,aAAa,EAAEa,KAAK,EAAEV,GAAG,EAAEQ,iBAAiB,CAAC;MACrE;IACF;IAEA,OAAO;MACLI,aAAa,EAAE,IAAI;MACnBV,OAAO,EAAEJ,MAAM;MACfS,OAAO;MACPH,IAAI,EAAE,CAAC;MACPD,OAAO,EAAEN,aAAa,CAACM,OAAO;MAC9BR,QAAQ,EAAEc,WAAW;MACrBJ,UAAU,EAAE,CAAC;MACbT,YAAY,EAAEN,2BAA2B,CAACM,YAAY;IACxD,CAAC;EACH,CACF,CAAC;AACH,CAAmB","ignoreList":[]}
@@ -11,12 +11,9 @@ import { defineAnimation, getReduceMotionForAnimation } from './util';
11
11
  * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSequence
12
12
  */
13
13
 
14
- export function withSequence(_reduceMotionOrFirstAnimation) {
14
+ export function withSequence(_reduceMotionOrFirstAnimation, ..._animations) {
15
15
  'worklet';
16
16
 
17
- for (var _len = arguments.length, _animations = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
18
- _animations[_key - 1] = arguments[_key];
19
- }
20
17
  let reduceMotion;
21
18
 
22
19
  // the first argument is either a config or an animation
@@ -80,7 +77,6 @@ export function withSequence(_reduceMotionOrFirstAnimation) {
80
77
  if (currentAnim.callback) {
81
78
  currentAnim.callback(true /* finished */);
82
79
  }
83
-
84
80
  currentAnim.finished = true;
85
81
  animation.animationIndex = findNextNonReducedMotionAnimationIndex(animation.animationIndex + 1);
86
82
  if (animation.animationIndex < animations.length) {
@@ -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\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;EAC9B,SAAS;;EAAC,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAFPC,WAAW,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAXF,WAAW,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;EAAA;EAGd,IAAIC,YAAsC;;EAE1C;EACA;EACA,IAAIP,6BAA6B,EAAE;IACjC,IAAI,OAAOA,6BAA6B,KAAK,QAAQ,EAAE;MACrDO,YAAY,GAAGP,6BAA6C;IAC9D,CAAC,MAAM;MACLI,WAAW,CAACI,OAAO,CACjBR,6BAA6B,CAC9B;IACH;EACF;EAEA,IAAII,WAAW,CAACD,MAAM,KAAK,CAAC,EAAE;IAC5BM,OAAO,CAACC,IAAI,CAAC,yDAAyD,CAAC;IAEvE,OAAOb,eAAe,CAAoB,CAAC,EAAE,MAAM;MACjD,SAAS;;MACT,OAAO;QACLc,OAAO,EAAEA,CAACC,SAAS,EAAEC,KAAK,KAAMD,SAAS,CAACE,OAAO,GAAGD,KAAM;QAC1DE,OAAO,EAAEA,CAAA,KAAM,IAAI;QACnBD,OAAO,EAAE,CAAC;QACVE,cAAc,EAAE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,QAAQ;MACRjB,YAAY,EAAET,2BAA2B,CAACS,YAAY;IACxD,CAAC;EACH,CAAC,CACF;AACH"}
1
+ {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withSequence","_reduceMotionOrFirstAnimation","_animations","reduceMotion","unshift","length","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,EAC7E,GAAGC,WAA6C,EAClB;EAC9B,SAAS;;EACT,IAAIC,YAAsC;;EAE1C;EACA;EACA,IAAIF,6BAA6B,EAAE;IACjC,IAAI,OAAOA,6BAA6B,KAAK,QAAQ,EAAE;MACrDE,YAAY,GAAGF,6BAA6C;IAC9D,CAAC,MAAM;MACLC,WAAW,CAACE,OAAO,CACjBH,6BACF,CAAC;IACH;EACF;EAEA,IAAIC,WAAW,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5BC,OAAO,CAACC,IAAI,CAAC,yDAAyD,CAAC;IAEvE,OAAOT,eAAe,CAAoB,CAAC,EAAE,MAAM;MACjD,SAAS;;MACT,OAAO;QACLU,OAAO,EAAEA,CAACC,SAAS,EAAEC,KAAK,KAAMD,SAAS,CAACE,OAAO,GAAGD,KAAM;QAC1DE,OAAO,EAAEA,CAAA,KAAM,IAAI;QACnBD,OAAO,EAAE,CAAC;QACVE,cAAc,EAAE,CAAC;QACjBV,YAAY,EAAEJ,2BAA2B,CAACI,YAAY;MACxD,CAAC;IACH,CAAC,CAAC;EACJ;EAEA,OAAOL,eAAe,CACpBI,WAAW,CAAC,CAAC,CAAC,EACd,MAAM;IACJ,SAAS;;IAET,MAAMY,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QACD,IAAIJ,SAAS,CAACI,cAAc,GAAGC,UAAU,CAACT,MAAM,EAAE;UAChD,MAAMqB,QAAQ,GAAGZ,UAAU,CAACL,SAAS,CAACI,cAAc,CAAC;UACrDa,QAAQ,CAAClB,OAAO,CAACkB,QAAQ,EAAED,WAAW,CAACd,OAAO,EAAEa,GAAG,EAAEC,WAAW,CAAC;UACjE,OAAO,KAAK;QACd;QACA,OAAO,IAAI;MACb;MACA,OAAO,KAAK;IACd;IAEA,SAASjB,OAAOA,CACdC,SAA4B,EAC5BC,KAAsB,EACtBc,GAAc,EACdG,iBAAoC,EAC9B;MACN;MACA;MACAb,UAAU,CAACQ,OAAO,CAAEM,IAAI,IAAK;QAC3B,IAAIA,IAAI,CAACzB,YAAY,KAAK0B,SAAS,EAAE;UACnCD,IAAI,CAACzB,YAAY,GAAGM,SAAS,CAACN,YAAY;QAC5C;MACF,CAAC,CAAC;MACFM,SAAS,CAACI,cAAc,GAAGM,sCAAsC,CAAC,CAAC,CAAC;MAEpE,IAAIQ,iBAAiB,KAAKE,SAAS,EAAE;QACnCF,iBAAiB,GAAGb,UAAU,CAC5BA,UAAU,CAACT,MAAM,GAAG,CAAC,CACD;MACxB;MAEA,MAAMyB,gBAAgB,GAAGhB,UAAU,CAACL,SAAS,CAACI,cAAc,CAAC;MAC7DiB,gBAAgB,CAACtB,OAAO,CACtBsB,gBAAgB,EAChBpB,KAAK,EACLc,GAAG,EACHG,iBACF,CAAC;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;MACRlB,YAAY,EAAEJ,2BAA2B,CAACI,YAAY;IACxD,CAAC;EACH,CACF,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","initialCalculations","calculateNewMassToMatchDuration","underDampedSpringCalculations","criticallyDampedSpringCalculations","isAnimationTerminatingCalculation","scaleZetaToMatchClamps","checkIfConfigIsValid","withSpring","toValue","userConfig","callback","defaultConfig","damping","mass","stiffness","overshootClamping","restDisplacementThreshold","restSpeedThreshold","velocity","duration","dampingRatio","reduceMotion","undefined","clamp","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 scaleZetaToMatchClamps,\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 clamp: 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 // eslint-disable-next-line @typescript-eslint/no-shadow\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 if (config.clamp !== undefined) {\n animation.zeta = scaleZetaToMatchClamps(animation, config.clamp);\n }\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,sBAAsB,EACtBC,oBAAoB,QACf,eAAe;;AAEtB;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAIA,CACzBC,OAAwB,EACxBC,UAAyB,EACzBC,QAA4B,KACG;EAC/B,SAAS;;EAET,OAAOZ,eAAe,CAAkBU,OAAO,EAAE,MAAM;IACrD,SAAS;;IACT,MAAMG,aAAkC,GAAG;MACzCC,OAAO,EAAE,EAAE;MACXC,IAAI,EAAE,CAAC;MACPC,SAAS,EAAE,GAAG;MACdC,iBAAiB,EAAE,KAAK;MACxBC,yBAAyB,EAAE,IAAI;MAC/BC,kBAAkB,EAAE,CAAC;MACrBC,QAAQ,EAAE,CAAC;MACXC,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE,GAAG;MACjBC,YAAY,EAAEC,SAAS;MACvBC,KAAK,EAAED;IACT,CAAU;IAEV,MAAME,MAA+C,GAAG;MACtD,GAAGb,aAAa;MAChB,GAAGF,UAAU;MACbgB,WAAW,EAAE,CAAC,EAAEhB,UAAU,aAAVA,UAAU,eAAVA,UAAU,CAAEU,QAAQ,IAAIV,UAAU,aAAVA,UAAU,eAAVA,UAAU,CAAEW,YAAY,CAAC;MACjEM,aAAa,EAAE;IACjB,CAAC;IAEDF,MAAM,CAACE,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M,EAAE,CAAC;MACTrB,YAAY,EAAEtB,2BAA2B,CAACyB,MAAM,CAACH,YAAY;IAC/D,CAAC;EACH,CAAC,CAAC;AACJ,CAAoB"}
1
+ {"version":3,"names":["defineAnimation","getReduceMotionForAnimation","initialCalculations","calculateNewMassToMatchDuration","underDampedSpringCalculations","criticallyDampedSpringCalculations","isAnimationTerminatingCalculation","scaleZetaToMatchClamps","checkIfConfigIsValid","withSpring","toValue","userConfig","callback","defaultConfig","damping","mass","stiffness","overshootClamping","restDisplacementThreshold","restSpeedThreshold","velocity","duration","dampingRatio","reduceMotion","undefined","clamp","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 scaleZetaToMatchClamps,\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 clamp: 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 // eslint-disable-next-line @typescript-eslint/no-shadow\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 if (config.clamp !== undefined) {\n animation.zeta = scaleZetaToMatchClamps(animation, config.clamp);\n }\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,sBAAsB,EACtBC,oBAAoB,QACf,eAAe;;AAEtB;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAIA,CACzBC,OAAwB,EACxBC,UAAyB,EACzBC,QAA4B,KACG;EAC/B,SAAS;;EAET,OAAOZ,eAAe,CAAkBU,OAAO,EAAE,MAAM;IACrD,SAAS;;IACT,MAAMG,aAAkC,GAAG;MACzCC,OAAO,EAAE,EAAE;MACXC,IAAI,EAAE,CAAC;MACPC,SAAS,EAAE,GAAG;MACdC,iBAAiB,EAAE,KAAK;MACxBC,yBAAyB,EAAE,IAAI;MAC/BC,kBAAkB,EAAE,CAAC;MACrBC,QAAQ,EAAE,CAAC;MACXC,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE,GAAG;MACjBC,YAAY,EAAEC,SAAS;MACvBC,KAAK,EAAED;IACT,CAAU;IAEV,MAAME,MAA+C,GAAG;MACtD,GAAGb,aAAa;MAChB,GAAGF,UAAU;MACbgB,WAAW,EAAE,CAA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,EAAEvB,OAAO;MAChB8C,UAAU,EAAE,CAAC;MACb5C,QAAQ;MACRuB,aAAa,EAAE,CAAC;MAChBH,cAAc,EAAE,CAAC;MACjBU,IAAI,EAAE,CAAC;MACPC,MAAM,EAAE,CAAC;MACTC,MAAM,EAAE,CAAC;MACTrB,YAAY,EAAEtB,2BAA2B,CAACyB,MAAM,CAACH,YAAY;IAC/D,CAAC;EACH,CAAC,CAAC;AACJ,CAAoB","ignoreList":[]}
@@ -18,6 +18,7 @@
18
18
 
19
19
  // This type contains all the properties from SpringConfig, which are changed to be required,
20
20
  // except for optional 'reduceMotion' and 'clamp'
21
+
21
22
  export function checkIfConfigIsValid(config) {
22
23
  'worklet';
23
24
 
@@ -42,15 +43,14 @@ export function checkIfConfigIsValid(config) {
42
43
  }
43
44
 
44
45
  // ts-prune-ignore-next This function is exported to be tested
45
- export function bisectRoot(_ref) {
46
+ export function bisectRoot({
47
+ min,
48
+ max,
49
+ func,
50
+ maxIterations = 20
51
+ }) {
46
52
  'worklet';
47
53
 
48
- let {
49
- min,
50
- max,
51
- func,
52
- maxIterations = 20
53
- } = _ref;
54
54
  const ACCURACY = 0.00005;
55
55
  let idx = maxIterations;
56
56
  let current = (max + min) / 2;
@@ -65,11 +65,9 @@ export function bisectRoot(_ref) {
65
65
  }
66
66
  return current;
67
67
  }
68
- export function initialCalculations() {
68
+ export function initialCalculations(mass = 0, config) {
69
69
  'worklet';
70
70
 
71
- let mass = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
72
- let config = arguments.length > 1 ? arguments[1] : undefined;
73
71
  if (config.skipAnimation) {
74
72
  return {
75
73
  zeta: 0,
@@ -1 +1 @@
1
- {"version":3,"names":["checkIfConfigIsValid","config","_config$clamp","_config$clamp2","errorMessage","forEach","prop","value","duration","clamp","min","max","console","warn","bisectRoot","_ref","func","maxIterations","ACCURACY","idx","current","Math","abs","initialCalculations","mass","arguments","length","undefined","skipAnimation","zeta","omega0","omega1","useDuration","stiffness","k","dampingRatio","sqrt","damping","c","m","scaleZetaToMatchClamps","animation","toValue","startValue","toValueNum","Number","firstBound","secondBound","relativeExtremum1","relativeExtremum2","newZeta1","log","PI","newZeta2","zetaSatisfyingClamp","filter","x","calculateNewMassToMatchDuration","x0","v0","restSpeedThreshold","threshold","durationForMass","amplitude","exp","criticallyDampedSpringCalculations","precalculatedValues","t","criticallyDampedEnvelope","criticallyDampedPosition","criticallyDampedVelocity","position","velocity","underDampedSpringCalculations","sin1","sin","cos1","cos","underDampedEnvelope","underDampedFrag1","underDampedPosition","underDampedVelocity","isAnimationTerminatingCalculation","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 clamp?: never;\n }\n | {\n mass?: never;\n damping?: never;\n duration?: number;\n dampingRatio?: number;\n clamp?: { min?: number; max?: number };\n }\n);\n\n// This type contains all the properties from SpringConfig, which are changed to be required,\n// except for optional 'reduceMotion' and 'clamp'\nexport type DefaultSpringConfig = {\n [K in keyof Required<SpringConfig>]: K extends 'reduceMotion' | 'clamp'\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 (\n config.clamp?.min &&\n config.clamp?.max &&\n config.clamp.min > config.clamp.max\n ) {\n errorMessage += `, clamp.min should be lower than clamp.max, got clamp: {min: ${config.clamp.min}, max: ${config.clamp.max}} `;\n }\n\n if (errorMessage !== '') {\n console.warn('[Reanimated] Invalid spring config' + errorMessage);\n }\n\n return errorMessage === '';\n}\n\n// ts-prune-ignore-next This function is exported to be tested\nexport function 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\n/** We make an assumption that we can manipulate zeta without changing duration of movement.\n * According to theory this change is small and tests shows that we can indeed ignore it.\n */\nexport function scaleZetaToMatchClamps(\n animation: SpringAnimation,\n clamp: { min?: number; max?: number }\n): number {\n 'worklet';\n const { zeta, toValue, startValue } = animation;\n const toValueNum = Number(toValue);\n\n if (toValueNum === startValue) {\n return zeta;\n }\n\n const [firstBound, secondBound] =\n toValueNum - startValue > 0\n ? [clamp.min, clamp.max]\n : [clamp.max, clamp.min];\n\n /** The extrema we get from equation below are relative (we obtain a ratio),\n * To get absolute extrema we convert it as follows:\n *\n * AbsoluteExtremum = startValue ± RelativeExtremum * (toValue - startValue)\n * Where ± denotes:\n * + if extremum is over the target\n * - otherwise\n */\n\n const relativeExtremum1 =\n secondBound !== undefined\n ? Math.abs((secondBound - toValueNum) / (toValueNum - startValue))\n : undefined;\n\n const relativeExtremum2 =\n firstBound !== undefined\n ? Math.abs((firstBound - toValueNum) / (toValueNum - startValue))\n : undefined;\n\n /** Use this formula http://hyperphysics.phy-astr.gsu.edu/hbase/oscda.html to calculate\n * first two extrema. These extrema are located where cos = +- 1\n *\n * Therefore the first two extrema are:\n *\n * Math.exp(-zeta * Math.PI); (over the target)\n * Math.exp(-zeta * 2 * Math.PI); (before the target)\n */\n\n const newZeta1 =\n relativeExtremum1 !== undefined\n ? Math.abs(Math.log(relativeExtremum1) / Math.PI)\n : undefined;\n\n const newZeta2 =\n relativeExtremum2 !== undefined\n ? Math.abs(Math.log(relativeExtremum2) / (2 * Math.PI))\n : undefined;\n\n const zetaSatisfyingClamp = [newZeta1, newZeta2].filter(\n (x: number | undefined): x is number => x !== undefined\n );\n // The bigger is zeta the smaller are bounces, we return the biggest one\n // because it should satisfy all conditions\n return Math.max(...zetaSatisfyingClamp, zeta);\n}\n\n/** Runs before initial */\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;;AAyBA;AACA;AA8BA,OAAO,SAASA,oBAAoBA,CAACC,MAA2B,EAAW;EACzE,SAAS;;EAAC,IAAAC,aAAA,EAAAC,cAAA;EACV,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,GAAGN,MAAM,CAACK,IAAI,CAAC;IAC1B,IAAIC,KAAK,IAAI,CAAC,EAAE;MACdH,YAAY,IAAK,KAAIE,IAAK,qCAAoCC,KAAM,EAAC;IACvE;EACF,CAAC,CAAC;EAEF,IAAIN,MAAM,CAACO,QAAQ,GAAG,CAAC,EAAE;IACvBJ,YAAY,IAAK,qCAAoCH,MAAM,CAACO,QAAS,EAAC;EACxE;EAEA,IACE,CAAAN,aAAA,GAAAD,MAAM,CAACQ,KAAK,cAAAP,aAAA,eAAZA,aAAA,CAAcQ,GAAG,KAAAP,cAAA,GACjBF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G9B,IAAI,GAAGC,MAAM,GAAG4B,EAAE,IAAI3B,MAAM,CAAC,GAAG2B,EAAE,GAAGkB,IAAI,CAAC;EAE3D,MAAMI,mBAAmB,GAAGtC,OAAO,GAAGqC,gBAAgB;EACtD;EACA,MAAME,mBAAmB,GACvBpD,IAAI,GAAGC,MAAM,GAAGiD,gBAAgB,GAChCD,mBAAmB,IAChBF,IAAI,IAAIjB,EAAE,GAAG9B,IAAI,GAAGC,MAAM,GAAG4B,EAAE,CAAC,GAAG3B,MAAM,GAAG2B,EAAE,GAAGgB,IAAI,CAAC;EAE3D,OAAO;IAAEH,QAAQ,EAAES,mBAAmB;IAAER,QAAQ,EAAES;EAAoB,CAAC;AACzE;AAEA,OAAO,SAASC,iCAAiCA,CAC/CzC,SAA+B,EAC/BxC,MAA2B,EAK3B;EACA,SAAS;;EACT,MAAM;IAAEyC,OAAO;IAAE8B,QAAQ;IAAE7B,UAAU;IAAEvB;EAAQ,CAAC,GAAGqB,SAAS;EAE5D,MAAM0C,cAAc,GAAGlF,MAAM,CAACmF,iBAAiB,GAC1ChE,OAAO,GAAGsB,OAAO,IAAIC,UAAU,GAAGD,OAAO,IACzCtB,OAAO,GAAGsB,OAAO,IAAIC,UAAU,GAAGD,OAAQ,GAC3C,KAAK;EAET,MAAM2C,UAAU,GAAGhE,IAAI,CAACC,GAAG,CAACkD,QAAQ,CAAC,GAAGvE,MAAM,CAAC2D,kBAAkB;EACjE,MAAM0B,cAAc,GAClBjE,IAAI,CAACC,GAAG,CAACoB,OAAO,GAAGtB,OAAO,CAAC,GAAGnB,MAAM,CAACsF,yBAAyB;EAEhE,OAAO;IAAEJ,cAAc;IAAEE,UAAU;IAAEC;EAAe,CAAC;AACvD"}
1
+ {"version":3,"names":["checkIfConfigIsValid","config","_config$clamp","_config$clamp2","errorMessage","forEach","prop","value","duration","clamp","min","max","console","warn","bisectRoot","func","maxIterations","ACCURACY","idx","current","Math","abs","initialCalculations","mass","skipAnimation","zeta","omega0","omega1","useDuration","stiffness","k","dampingRatio","sqrt","damping","c","m","scaleZetaToMatchClamps","animation","toValue","startValue","toValueNum","Number","firstBound","secondBound","relativeExtremum1","undefined","relativeExtremum2","newZeta1","log","PI","newZeta2","zetaSatisfyingClamp","filter","x","calculateNewMassToMatchDuration","x0","v0","restSpeedThreshold","threshold","durationForMass","amplitude","exp","criticallyDampedSpringCalculations","precalculatedValues","t","criticallyDampedEnvelope","criticallyDampedPosition","criticallyDampedVelocity","position","velocity","underDampedSpringCalculations","sin1","sin","cos1","cos","underDampedEnvelope","underDampedFrag1","underDampedPosition","underDampedVelocity","isAnimationTerminatingCalculation","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 clamp?: never;\n }\n | {\n mass?: never;\n damping?: never;\n duration?: number;\n dampingRatio?: number;\n clamp?: { min?: number; max?: number };\n }\n);\n\n// This type contains all the properties from SpringConfig, which are changed to be required,\n// except for optional 'reduceMotion' and 'clamp'\nexport type DefaultSpringConfig = {\n [K in keyof Required<SpringConfig>]: K extends 'reduceMotion' | 'clamp'\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 (\n config.clamp?.min &&\n config.clamp?.max &&\n config.clamp.min > config.clamp.max\n ) {\n errorMessage += `, clamp.min should be lower than clamp.max, got clamp: {min: ${config.clamp.min}, max: ${config.clamp.max}} `;\n }\n\n if (errorMessage !== '') {\n console.warn('[Reanimated] Invalid spring config' + errorMessage);\n }\n\n return errorMessage === '';\n}\n\n// ts-prune-ignore-next This function is exported to be tested\nexport function 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\n/** We make an assumption that we can manipulate zeta without changing duration of movement.\n * According to theory this change is small and tests shows that we can indeed ignore it.\n */\nexport function scaleZetaToMatchClamps(\n animation: SpringAnimation,\n clamp: { min?: number; max?: number }\n): number {\n 'worklet';\n const { zeta, toValue, startValue } = animation;\n const toValueNum = Number(toValue);\n\n if (toValueNum === startValue) {\n return zeta;\n }\n\n const [firstBound, secondBound] =\n toValueNum - startValue > 0\n ? [clamp.min, clamp.max]\n : [clamp.max, clamp.min];\n\n /** The extrema we get from equation below are relative (we obtain a ratio),\n * To get absolute extrema we convert it as follows:\n *\n * AbsoluteExtremum = startValue ± RelativeExtremum * (toValue - startValue)\n * Where ± denotes:\n * + if extremum is over the target\n * - otherwise\n */\n\n const relativeExtremum1 =\n secondBound !== undefined\n ? Math.abs((secondBound - toValueNum) / (toValueNum - startValue))\n : undefined;\n\n const relativeExtremum2 =\n firstBound !== undefined\n ? Math.abs((firstBound - toValueNum) / (toValueNum - startValue))\n : undefined;\n\n /** Use this formula http://hyperphysics.phy-astr.gsu.edu/hbase/oscda.html to calculate\n * first two extrema. These extrema are located where cos = +- 1\n *\n * Therefore the first two extrema are:\n *\n * Math.exp(-zeta * Math.PI); (over the target)\n * Math.exp(-zeta * 2 * Math.PI); (before the target)\n */\n\n const newZeta1 =\n relativeExtremum1 !== undefined\n ? Math.abs(Math.log(relativeExtremum1) / Math.PI)\n : undefined;\n\n const newZeta2 =\n relativeExtremum2 !== undefined\n ? Math.abs(Math.log(relativeExtremum2) / (2 * Math.PI))\n : undefined;\n\n const zetaSatisfyingClamp = [newZeta1, newZeta2].filter(\n (x: number | undefined): x is number => x !== undefined\n );\n // The bigger is zeta the smaller are bounces, we return the biggest one\n // because it should satisfy all conditions\n return Math.max(...zetaSatisfyingClamp, zeta);\n}\n\n/** Runs before initial */\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;;AAyBA;AACA;;AA8BA,OAAO,SAASA,oBAAoBA,CAACC,MAA2B,EAAW;EACzE,SAAS;;EAAC,IAAAC,aAAA,EAAAC,cAAA;EACV,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,GAAGN,MAAM,CAACK,IAAI,CAAC;IAC1B,IAAIC,KAAK,IAAI,CAAC,EAAE;MACdH,YAAY,IAAK,KAAIE,IAAK,qCAAoCC,KAAM,EAAC;IACvE;EACF,CAAC,CAAC;EAEF,IAAIN,MAAM,CAACO,QAAQ,GAAG,CAAC,EAAE;IACvBJ,YAAY,IAAK,qCAAoCH,MAAM,CAACO,QAAS,EAAC;EACxE;EAEA,IACE,CAAAN,aAAA,GAAAD,MAAM,CAACQ,KAAK,cAAAP,aAAA,eAAZA,aAAA,CAAcQ,GAA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AAME,mBAAmB,GACvBrD,IAAI,GAAGC,MAAM,GAAGkD,gBAAgB,GAChCD,mBAAmB,IAChBF,IAAI,IAAIjB,EAAE,GAAG/B,IAAI,GAAGC,MAAM,GAAG6B,EAAE,CAAC,GAAG5B,MAAM,GAAG4B,EAAE,GAAGgB,IAAI,CAAC;EAE3D,OAAO;IAAEH,QAAQ,EAAES,mBAAmB;IAAER,QAAQ,EAAES;EAAoB,CAAC;AACzE;AAEA,OAAO,SAASC,iCAAiCA,CAC/C1C,SAA+B,EAC/BpC,MAA2B,EAK3B;EACA,SAAS;;EACT,MAAM;IAAEqC,OAAO;IAAE+B,QAAQ;IAAE9B,UAAU;IAAEpB;EAAQ,CAAC,GAAGkB,SAAS;EAE5D,MAAM2C,cAAc,GAAG/E,MAAM,CAACgF,iBAAiB,GAC1C9D,OAAO,GAAGmB,OAAO,IAAIC,UAAU,GAAGD,OAAO,IACzCnB,OAAO,GAAGmB,OAAO,IAAIC,UAAU,GAAGD,OAAQ,GAC3C,KAAK;EAET,MAAM4C,UAAU,GAAG9D,IAAI,CAACC,GAAG,CAACgD,QAAQ,CAAC,GAAGpE,MAAM,CAACwD,kBAAkB;EACjE,MAAM0B,cAAc,GAClB/D,IAAI,CAACC,GAAG,CAACiB,OAAO,GAAGnB,OAAO,CAAC,GAAGlB,MAAM,CAACmF,yBAAyB;EAEhE,OAAO;IAAEJ,cAAc;IAAEE,UAAU;IAAEC;EAAe,CAAC;AACvD","ignoreList":[]}
@@ -85,10 +85,11 @@ export function withStyleAnimation(styleAnimations) {
85
85
  } else {
86
86
  stillGoing = true;
87
87
  }
88
- if (ColorProperties.includes(currentEntry.path[0])) {
89
- currentStyleAnimation.current = processColor(currentStyleAnimation.current);
90
- }
91
- setPath(animation.current, currentEntry.path, currentStyleAnimation.current);
88
+
89
+ // When working with animations changing colors, we need to make sure that each one of them begins with a rgba, not a processed number.
90
+ // Thus, we only set the path to a processed color, but currentStyleAnimation.current stays as rgba.
91
+ const isAnimatingColorProp = ColorProperties.includes(currentEntry.path[0]);
92
+ setPath(animation.current, currentEntry.path, isAnimatingColorProp ? processColor(currentStyleAnimation.current) : currentStyleAnimation.current);
92
93
  }
93
94
  }
94
95
  return !stillGoing;
@@ -1 +1 @@
1
- {"version":3,"names":["defineAnimation","withTiming","ColorProperties","processColor","resolvePath","obj","path","keys","Array","isArray","reduce","acc","current","undefined","setPath","value","currObj","i","length","withStyleAnimation","styleAnimations","onFrame","animation","now","stillGoing","entriesToCheck","currentEntry","pop","index","push","concat","key","Object","currentStyleAnimation","finished","callback","includes","onStart","previousAnimation","prevAnimation","prevVal","console","warn","join","currentAnimation","duration","animationsToCheck","element","values","isHigherOrder"],"sources":["styleAnimation.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation } from './util';\nimport type {\n Timestamp,\n AnimatableValue,\n AnimationObject,\n Animation,\n NestedObject,\n NestedObjectValues,\n} from '../commonTypes';\nimport type { AnimatedStyle } from '../helperTypes';\nimport type { StyleLayoutAnimation } from './commonTypes';\nimport { withTiming } from './timing';\nimport { ColorProperties, processColor } from '../Colors';\n\n// resolves path to value for nested objects\n// if path cannot be resolved returns undefined\nfunction resolvePath<T>(\n obj: NestedObject<T>,\n path: AnimatableValue[] | AnimatableValue\n): NestedObjectValues<T> | undefined {\n 'worklet';\n const keys: AnimatableValue[] = Array.isArray(path) ? path : [path];\n return keys.reduce<NestedObjectValues<T> | undefined>((acc, current) => {\n if (Array.isArray(acc) && typeof current === 'number') {\n return acc[current];\n } else if (\n acc !== null &&\n typeof acc === 'object' &&\n (current as number | string) in acc\n ) {\n return (acc as { [key: string]: NestedObjectValues<T> })[\n current as number | string\n ];\n }\n return undefined;\n }, obj);\n}\n\n// set value at given path\ntype Path = Array<string | number> | string | number;\nfunction setPath<T>(\n obj: NestedObject<T>,\n path: Path,\n value: NestedObjectValues<T>\n): void {\n 'worklet';\n const keys: Path = Array.isArray(path) ? path : [path];\n let currObj: NestedObjectValues<T> = obj;\n for (let i = 0; i < keys.length - 1; i++) {\n // creates entry if there isn't one\n currObj = currObj as { [key: string]: NestedObjectValues<T> };\n if (!(keys[i] in currObj)) {\n // if next key is a number create an array\n if (typeof keys[i + 1] === 'number') {\n currObj[keys[i]] = [];\n } else {\n currObj[keys[i]] = {};\n }\n }\n currObj = currObj[keys[i]];\n }\n\n (currObj as { [key: string]: NestedObjectValues<T> })[keys[keys.length - 1]] =\n value;\n}\n\ninterface NestedObjectEntry<T> {\n value: NestedObjectValues<T>;\n path: (string | number)[];\n}\n\nexport function withStyleAnimation(\n styleAnimations: AnimatedStyle<any>\n): StyleLayoutAnimation {\n 'worklet';\n return defineAnimation<StyleLayoutAnimation>({}, () => {\n 'worklet';\n\n const onFrame = (\n animation: StyleLayoutAnimation,\n now: Timestamp\n ): boolean => {\n let stillGoing = false;\n const entriesToCheck: NestedObjectEntry<AnimationObject>[] = [\n { value: animation.styleAnimations, path: [] },\n ];\n while (entriesToCheck.length > 0) {\n const currentEntry: NestedObjectEntry<AnimationObject> =\n entriesToCheck.pop() as NestedObjectEntry<AnimationObject>;\n if (Array.isArray(currentEntry.value)) {\n for (let index = 0; index < currentEntry.value.length; index++) {\n entriesToCheck.push({\n value: currentEntry.value[index],\n path: currentEntry.path.concat(index),\n });\n }\n } else if (\n typeof currentEntry.value === 'object' &&\n currentEntry.value.onFrame === undefined\n ) {\n // nested object\n for (const key of Object.keys(currentEntry.value)) {\n entriesToCheck.push({\n value: currentEntry.value[key],\n path: currentEntry.path.concat(key),\n });\n }\n } else {\n const currentStyleAnimation: AnimationObject =\n currentEntry.value as AnimationObject;\n if (currentStyleAnimation.finished) {\n continue;\n }\n const finished = currentStyleAnimation.onFrame(\n currentStyleAnimation,\n now\n );\n if (finished) {\n currentStyleAnimation.finished = true;\n if (currentStyleAnimation.callback) {\n currentStyleAnimation.callback(true);\n }\n } else {\n stillGoing = true;\n }\n\n if (ColorProperties.includes(currentEntry.path[0] as string)) {\n currentStyleAnimation.current = processColor(\n currentStyleAnimation.current\n ) as number;\n }\n\n setPath(\n animation.current,\n currentEntry.path,\n currentStyleAnimation.current\n );\n }\n }\n return !stillGoing;\n };\n\n const onStart = (\n animation: StyleLayoutAnimation,\n value: AnimatedStyle<any>,\n now: Timestamp,\n previousAnimation: StyleLayoutAnimation\n ): void => {\n const entriesToCheck: NestedObjectEntry<\n AnimationObject | AnimatableValue\n >[] = [{ value: styleAnimations, path: [] }];\n while (entriesToCheck.length > 0) {\n const currentEntry: NestedObjectEntry<\n AnimationObject | AnimatableValue\n > = entriesToCheck.pop() as NestedObjectEntry<\n AnimationObject | AnimatableValue\n >;\n if (Array.isArray(currentEntry.value)) {\n for (let index = 0; index < currentEntry.value.length; index++) {\n entriesToCheck.push({\n value: currentEntry.value[index],\n path: currentEntry.path.concat(index),\n });\n }\n } else if (\n typeof currentEntry.value === 'object' &&\n currentEntry.value.onStart === undefined\n ) {\n for (const key of Object.keys(currentEntry.value)) {\n entriesToCheck.push({\n value: currentEntry.value[key],\n path: currentEntry.path.concat(key),\n });\n }\n } else {\n const prevAnimation = resolvePath(\n previousAnimation?.styleAnimations,\n currentEntry.path\n );\n let prevVal = resolvePath(value, currentEntry.path);\n if (prevAnimation && !prevVal) {\n prevVal = (prevAnimation as any).current;\n }\n if (prevVal === undefined) {\n console.warn(\n `Initial values for animation are missing for property ${currentEntry.path.join(\n '.'\n )}`\n );\n }\n setPath(animation.current, currentEntry.path, prevVal);\n let currentAnimation: AnimationObject;\n if (\n typeof currentEntry.value !== 'object' ||\n !currentEntry.value.onStart\n ) {\n currentAnimation = withTiming(\n currentEntry.value as AnimatableValue,\n { duration: 0 }\n ) as AnimationObject; // TODO TYPESCRIPT this temporary cast is to get rid of .d.ts file.\n setPath(\n animation.styleAnimations,\n currentEntry.path,\n currentAnimation\n );\n } else {\n currentAnimation = currentEntry.value as Animation<AnimationObject>;\n }\n currentAnimation.onStart(\n currentAnimation,\n prevVal,\n now,\n prevAnimation\n );\n }\n }\n };\n\n const callback = (finished: boolean): void => {\n if (!finished) {\n const animationsToCheck: NestedObjectValues<AnimationObject>[] = [\n styleAnimations,\n ];\n while (animationsToCheck.length > 0) {\n const currentAnimation: NestedObjectValues<AnimationObject> =\n animationsToCheck.pop() as NestedObjectValues<AnimationObject>;\n if (Array.isArray(currentAnimation)) {\n for (const element of currentAnimation) {\n animationsToCheck.push(element);\n }\n } else if (\n typeof currentAnimation === 'object' &&\n currentAnimation.onStart === undefined\n ) {\n for (const value of Object.values(currentAnimation)) {\n animationsToCheck.push(value);\n }\n } else {\n const currentStyleAnimation: AnimationObject =\n currentAnimation as AnimationObject;\n if (\n !currentStyleAnimation.finished &&\n currentStyleAnimation.callback\n ) {\n currentStyleAnimation.callback(false);\n }\n }\n }\n }\n };\n\n return {\n isHigherOrder: true,\n onFrame,\n onStart,\n current: {},\n styleAnimations,\n callback,\n } as StyleLayoutAnimation;\n });\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,QAAQ,QAAQ;AAWxC,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,eAAe,EAAEC,YAAY,QAAQ,WAAW;;AAEzD;AACA;AACA,SAASC,WAAWA,CAClBC,GAAoB,EACpBC,IAAyC,EACN;EACnC,SAAS;;EACT,MAAMC,IAAuB,GAAGC,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,GAAGA,IAAI,GAAG,CAACA,IAAI,CAAC;EACnE,OAAOC,IAAI,CAACG,MAAM,CAAoC,CAACC,GAAG,EAAEC,OAAO,KAAK;IACtE,IAAIJ,KAAK,CAACC,OAAO,CAACE,GAAG,CAAC,IAAI,OAAOC,OAAO,KAAK,QAAQ,EAAE;MACrD,OAAOD,GAAG,CAACC,OAAO,CAAC;IACrB,CAAC,MAAM,IACLD,GAAG,KAAK,IAAI,IACZ,OAAOA,GAAG,KAAK,QAAQ,IACtBC,OAAO,IAAwBD,GAAG,EACnC;MACA,OAAQA,GAAG,CACTC,OAAO,CACR;IACH;IACA,OAAOC,SAAS;EAClB,CAAC,EAAER,GAAG,CAAC;AAC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G,CAC/D1B,eAAe,CAChB;QACD,OAAO0B,iBAAiB,CAAC5B,MAAM,GAAG,CAAC,EAAE;UACnC,MAAM0B,gBAAqD,GACzDE,iBAAiB,CAACnB,GAAG,EAAyC;UAChE,IAAInB,KAAK,CAACC,OAAO,CAACmC,gBAAgB,CAAC,EAAE;YACnC,KAAK,MAAMG,OAAO,IAAIH,gBAAgB,EAAE;cACtCE,iBAAiB,CAACjB,IAAI,CAACkB,OAAO,CAAC;YACjC;UACF,CAAC,MAAM,IACL,OAAOH,gBAAgB,KAAK,QAAQ,IACpCA,gBAAgB,CAACP,OAAO,KAAKxB,SAAS,EACtC;YACA,KAAK,MAAME,KAAK,IAAIiB,MAAM,CAACgB,MAAM,CAACJ,gBAAgB,CAAC,EAAE;cACnDE,iBAAiB,CAACjB,IAAI,CAACd,KAAK,CAAC;YAC/B;UACF,CAAC,MAAM;YACL,MAAMkB,qBAAsC,GAC1CW,gBAAmC;YACrC,IACE,CAACX,qBAAqB,CAACC,QAAQ,IAC/BD,qBAAqB,CAACE,QAAQ,EAC9B;cACAF,qBAAqB,CAACE,QAAQ,CAAC,KAAK,CAAC;YACvC;UACF;QACF;MACF;IACF,CAAC;IAED,OAAO;MACLc,aAAa,EAAE,IAAI;MACnB5B,OAAO;MACPgB,OAAO;MACPzB,OAAO,EAAE,CAAC,CAAC;MACXQ,eAAe;MACfe;IACF,CAAC;EACH,CAAC,CAAC;AACJ"}
1
+ {"version":3,"names":["defineAnimation","withTiming","ColorProperties","processColor","resolvePath","obj","path","keys","Array","isArray","reduce","acc","current","undefined","setPath","value","currObj","i","length","withStyleAnimation","styleAnimations","onFrame","animation","now","stillGoing","entriesToCheck","currentEntry","pop","index","push","concat","key","Object","currentStyleAnimation","finished","callback","isAnimatingColorProp","includes","onStart","previousAnimation","prevAnimation","prevVal","console","warn","join","currentAnimation","duration","animationsToCheck","element","values","isHigherOrder"],"sources":["styleAnimation.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation } from './util';\nimport type {\n Timestamp,\n AnimatableValue,\n AnimationObject,\n Animation,\n NestedObject,\n NestedObjectValues,\n} from '../commonTypes';\nimport type { AnimatedStyle } from '../helperTypes';\nimport type { StyleLayoutAnimation } from './commonTypes';\nimport { withTiming } from './timing';\nimport { ColorProperties, processColor } from '../Colors';\n\n// resolves path to value for nested objects\n// if path cannot be resolved returns undefined\nfunction resolvePath<T>(\n obj: NestedObject<T>,\n path: AnimatableValue[] | AnimatableValue\n): NestedObjectValues<T> | undefined {\n 'worklet';\n const keys: AnimatableValue[] = Array.isArray(path) ? path : [path];\n return keys.reduce<NestedObjectValues<T> | undefined>((acc, current) => {\n if (Array.isArray(acc) && typeof current === 'number') {\n return acc[current];\n } else if (\n acc !== null &&\n typeof acc === 'object' &&\n (current as number | string) in acc\n ) {\n return (acc as { [key: string]: NestedObjectValues<T> })[\n current as number | string\n ];\n }\n return undefined;\n }, obj);\n}\n\n// set value at given path\ntype Path = Array<string | number> | string | number;\nfunction setPath<T>(\n obj: NestedObject<T>,\n path: Path,\n value: NestedObjectValues<T>\n): void {\n 'worklet';\n const keys: Path = Array.isArray(path) ? path : [path];\n let currObj: NestedObjectValues<T> = obj;\n for (let i = 0; i < keys.length - 1; i++) {\n // creates entry if there isn't one\n currObj = currObj as { [key: string]: NestedObjectValues<T> };\n if (!(keys[i] in currObj)) {\n // if next key is a number create an array\n if (typeof keys[i + 1] === 'number') {\n currObj[keys[i]] = [];\n } else {\n currObj[keys[i]] = {};\n }\n }\n currObj = currObj[keys[i]];\n }\n\n (currObj as { [key: string]: NestedObjectValues<T> })[keys[keys.length - 1]] =\n value;\n}\n\ninterface NestedObjectEntry<T> {\n value: NestedObjectValues<T>;\n path: (string | number)[];\n}\n\nexport function withStyleAnimation(\n styleAnimations: AnimatedStyle<any>\n): StyleLayoutAnimation {\n 'worklet';\n return defineAnimation<StyleLayoutAnimation>({}, () => {\n 'worklet';\n\n const onFrame = (\n animation: StyleLayoutAnimation,\n now: Timestamp\n ): boolean => {\n let stillGoing = false;\n const entriesToCheck: NestedObjectEntry<AnimationObject>[] = [\n { value: animation.styleAnimations, path: [] },\n ];\n while (entriesToCheck.length > 0) {\n const currentEntry: NestedObjectEntry<AnimationObject> =\n entriesToCheck.pop() as NestedObjectEntry<AnimationObject>;\n if (Array.isArray(currentEntry.value)) {\n for (let index = 0; index < currentEntry.value.length; index++) {\n entriesToCheck.push({\n value: currentEntry.value[index],\n path: currentEntry.path.concat(index),\n });\n }\n } else if (\n typeof currentEntry.value === 'object' &&\n currentEntry.value.onFrame === undefined\n ) {\n // nested object\n for (const key of Object.keys(currentEntry.value)) {\n entriesToCheck.push({\n value: currentEntry.value[key],\n path: currentEntry.path.concat(key),\n });\n }\n } else {\n const currentStyleAnimation: AnimationObject =\n currentEntry.value as AnimationObject;\n if (currentStyleAnimation.finished) {\n continue;\n }\n const finished = currentStyleAnimation.onFrame(\n currentStyleAnimation,\n now\n );\n if (finished) {\n currentStyleAnimation.finished = true;\n if (currentStyleAnimation.callback) {\n currentStyleAnimation.callback(true);\n }\n } else {\n stillGoing = true;\n }\n\n // When working with animations changing colors, we need to make sure that each one of them begins with a rgba, not a processed number.\n // Thus, we only set the path to a processed color, but currentStyleAnimation.current stays as rgba.\n const isAnimatingColorProp = ColorProperties.includes(\n currentEntry.path[0] as string\n );\n\n setPath(\n animation.current,\n currentEntry.path,\n isAnimatingColorProp\n ? processColor(currentStyleAnimation.current)\n : currentStyleAnimation.current\n );\n }\n }\n return !stillGoing;\n };\n\n const onStart = (\n animation: StyleLayoutAnimation,\n value: AnimatedStyle<any>,\n now: Timestamp,\n previousAnimation: StyleLayoutAnimation\n ): void => {\n const entriesToCheck: NestedObjectEntry<\n AnimationObject | AnimatableValue\n >[] = [{ value: styleAnimations, path: [] }];\n while (entriesToCheck.length > 0) {\n const currentEntry: NestedObjectEntry<\n AnimationObject | AnimatableValue\n > = entriesToCheck.pop() as NestedObjectEntry<\n AnimationObject | AnimatableValue\n >;\n if (Array.isArray(currentEntry.value)) {\n for (let index = 0; index < currentEntry.value.length; index++) {\n entriesToCheck.push({\n value: currentEntry.value[index],\n path: currentEntry.path.concat(index),\n });\n }\n } else if (\n typeof currentEntry.value === 'object' &&\n currentEntry.value.onStart === undefined\n ) {\n for (const key of Object.keys(currentEntry.value)) {\n entriesToCheck.push({\n value: currentEntry.value[key],\n path: currentEntry.path.concat(key),\n });\n }\n } else {\n const prevAnimation = resolvePath(\n previousAnimation?.styleAnimations,\n currentEntry.path\n );\n let prevVal = resolvePath(value, currentEntry.path);\n if (prevAnimation && !prevVal) {\n prevVal = (prevAnimation as any).current;\n }\n if (prevVal === undefined) {\n console.warn(\n `Initial values for animation are missing for property ${currentEntry.path.join(\n '.'\n )}`\n );\n }\n setPath(animation.current, currentEntry.path, prevVal);\n let currentAnimation: AnimationObject;\n if (\n typeof currentEntry.value !== 'object' ||\n !currentEntry.value.onStart\n ) {\n currentAnimation = withTiming(\n currentEntry.value as AnimatableValue,\n { duration: 0 }\n ) as AnimationObject; // TODO TYPESCRIPT this temporary cast is to get rid of .d.ts file.\n setPath(\n animation.styleAnimations,\n currentEntry.path,\n currentAnimation\n );\n } else {\n currentAnimation = currentEntry.value as Animation<AnimationObject>;\n }\n currentAnimation.onStart(\n currentAnimation,\n prevVal,\n now,\n prevAnimation\n );\n }\n }\n };\n\n const callback = (finished: boolean): void => {\n if (!finished) {\n const animationsToCheck: NestedObjectValues<AnimationObject>[] = [\n styleAnimations,\n ];\n while (animationsToCheck.length > 0) {\n const currentAnimation: NestedObjectValues<AnimationObject> =\n animationsToCheck.pop() as NestedObjectValues<AnimationObject>;\n if (Array.isArray(currentAnimation)) {\n for (const element of currentAnimation) {\n animationsToCheck.push(element);\n }\n } else if (\n typeof currentAnimation === 'object' &&\n currentAnimation.onStart === undefined\n ) {\n for (const value of Object.values(currentAnimation)) {\n animationsToCheck.push(value);\n }\n } else {\n const currentStyleAnimation: AnimationObject =\n currentAnimation as AnimationObject;\n if (\n !currentStyleAnimation.finished &&\n currentStyleAnimation.callback\n ) {\n currentStyleAnimation.callback(false);\n }\n }\n }\n }\n };\n\n return {\n isHigherOrder: true,\n onFrame,\n onStart,\n current: {},\n styleAnimations,\n callback,\n } as StyleLayoutAnimation;\n });\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,QAAQ,QAAQ;AAWxC,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,eAAe,EAAEC,YAAY,QAAQ,WAAW;;AAEzD;AACA;AACA,SAASC,WAAWA,CAClBC,GAAoB,EACpBC,IAAyC,EACN;EACnC,SAAS;;EACT,MAAMC,IAAuB,GAAGC,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,GAAGA,IAAI,GAAG,CAACA,IAAI,CAAC;EACnE,OAAOC,IAAI,CAACG,MAAM,CAAoC,CAACC,GAAG,EAAEC,OAAO,KAAK;IACtE,IAAIJ,KAAK,CAACC,OAAO,CAACE,GAAG,CAAC,IAAI,OAAOC,OAAO,KAAK,QAAQ,EAAE;MACrD,OAAOD,GAAG,CAACC,OAAO,CAAC;IACrB,CAAC,MAAM,IACLD,GAAG,KAAK,IAAI,IACZ,OAAOA,GAAG,KAAK,QAAQ,IACtBC,OAAO,IAAwBD,GAAG,EACnC;MACA,OAAQA,GAAG,CACTC,OAAO,CACR;IACH;IACA,OAAOC,SAAS;EAClB,CAAC,EAAER,GAAG,CAAC;AACT;;AAEA;;AAEA,SAASS,OAAOA,CACdT,GAAoB,EACpBC,IAAU,EACVS,KAA4B,EACtB;EACN,SAAS;;EACT,MAAMR,IAAU,GAAGC,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,GAAGA,IAAI,GAAG,CAACA,IAAI,CAAC;EACtD,IAAIU,OAA8B,GAAGX,GAAG;EACxC,KAAK,IAAIY,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGV,IAAI,CAACW,MAAM,GAAG,CAAC,EAAED,CAAC,EAAE,EAAE;IACxC;IACAD,OAAO,GAAGA,OAAmD;IAC7D,IAAI,EAAET,IAAI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