react-native-reanimated 2.3.0-alpha.3 → 2.3.0-beta.4

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 (264) hide show
  1. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +15 -8
  2. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +176 -154
  3. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +49 -33
  4. package/Common/cpp/Registries/EventHandlerRegistry.cpp +14 -7
  5. package/Common/cpp/Registries/MapperRegistry.cpp +24 -20
  6. package/Common/cpp/Registries/WorkletsCache.cpp +19 -9
  7. package/Common/cpp/SharedItems/FrozenObject.cpp +17 -8
  8. package/Common/cpp/SharedItems/MutableValue.cpp +38 -25
  9. package/Common/cpp/SharedItems/MutableValueSetterProxy.cpp +11 -7
  10. package/Common/cpp/SharedItems/RemoteObject.cpp +9 -5
  11. package/Common/cpp/SharedItems/ShareableValue.cpp +211 -160
  12. package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
  13. package/Common/cpp/Tools/JSIStoreValueUser.cpp +25 -6
  14. package/Common/cpp/Tools/Mapper.cpp +30 -30
  15. package/Common/cpp/Tools/RuntimeDecorator.cpp +124 -86
  16. package/Common/cpp/Tools/Scheduler.cpp +6 -5
  17. package/Common/cpp/Tools/WorkletEventHandler.cpp +4 -2
  18. package/Common/cpp/headers/LayoutAnimations/LayoutAnimationsProxy.h +12 -11
  19. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +50 -31
  20. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +34 -16
  21. package/Common/cpp/headers/Registries/EventHandlerRegistry.h +15 -8
  22. package/Common/cpp/headers/Registries/MapperRegistry.h +5 -4
  23. package/Common/cpp/headers/Registries/WorkletsCache.h +9 -7
  24. package/Common/cpp/headers/SharedItems/FrozenObject.h +19 -11
  25. package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +8 -4
  26. package/Common/cpp/headers/SharedItems/MutableValue.h +23 -12
  27. package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +12 -7
  28. package/Common/cpp/headers/SharedItems/RemoteObject.h +19 -8
  29. package/Common/cpp/headers/SharedItems/RuntimeManager.h +26 -25
  30. package/Common/cpp/headers/SharedItems/ShareableValue.h +32 -27
  31. package/Common/cpp/headers/SharedItems/SharedParent.h +10 -7
  32. package/Common/cpp/headers/SharedItems/ValueWrapper.h +95 -72
  33. package/Common/cpp/headers/SpecTools/ErrorHandler.h +18 -19
  34. package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
  35. package/Common/cpp/headers/Tools/JSIStoreValueUser.h +13 -16
  36. package/Common/cpp/headers/Tools/Mapper.h +19 -16
  37. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +17 -7
  38. package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +7 -11
  39. package/Common/cpp/headers/Tools/RuntimeDecorator.h +36 -27
  40. package/Common/cpp/headers/Tools/Scheduler.h +30 -35
  41. package/Common/cpp/headers/Tools/WorkletEventHandler.h +11 -8
  42. package/Common/cpp/hidden_headers/Logger.h +14 -14
  43. package/Common/cpp/hidden_headers/LoggerInterface.h +8 -9
  44. package/Common/cpp/hidden_headers/SpeedChecker.h +7 -8
  45. package/README.md +1 -1
  46. package/RNReanimated.podspec +24 -6
  47. package/android/build.gradle +38 -29
  48. package/android/react-native-reanimated-63-hermes.aar +0 -0
  49. package/android/react-native-reanimated-63-jsc.aar +0 -0
  50. package/android/react-native-reanimated-64-hermes.aar +0 -0
  51. package/android/react-native-reanimated-64-jsc.aar +0 -0
  52. package/android/react-native-reanimated-65-hermes.aar +0 -0
  53. package/android/react-native-reanimated-65-jsc.aar +0 -0
  54. package/android/react-native-reanimated-66-hermes.aar +0 -0
  55. package/android/react-native-reanimated-66-jsc.aar +0 -0
  56. package/android/react-native-reanimated-67-hermes.aar +0 -0
  57. package/android/react-native-reanimated-67-jsc.aar +0 -0
  58. package/ios/LayoutReanimation/REAAnimationsManager.h +10 -8
  59. package/ios/LayoutReanimation/REAAnimationsManager.m +91 -87
  60. package/ios/LayoutReanimation/REASnapshot.h +2 -2
  61. package/ios/LayoutReanimation/REASnapshot.m +8 -7
  62. package/ios/LayoutReanimation/REAUIManager.h +4 -4
  63. package/ios/LayoutReanimation/REAUIManager.mm +116 -70
  64. package/ios/Nodes/REAAlwaysNode.m +14 -15
  65. package/ios/Nodes/REABezierNode.m +8 -7
  66. package/ios/Nodes/REABlockNode.m +1 -1
  67. package/ios/Nodes/REACallFuncNode.h +0 -1
  68. package/ios/Nodes/REACallFuncNode.m +10 -8
  69. package/ios/Nodes/REAClockNodes.m +22 -20
  70. package/ios/Nodes/REAConcatNode.h +0 -1
  71. package/ios/Nodes/REAConcatNode.m +2 -2
  72. package/ios/Nodes/REACondNode.m +7 -5
  73. package/ios/Nodes/READebugNode.m +5 -4
  74. package/ios/Nodes/REAEventNode.m +1 -1
  75. package/ios/Nodes/REAFunctionNode.h +0 -1
  76. package/ios/Nodes/REAFunctionNode.m +2 -2
  77. package/ios/Nodes/REAJSCallNode.m +4 -5
  78. package/ios/Nodes/REANode.h +3 -4
  79. package/ios/Nodes/REANode.m +9 -11
  80. package/ios/Nodes/REAOperatorNode.m +68 -67
  81. package/ios/Nodes/REAParamNode.h +1 -3
  82. package/ios/Nodes/REAParamNode.m +15 -17
  83. package/ios/Nodes/REAPropsNode.h +1 -3
  84. package/ios/Nodes/REAPropsNode.m +19 -22
  85. package/ios/Nodes/REASetNode.h +0 -1
  86. package/ios/Nodes/REASetNode.m +7 -5
  87. package/ios/Nodes/REAStyleNode.h +0 -1
  88. package/ios/Nodes/REAStyleNode.m +2 -4
  89. package/ios/Nodes/REATransformNode.h +0 -1
  90. package/ios/Nodes/REATransformNode.m +3 -5
  91. package/ios/Nodes/REAValueNode.m +5 -7
  92. package/ios/REAEventDispatcher.m +4 -4
  93. package/ios/REAModule.h +0 -2
  94. package/ios/REAModule.m +29 -38
  95. package/ios/REANodesManager.h +11 -19
  96. package/ios/REANodesManager.m +106 -130
  97. package/ios/REAUtils.h +5 -3
  98. package/ios/RNGestureHandlerStateManager.h +5 -0
  99. package/ios/Transitioning/RCTConvert+REATransition.m +45 -29
  100. package/ios/Transitioning/REAAllTransitions.h +2 -2
  101. package/ios/Transitioning/REAAllTransitions.m +14 -25
  102. package/ios/Transitioning/REATransition.h +8 -7
  103. package/ios/Transitioning/REATransition.m +19 -16
  104. package/ios/Transitioning/REATransitionAnimation.h +1 -1
  105. package/ios/Transitioning/REATransitionAnimation.m +2 -3
  106. package/ios/Transitioning/REATransitionManager.m +3 -3
  107. package/ios/native/NativeMethods.h +20 -5
  108. package/ios/native/NativeMethods.mm +14 -6
  109. package/ios/native/NativeProxy.h +4 -2
  110. package/ios/native/NativeProxy.mm +84 -63
  111. package/ios/native/REAIOSErrorHandler.h +13 -10
  112. package/ios/native/REAIOSErrorHandler.mm +19 -15
  113. package/ios/native/REAIOSLogger.h +8 -8
  114. package/ios/native/REAIOSLogger.mm +10 -6
  115. package/ios/native/REAIOSScheduler.h +5 -5
  116. package/ios/native/REAIOSScheduler.mm +17 -10
  117. package/ios/native/REAInitializer.h +5 -7
  118. package/ios/native/REAInitializer.mm +43 -31
  119. package/ios/native/UIResponder+Reanimated.mm +2 -2
  120. package/lib/Animated.js +9 -1
  121. package/lib/ConfigHelper.js +121 -138
  122. package/lib/ReanimatedEventEmitter.js +0 -1
  123. package/lib/ReanimatedModule.js +0 -1
  124. package/lib/ReanimatedModule.macos.js +0 -1
  125. package/lib/ReanimatedModule.native.js +5 -6
  126. package/lib/ReanimatedModule.windows.js +0 -1
  127. package/lib/ReanimatedModuleCompat.js +64 -35
  128. package/lib/createAnimatedComponent.js +468 -487
  129. package/lib/index.js +9 -1
  130. package/lib/reanimated2/NativeMethods.js +7 -12
  131. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +37 -0
  132. package/lib/reanimated2/NativeReanimated/index.js +15 -0
  133. package/lib/reanimated2/PropAdapters.js +0 -1
  134. package/lib/reanimated2/UpdateProps.js +6 -7
  135. package/lib/reanimated2/ViewDescriptorsSet.js +4 -4
  136. package/lib/reanimated2/WorkletEventHandler.js +15 -13
  137. package/lib/reanimated2/animation/delay.js +8 -2
  138. package/lib/reanimated2/animation/spring.js +2 -0
  139. package/lib/reanimated2/animation/styleAnimation.js +7 -3
  140. package/lib/reanimated2/animation/util.js +25 -2
  141. package/lib/reanimated2/core.js +41 -17
  142. package/lib/reanimated2/globals.d.ts +21 -1
  143. package/lib/reanimated2/hook/useAnimatedRef.js +1 -1
  144. package/lib/reanimated2/hook/useAnimatedStyle.js +3 -3
  145. package/lib/reanimated2/index.js +1 -0
  146. package/lib/reanimated2/interpolation.js +95 -87
  147. package/lib/reanimated2/js-reanimated/JSReanimated.js +13 -10
  148. package/lib/reanimated2/js-reanimated/Mapper.js +4 -3
  149. package/lib/reanimated2/js-reanimated/MapperRegistry.js +3 -6
  150. package/lib/reanimated2/js-reanimated/MutableValue.js +0 -2
  151. package/lib/reanimated2/js-reanimated/index.js +10 -8
  152. package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +33 -2
  153. package/lib/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +27 -124
  154. package/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +125 -0
  155. package/lib/reanimated2/layoutReanimation/animationBuilder/index.js +1 -2
  156. package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +115 -45
  157. package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +7 -2
  158. package/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.js +21 -21
  159. package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +25 -25
  160. package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +19 -17
  161. package/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +5 -5
  162. package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +9 -9
  163. package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +17 -17
  164. package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +19 -19
  165. package/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +9 -9
  166. package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +33 -33
  167. package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +78 -0
  168. package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +128 -0
  169. package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +37 -0
  170. package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +41 -0
  171. package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +34 -0
  172. package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +46 -0
  173. package/lib/reanimated2/layoutReanimation/defaultTransitions/index.js +6 -0
  174. package/lib/reanimated2/layoutReanimation/index.js +1 -0
  175. package/lib/reanimated2/mock.js +3 -1
  176. package/lib/reanimated2/utils.js +9 -0
  177. package/lib/setAndForwardRef.js +14 -48
  178. package/libSo/fbjni/jni/arm64-v8a/libfbjni.so +0 -0
  179. package/libSo/fbjni/jni/armeabi-v7a/libfbjni.so +0 -0
  180. package/libSo/fbjni/jni/x86/libfbjni.so +0 -0
  181. package/libSo/fbjni/jni/x86_64/libfbjni.so +0 -0
  182. package/mock.js +1 -1
  183. package/package.json +28 -17
  184. package/plugin.js +220 -39
  185. package/react-native-reanimated.d.ts +542 -547
  186. package/src/Animated.js +9 -1
  187. package/src/{ConfigHelper.js → ConfigHelper.ts} +15 -7
  188. package/src/{ReanimatedEventEmitter.js → ReanimatedEventEmitter.ts} +0 -0
  189. package/src/{ReanimatedModule.js → ReanimatedModule.macos.ts} +0 -0
  190. package/src/{ReanimatedModule.native.js → ReanimatedModule.native.ts} +0 -0
  191. package/src/{ReanimatedModule.macos.js → ReanimatedModule.ts} +0 -0
  192. package/src/{ReanimatedModule.windows.js → ReanimatedModule.windows.ts} +0 -0
  193. package/src/ReanimatedModuleCompat.ts +51 -0
  194. package/src/{createAnimatedComponent.js → createAnimatedComponent.tsx} +285 -126
  195. package/src/reanimated2/NativeMethods.ts +34 -13
  196. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +72 -0
  197. package/src/reanimated2/NativeReanimated/index.ts +18 -0
  198. package/src/reanimated2/PropAdapters.ts +0 -1
  199. package/src/reanimated2/UpdateProps.ts +31 -15
  200. package/src/reanimated2/ViewDescriptorsSet.ts +15 -12
  201. package/src/reanimated2/WorkletEventHandler.ts +41 -23
  202. package/src/reanimated2/animation/commonTypes.ts +4 -4
  203. package/src/reanimated2/animation/decay.ts +2 -2
  204. package/src/reanimated2/animation/delay.ts +11 -5
  205. package/src/reanimated2/animation/index.ts +7 -7
  206. package/src/reanimated2/animation/repeat.ts +4 -4
  207. package/src/reanimated2/animation/sequence.ts +2 -2
  208. package/src/reanimated2/animation/spring.ts +6 -5
  209. package/src/reanimated2/animation/styleAnimation.ts +27 -15
  210. package/src/reanimated2/animation/timing.ts +5 -5
  211. package/src/reanimated2/animation/util.ts +47 -8
  212. package/src/reanimated2/commonTypes.ts +3 -0
  213. package/src/reanimated2/core.ts +80 -34
  214. package/src/reanimated2/globals.d.ts +21 -1
  215. package/src/reanimated2/hook/useAnimatedGestureHandler.ts +1 -1
  216. package/src/reanimated2/hook/useAnimatedRef.ts +13 -15
  217. package/src/reanimated2/hook/useAnimatedScrollHandler.ts +3 -3
  218. package/src/reanimated2/hook/useAnimatedStyle.ts +7 -7
  219. package/src/reanimated2/hook/utils.ts +4 -3
  220. package/src/reanimated2/index.ts +1 -0
  221. package/src/reanimated2/interpolation.ts +170 -103
  222. package/src/reanimated2/js-reanimated/JSReanimated.ts +37 -23
  223. package/src/reanimated2/js-reanimated/Mapper.ts +22 -9
  224. package/src/reanimated2/js-reanimated/MapperRegistry.ts +22 -19
  225. package/src/reanimated2/js-reanimated/MutableValue.ts +11 -11
  226. package/src/reanimated2/js-reanimated/index.ts +31 -14
  227. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +75 -0
  228. package/src/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts +29 -159
  229. package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +169 -0
  230. package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +2 -2
  231. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +3 -9
  232. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -5
  233. package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +162 -82
  234. package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +7 -2
  235. package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +32 -32
  236. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +38 -38
  237. package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +34 -32
  238. package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +8 -8
  239. package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +14 -14
  240. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +26 -26
  241. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +28 -28
  242. package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +14 -14
  243. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +50 -50
  244. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +104 -0
  245. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +213 -0
  246. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +60 -0
  247. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +58 -0
  248. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +41 -0
  249. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +78 -0
  250. package/src/reanimated2/layoutReanimation/defaultTransitions/index.ts +6 -0
  251. package/src/reanimated2/layoutReanimation/index.ts +1 -0
  252. package/src/reanimated2/mock.ts +3 -1
  253. package/src/reanimated2/utils.ts +21 -0
  254. package/src/{setAndForwardRef.js → setAndForwardRef.ts} +12 -2
  255. package/android/react-native-reanimated-62-hermes.aar +0 -0
  256. package/android/react-native-reanimated-62-jsc.aar +0 -0
  257. package/lib/reanimated2/NativeReanimated.js +0 -48
  258. package/lib/reanimated2/layoutReanimation/animationBuilder/BaseBounceAnimationBuilder.js +0 -55
  259. package/lib/reanimated2/layoutReanimation/animationBuilder/LayoutAnimationBuilder.js +0 -165
  260. package/src/ReanimatedModuleCompat.js +0 -37
  261. package/src/reanimated2/NativeReanimated.ts +0 -70
  262. package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.tsx +0 -41
  263. package/src/reanimated2/layoutReanimation/animationBuilder/BaseBounceAnimationBuilder.ts +0 -82
  264. package/src/reanimated2/layoutReanimation/animationBuilder/LayoutAnimationBuilder.ts +0 -217
@@ -0,0 +1,58 @@
1
+ import {
2
+ ILayoutAnimationBuilder,
3
+ LayoutAnimationFunction,
4
+ } from '../animationBuilder/commonTypes';
5
+ import { withSequence, withTiming } from '../../animation';
6
+ import { Easing } from '../../Easing';
7
+ import { BaseAnimationBuilder } from '../animationBuilder';
8
+ export class JumpingTransition
9
+ extends BaseAnimationBuilder
10
+ implements ILayoutAnimationBuilder {
11
+ static createInstance(): JumpingTransition {
12
+ return new JumpingTransition();
13
+ }
14
+
15
+ build = (): LayoutAnimationFunction => {
16
+ const delayFunction = this.getDelayFunction();
17
+ const callback = this.callbackV;
18
+ const delay = this.getDelay();
19
+ const duration = (this.durationV ?? 300) / 2;
20
+ const config = { duration: duration * 2 };
21
+
22
+ return (values) => {
23
+ 'worklet';
24
+ const d = Math.max(
25
+ Math.abs(values.originX - values.boriginX),
26
+ Math.abs(values.originY - values.boriginY)
27
+ );
28
+ return {
29
+ initialValues: {
30
+ originX: values.boriginX,
31
+ originY: values.boriginY,
32
+ width: values.bwidth,
33
+ height: values.bheight,
34
+ },
35
+ animations: {
36
+ originX: delayFunction(delay, withTiming(values.originX, config)),
37
+ originY: delayFunction(
38
+ delay,
39
+ withSequence(
40
+ withTiming(Math.min(values.originY, values.boriginY) - d, {
41
+ duration,
42
+ easing: Easing.out(Easing.exp),
43
+ }),
44
+ withTiming(values.originY, {
45
+ ...config,
46
+ duration,
47
+ easing: Easing.bounce,
48
+ })
49
+ )
50
+ ),
51
+ width: delayFunction(delay, withTiming(values.width, config)),
52
+ height: delayFunction(delay, withTiming(values.height, config)),
53
+ },
54
+ callback: callback,
55
+ };
56
+ };
57
+ };
58
+ }
@@ -0,0 +1,41 @@
1
+ import { ComplexAnimationBuilder } from '../animationBuilder/ComplexAnimationBuilder';
2
+ import {
3
+ ILayoutAnimationBuilder,
4
+ LayoutAnimationFunction,
5
+ } from '../animationBuilder/commonTypes';
6
+
7
+ export class LinearTransition
8
+ extends ComplexAnimationBuilder
9
+ implements ILayoutAnimationBuilder {
10
+ static createInstance(): LinearTransition {
11
+ return new LinearTransition();
12
+ }
13
+
14
+ build = (): LayoutAnimationFunction => {
15
+ const delayFunction = this.getDelayFunction();
16
+ const [animation, config] = this.getAnimationAndConfig();
17
+ const callback = this.callbackV;
18
+ const delay = this.getDelay();
19
+
20
+ return (values) => {
21
+ 'worklet';
22
+ return {
23
+ initialValues: {
24
+ originX: values.boriginX,
25
+ originY: values.boriginY,
26
+ width: values.bwidth,
27
+ height: values.bheight,
28
+ },
29
+ animations: {
30
+ originX: delayFunction(delay, animation(values.originX, config)),
31
+ originY: delayFunction(delay, animation(values.originY, config)),
32
+ width: delayFunction(delay, animation(values.width, config)),
33
+ height: delayFunction(delay, animation(values.height, config)),
34
+ },
35
+ callback: callback,
36
+ };
37
+ };
38
+ };
39
+ }
40
+
41
+ export const Layout = LinearTransition;
@@ -0,0 +1,78 @@
1
+ import { withSequence, withTiming } from '../../animation';
2
+ import {
3
+ ILayoutAnimationBuilder,
4
+ LayoutAnimationFunction,
5
+ } from '../animationBuilder/commonTypes';
6
+ import { BaseAnimationBuilder } from '../animationBuilder';
7
+
8
+ export class SequencedTransition
9
+ extends BaseAnimationBuilder
10
+ implements ILayoutAnimationBuilder {
11
+ reversed = false;
12
+
13
+ static createInstance(): SequencedTransition {
14
+ return new SequencedTransition();
15
+ }
16
+
17
+ static reverse(): SequencedTransition {
18
+ const instance = SequencedTransition.createInstance();
19
+ return instance.reverse();
20
+ }
21
+
22
+ reverse(): SequencedTransition {
23
+ this.reversed = !this.reversed;
24
+ return this;
25
+ }
26
+
27
+ build = (): LayoutAnimationFunction => {
28
+ const delayFunction = this.getDelayFunction();
29
+ const callback = this.callbackV;
30
+ const delay = this.getDelay();
31
+ const sequenceDuration = (this.durationV ?? 500) / 2;
32
+ const config = { duration: sequenceDuration };
33
+ const reverse = this.reversed;
34
+
35
+ return (values) => {
36
+ 'worklet';
37
+ return {
38
+ initialValues: {
39
+ originX: values.boriginX,
40
+ originY: values.boriginY,
41
+ width: values.bwidth,
42
+ height: values.bheight,
43
+ },
44
+ animations: {
45
+ originX: delayFunction(
46
+ delay,
47
+ withSequence(
48
+ withTiming(reverse ? values.boriginX : values.originX, config),
49
+ withTiming(values.originX, config)
50
+ )
51
+ ),
52
+ originY: delayFunction(
53
+ delay,
54
+ withSequence(
55
+ withTiming(reverse ? values.originY : values.boriginY, config),
56
+ withTiming(values.originY, config)
57
+ )
58
+ ),
59
+ width: delayFunction(
60
+ delay,
61
+ withSequence(
62
+ withTiming(reverse ? values.bwidth : values.width, config),
63
+ withTiming(values.width, config)
64
+ )
65
+ ),
66
+ height: delayFunction(
67
+ delay,
68
+ withSequence(
69
+ withTiming(reverse ? values.height : values.bheight, config),
70
+ withTiming(values.height, config)
71
+ )
72
+ ),
73
+ },
74
+ callback: callback,
75
+ };
76
+ };
77
+ };
78
+ }
@@ -0,0 +1,6 @@
1
+ export * from './LinearTransition';
2
+ export * from './FadingTransition';
3
+ export * from './SequencedTransition';
4
+ export * from './JumpingTransition';
5
+ export * from './CurvedTransition';
6
+ export * from './EntryExitTransition';
@@ -1,3 +1,4 @@
1
1
  import './LayoutAnimationRepository';
2
2
  export * from './animationBuilder';
3
3
  export * from './defaultAnimations';
4
+ export * from './defaultTransitions';
@@ -5,15 +5,17 @@ const NOOP = () => {
5
5
  // noop
6
6
  };
7
7
  const ID = (t) => t;
8
+ const IMMEDIATE_CB_INVOCATION = (cb: () => unknown) => cb();
8
9
 
9
10
  const ReanimatedV2 = {
10
11
  useSharedValue: (v) => ({ value: v }),
11
12
  useDerivedValue: (a) => ({ value: a() }),
12
13
  useAnimatedScrollHandler: () => NOOP,
13
14
  useAnimatedGestureHandler: () => NOOP,
14
- useAnimatedStyle: (style) => style,
15
+ useAnimatedStyle: IMMEDIATE_CB_INVOCATION,
15
16
  useAnimatedRef: () => ({ current: null }),
16
17
  useAnimatedReaction: NOOP,
18
+ useAnimatedProps: IMMEDIATE_CB_INVOCATION,
17
19
 
18
20
  withTiming: (toValue, _, cb) => {
19
21
  cb && cb(true);
@@ -0,0 +1,21 @@
1
+ import { Component } from 'react';
2
+ import { measure } from './NativeMethods';
3
+ import { RefObjectFunction } from './hook/useAnimatedRef';
4
+
5
+ export interface ComponentCoords {
6
+ x: number;
7
+ y: number;
8
+ }
9
+
10
+ export function getRelativeCoords(
11
+ parentRef: RefObjectFunction<Component>,
12
+ x: number,
13
+ y: number
14
+ ): ComponentCoords {
15
+ 'worklet';
16
+ const parentCoords = measure(parentRef);
17
+ return {
18
+ x: x - parentCoords.x,
19
+ y: y - parentCoords.y,
20
+ };
21
+ }
@@ -2,6 +2,8 @@
2
2
  * imported from react-native
3
3
  */
4
4
 
5
+ import { MutableRefObject } from 'react';
6
+
5
7
  /**
6
8
  * This is a helper function for when a component needs to be able to forward a ref
7
9
  * to a child component, but still needs to have access to that component as part of
@@ -33,8 +35,16 @@
33
35
  * module.exports = MyViewWithRef;
34
36
  */
35
37
 
36
- function setAndForwardRef({ getForwardedRef, setLocalRef }) {
37
- return function forwardRef(ref) {
38
+ export type ForwardedRef<T> = () => MutableRefObject<T> | ((ref: T) => void);
39
+
40
+ function setAndForwardRef<T>({
41
+ getForwardedRef,
42
+ setLocalRef,
43
+ }: {
44
+ getForwardedRef: ForwardedRef<T>;
45
+ setLocalRef: (ref: T) => void;
46
+ }): (ref: T) => void {
47
+ return function forwardRef(ref: T) {
38
48
  const forwardedRef = getForwardedRef();
39
49
 
40
50
  setLocalRef(ref);
@@ -1,48 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-nocheck
3
- import { Platform } from 'react-native';
4
- import reanimatedJS from './js-reanimated';
5
- import { nativeShouldBeMock } from './PlatformChecker';
6
- let exportedModule;
7
- if (nativeShouldBeMock()) {
8
- exportedModule = reanimatedJS;
9
- }
10
- else {
11
- const InnerNativeModule = global.__reanimatedModuleProxy;
12
- const NativeReanimated = {
13
- native: true,
14
- useOnlyV1: InnerNativeModule == null,
15
- installCoreFunctions(valueSetter) {
16
- return InnerNativeModule.installCoreFunctions(valueSetter);
17
- },
18
- makeShareable(value) {
19
- return InnerNativeModule.makeShareable(value);
20
- },
21
- makeMutable(value) {
22
- return InnerNativeModule.makeMutable(value);
23
- },
24
- makeRemote(object) {
25
- return InnerNativeModule.makeRemote(object);
26
- },
27
- startMapper(mapper, inputs = [], outputs = [], updater, tag, name) {
28
- return InnerNativeModule.startMapper(mapper, inputs, outputs, updater, tag, name);
29
- },
30
- stopMapper(mapperId) {
31
- return InnerNativeModule.stopMapper(mapperId);
32
- },
33
- registerEventHandler(eventHash, eventHandler) {
34
- return InnerNativeModule.registerEventHandler(eventHash, eventHandler);
35
- },
36
- unregisterEventHandler(registrationId) {
37
- return InnerNativeModule.unregisterEventHandler(registrationId);
38
- },
39
- getViewProp(viewTag, propName, callback) {
40
- return InnerNativeModule.getViewProp(viewTag, propName, callback);
41
- },
42
- };
43
- if (NativeReanimated.useOnlyV1 && Platform.OS === 'android') {
44
- console.warn(`If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation`);
45
- }
46
- exportedModule = NativeReanimated;
47
- }
48
- export default exportedModule; // TODO: just temporary type
@@ -1,55 +0,0 @@
1
- import { withDelay, withTiming } from '../../animation';
2
- export class BaseBounceAnimationBuilder {
3
- constructor() {
4
- this.build = () => {
5
- throw Error('Unimplemented method in child class.');
6
- };
7
- }
8
- static duration(durationMs) {
9
- const instance = this.createInstance();
10
- return instance.duration(durationMs);
11
- }
12
- duration(durationMs) {
13
- this.durationV = durationMs;
14
- return this;
15
- }
16
- static delay(delayMs) {
17
- const instance = this.createInstance();
18
- return instance.delay(delayMs);
19
- }
20
- delay(delayMs) {
21
- this.delayV = delayMs;
22
- return this;
23
- }
24
- static withCallback(callback) {
25
- const instance = this.createInstance();
26
- return instance.withCallback(callback);
27
- }
28
- withCallback(callback) {
29
- this.callbackV = callback;
30
- return this;
31
- }
32
- getDelayFunction() {
33
- const delay = this.delayV;
34
- return delay
35
- ? withDelay
36
- : (_, animation) => {
37
- 'worklet';
38
- return animation;
39
- };
40
- }
41
- getAnimationAndConfig() {
42
- const duration = this.durationV;
43
- const type = withTiming;
44
- const animation = type;
45
- const config = {};
46
- if (duration) {
47
- config.duration = duration;
48
- }
49
- return [animation, config];
50
- }
51
- static build() {
52
- const instance = this.createInstance();
53
- return instance.build();
54
- }
55
- }
@@ -1,165 +0,0 @@
1
- import { withDelay, withTiming, withSpring } from '../../animation';
2
- export class LayoutAnimationBuilder {
3
- constructor() {
4
- this.build = () => {
5
- const duration = this.durationV;
6
- const easing = this.easingV;
7
- const delay = this.delayV;
8
- const type = this.type ? this.type : withTiming;
9
- const damping = this.dampingV;
10
- const mass = this.massV;
11
- const stiffness = this.stiffnessV;
12
- const overshootClamping = this.overshootClampingV;
13
- const restDisplacementThreshold = this.restDisplacementThresholdV;
14
- const restSpeedThreshold = this.restSpeedThresholdV;
15
- const callback = this.callbackV;
16
- const delayFunction = delay
17
- ? withDelay
18
- : (_, animation) => {
19
- 'worklet';
20
- return animation;
21
- };
22
- const animation = type;
23
- const config = {};
24
- if (type === withTiming) {
25
- if (easing) {
26
- config.easing = easing;
27
- }
28
- if (duration) {
29
- config.duration = duration;
30
- }
31
- }
32
- else {
33
- if (damping) {
34
- config.damping = damping;
35
- }
36
- if (mass) {
37
- config.mass = mass;
38
- }
39
- if (stiffness) {
40
- config.stiffness = stiffness;
41
- }
42
- if (overshootClamping) {
43
- config.overshootClamping = overshootClamping;
44
- }
45
- if (restDisplacementThreshold) {
46
- config.restDisplacementThreshold = restDisplacementThreshold;
47
- }
48
- if (restSpeedThreshold) {
49
- config.restSpeedThreshold = restSpeedThreshold;
50
- }
51
- }
52
- return (values) => {
53
- 'worklet';
54
- return {
55
- initialValues: {
56
- originX: values.boriginX,
57
- originY: values.boriginY,
58
- width: values.bwidth,
59
- height: values.bheight,
60
- },
61
- animations: {
62
- originX: delayFunction(delay, animation(values.originX, config)),
63
- originY: delayFunction(delay, animation(values.originY, config)),
64
- width: delayFunction(delay, animation(values.width, config)),
65
- height: delayFunction(delay, animation(values.height, config)),
66
- },
67
- callback: callback,
68
- };
69
- };
70
- };
71
- }
72
- static duration(durationMs) {
73
- const instance = new LayoutAnimationBuilder();
74
- return instance.duration(durationMs);
75
- }
76
- duration(durationMs) {
77
- this.durationV = durationMs;
78
- return this;
79
- }
80
- static easing(easingFunction) {
81
- const instance = new LayoutAnimationBuilder();
82
- return instance.easing(easingFunction);
83
- }
84
- easing(easingFunction) {
85
- this.easingV = easingFunction;
86
- return this;
87
- }
88
- static delay(durationMs) {
89
- const instance = new LayoutAnimationBuilder();
90
- return instance.delay(durationMs);
91
- }
92
- delay(durationMs) {
93
- this.delayV = durationMs;
94
- return this;
95
- }
96
- static springify() {
97
- const instance = new LayoutAnimationBuilder();
98
- return instance.springify();
99
- }
100
- springify() {
101
- this.type = withSpring;
102
- return this;
103
- }
104
- static damping(damping) {
105
- const instance = new LayoutAnimationBuilder();
106
- return instance.damping(damping);
107
- }
108
- damping(damping) {
109
- this.dampingV = damping;
110
- return this;
111
- }
112
- static mass(mass) {
113
- const instance = new LayoutAnimationBuilder();
114
- return instance.mass(mass);
115
- }
116
- mass(mass) {
117
- this.massV = mass;
118
- return this;
119
- }
120
- static stiffness(stiffness) {
121
- const instance = new LayoutAnimationBuilder();
122
- return instance.stiffness(stiffness);
123
- }
124
- stiffness(stiffness) {
125
- this.stiffnessV = stiffness;
126
- return this;
127
- }
128
- static overshootClamping(overshootClamping) {
129
- const instance = new LayoutAnimationBuilder();
130
- return instance.overshootClamping(overshootClamping);
131
- }
132
- overshootClamping(overshootClamping) {
133
- this.overshootClampingV = overshootClamping;
134
- return this;
135
- }
136
- static restDisplacementThreshold(restDisplacementThreshold) {
137
- const instance = new LayoutAnimationBuilder();
138
- return instance.restDisplacementThreshold(restDisplacementThreshold);
139
- }
140
- restDisplacementThreshold(restDisplacementThreshold) {
141
- this.restDisplacementThresholdV = restDisplacementThreshold;
142
- return this;
143
- }
144
- static restSpeedThreshold(r) {
145
- const instance = new LayoutAnimationBuilder();
146
- return instance.restSpeedThreshold(r);
147
- }
148
- restSpeedThreshold(restSpeedThreshold) {
149
- this.restSpeedThresholdV = restSpeedThreshold;
150
- return this;
151
- }
152
- static withCallback(callback) {
153
- const instance = new LayoutAnimationBuilder();
154
- return instance.withCallback(callback);
155
- }
156
- withCallback(callback) {
157
- this.callbackV = callback;
158
- return this;
159
- }
160
- static build() {
161
- const instance = new LayoutAnimationBuilder();
162
- return instance.build();
163
- }
164
- }
165
- export const Layout = LayoutAnimationBuilder;
@@ -1,37 +0,0 @@
1
- export default {
2
- async disconnectNodeFromView() {
3
- // noop
4
- },
5
- async attachEvent(_viewTag, _eventName, _nodeID) {
6
- // noop
7
- },
8
- async detachEvent(_viewTag, _eventName, _nodeID) {
9
- // noop
10
- },
11
- async createNode(_nodeID, _config) {
12
- // noop
13
- },
14
- async dropNode(_nodeID) {
15
- // noop
16
- },
17
- async configureProps() {
18
- // noop
19
- },
20
- async disconnectNodes() {
21
- // noop
22
- },
23
- async addListener() {
24
- // noop
25
- },
26
- async removeListeners() {
27
- // noop
28
- },
29
- async removeAllListeners() {
30
- // noop
31
- },
32
- async animateNextTransition() {
33
- console.warn(
34
- 'Reanimated: animateNextTransition is unimplemented on current platform'
35
- );
36
- },
37
- };
@@ -1,70 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-nocheck
3
- import { Platform } from 'react-native';
4
- import reanimatedJS from './js-reanimated';
5
- import { nativeShouldBeMock } from './PlatformChecker';
6
-
7
- let exportedModule;
8
- if (nativeShouldBeMock()) {
9
- exportedModule = reanimatedJS;
10
- } else {
11
- const InnerNativeModule = global.__reanimatedModuleProxy;
12
-
13
- const NativeReanimated = {
14
- native: true,
15
- useOnlyV1: InnerNativeModule == null,
16
-
17
- installCoreFunctions(valueSetter) {
18
- return InnerNativeModule.installCoreFunctions(valueSetter);
19
- },
20
-
21
- makeShareable(value) {
22
- return InnerNativeModule.makeShareable(value);
23
- },
24
-
25
- makeMutable(value) {
26
- return InnerNativeModule.makeMutable(value);
27
- },
28
-
29
- makeRemote(object) {
30
- return InnerNativeModule.makeRemote(object);
31
- },
32
-
33
- startMapper(mapper, inputs = [], outputs = [], updater, tag, name) {
34
- return InnerNativeModule.startMapper(
35
- mapper,
36
- inputs,
37
- outputs,
38
- updater,
39
- tag,
40
- name
41
- );
42
- },
43
-
44
- stopMapper(mapperId) {
45
- return InnerNativeModule.stopMapper(mapperId);
46
- },
47
-
48
- registerEventHandler(eventHash, eventHandler) {
49
- return InnerNativeModule.registerEventHandler(eventHash, eventHandler);
50
- },
51
-
52
- unregisterEventHandler(registrationId) {
53
- return InnerNativeModule.unregisterEventHandler(registrationId);
54
- },
55
-
56
- getViewProp(viewTag, propName, callback) {
57
- return InnerNativeModule.getViewProp(viewTag, propName, callback);
58
- },
59
- };
60
-
61
- if (NativeReanimated.useOnlyV1 && Platform.OS === 'android') {
62
- console.warn(
63
- `If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation`
64
- );
65
- }
66
-
67
- exportedModule = NativeReanimated;
68
- }
69
-
70
- export default exportedModule as any; // TODO: just temporary type
@@ -1,41 +0,0 @@
1
- /* global _stopObservingProgress, _startObservingProgress */
2
- import { runOnUI } from '../core';
3
- import { withStyleAnimation } from '../animation/styleAnimation';
4
-
5
- runOnUI(() => {
6
- 'worklet';
7
-
8
- const configs: Record<string, any> = {};
9
-
10
- global.LayoutAnimationRepository = {
11
- configs,
12
- registerConfig(tag, config) {
13
- configs[tag] = config;
14
- },
15
- removeConfig(tag) {
16
- delete configs[tag];
17
- },
18
- startAnimationForTag(tag, type, yogaValues) {
19
- if (configs[tag] == null) {
20
- return; // :(
21
- }
22
-
23
- const style = configs[tag][type](yogaValues);
24
- const sv: { value: boolean; _value: boolean } = configs[tag].sv;
25
- _stopObservingProgress(tag, false);
26
- _startObservingProgress(tag, sv);
27
- sv._value = Object.assign({}, sv._value, style.initialValues);
28
- _stopObservingProgress(tag, false);
29
- const animation = withStyleAnimation(style.animations);
30
-
31
- animation.callback = (finished?: boolean) => {
32
- if (finished) {
33
- _stopObservingProgress(tag, finished);
34
- }
35
- style.callback && style.callback(finished);
36
- };
37
- configs[tag].sv.value = animation;
38
- _startObservingProgress(tag, sv);
39
- },
40
- };
41
- })();