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,169 @@
1
+ import { withTiming, withSpring } from '../../animation';
2
+ import {
3
+ AnimationFunction,
4
+ BaseBuilderAnimationConfig,
5
+ LayoutAnimationAndConfig,
6
+ } from './commonTypes';
7
+ import { EasingFn } from '../../Easing';
8
+ import { BaseAnimationBuilder } from './BaseAnimationBuilder';
9
+ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
10
+ easingV?: EasingFn;
11
+ rotateV?: string;
12
+ type?: AnimationFunction;
13
+ dampingV?: number;
14
+ massV?: number;
15
+ stiffnessV?: number;
16
+ overshootClampingV?: number;
17
+ restDisplacementThresholdV?: number;
18
+ restSpeedThresholdV?: number;
19
+
20
+ static createInstance: () => ComplexAnimationBuilder;
21
+
22
+ static easing(easingFunction: EasingFn): ComplexAnimationBuilder {
23
+ const instance = this.createInstance();
24
+ return instance.easing(easingFunction);
25
+ }
26
+
27
+ easing(easingFunction: EasingFn): ComplexAnimationBuilder {
28
+ this.easingV = easingFunction;
29
+ return this;
30
+ }
31
+
32
+ static rotate(degree: string): ComplexAnimationBuilder {
33
+ const instance = this.createInstance();
34
+ return instance.rotate(degree);
35
+ }
36
+
37
+ rotate(degree: string): ComplexAnimationBuilder {
38
+ this.rotateV = degree;
39
+ return this;
40
+ }
41
+
42
+ static springify(): ComplexAnimationBuilder {
43
+ const instance = this.createInstance();
44
+ return instance.springify();
45
+ }
46
+
47
+ springify(): ComplexAnimationBuilder {
48
+ this.type = withSpring as AnimationFunction;
49
+ return this;
50
+ }
51
+
52
+ static damping(damping: number): ComplexAnimationBuilder {
53
+ const instance = this.createInstance();
54
+ return instance.damping(damping);
55
+ }
56
+
57
+ damping(damping: number): ComplexAnimationBuilder {
58
+ this.dampingV = damping;
59
+ return this;
60
+ }
61
+
62
+ static mass(mass: number): ComplexAnimationBuilder {
63
+ const instance = this.createInstance();
64
+ return instance.mass(mass);
65
+ }
66
+
67
+ mass(mass: number): ComplexAnimationBuilder {
68
+ this.massV = mass;
69
+ return this;
70
+ }
71
+
72
+ static stiffness(stiffness: number): ComplexAnimationBuilder {
73
+ const instance = this.createInstance();
74
+ return instance.stiffness(stiffness);
75
+ }
76
+
77
+ stiffness(stiffness: number): ComplexAnimationBuilder {
78
+ this.stiffnessV = stiffness;
79
+ return this;
80
+ }
81
+
82
+ static overshootClamping(overshootClamping: number): ComplexAnimationBuilder {
83
+ const instance = this.createInstance();
84
+ return instance.overshootClamping(overshootClamping);
85
+ }
86
+
87
+ overshootClamping(overshootClamping: number): ComplexAnimationBuilder {
88
+ this.overshootClampingV = overshootClamping;
89
+ return this;
90
+ }
91
+
92
+ static restDisplacementThreshold(
93
+ restDisplacementThreshold: number
94
+ ): ComplexAnimationBuilder {
95
+ const instance = this.createInstance();
96
+ return instance.restDisplacementThreshold(restDisplacementThreshold);
97
+ }
98
+
99
+ restDisplacementThreshold(
100
+ restDisplacementThreshold: number
101
+ ): ComplexAnimationBuilder {
102
+ this.restDisplacementThresholdV = restDisplacementThreshold;
103
+ return this;
104
+ }
105
+
106
+ static restSpeedThreshold(
107
+ restSpeedThreshold: number
108
+ ): ComplexAnimationBuilder {
109
+ const instance = this.createInstance();
110
+ return instance.restSpeedThreshold(restSpeedThreshold);
111
+ }
112
+
113
+ restSpeedThreshold(restSpeedThreshold: number): ComplexAnimationBuilder {
114
+ this.restSpeedThresholdV = restSpeedThreshold;
115
+ return this;
116
+ }
117
+
118
+ getAnimationAndConfig(): LayoutAnimationAndConfig {
119
+ const duration = this.durationV;
120
+ const easing = this.easingV;
121
+ const rotate = this.rotateV;
122
+ const type = this.type ? this.type : (withTiming as AnimationFunction);
123
+ const damping = this.dampingV;
124
+ const mass = this.massV;
125
+ const stiffness = this.stiffnessV;
126
+ const overshootClamping = this.overshootClampingV;
127
+ const restDisplacementThreshold = this.restDisplacementThresholdV;
128
+ const restSpeedThreshold = this.restSpeedThresholdV;
129
+
130
+ const animation = type;
131
+
132
+ const config: BaseBuilderAnimationConfig = {};
133
+
134
+ if (type === withTiming) {
135
+ if (easing) {
136
+ config.easing = easing;
137
+ }
138
+ if (duration) {
139
+ config.duration = duration;
140
+ }
141
+ if (rotate) {
142
+ config.rotate = rotate;
143
+ }
144
+ } else {
145
+ if (damping) {
146
+ config.damping = damping;
147
+ }
148
+ if (mass) {
149
+ config.mass = mass;
150
+ }
151
+ if (stiffness) {
152
+ config.stiffness = stiffness;
153
+ }
154
+ if (overshootClamping) {
155
+ config.overshootClamping = overshootClamping;
156
+ }
157
+ if (restDisplacementThreshold) {
158
+ config.restDisplacementThreshold = restDisplacementThreshold;
159
+ }
160
+ if (restSpeedThreshold) {
161
+ config.restSpeedThreshold = restSpeedThreshold;
162
+ }
163
+ if (rotate) {
164
+ config.rotate = rotate;
165
+ }
166
+ }
167
+ return [animation, config];
168
+ }
169
+ }
@@ -2,7 +2,7 @@ import { Easing, EasingFn } from '../../Easing';
2
2
  import { withDelay, withSequence, withTiming } from '../../animation';
3
3
  import {
4
4
  AnimationFunction,
5
- EntryExitAnimationBuild,
5
+ EntryExitAnimationFunction,
6
6
  IEntryExitAnimationBuilder,
7
7
  KeyframeProps,
8
8
  } from './commonTypes';
@@ -188,7 +188,7 @@ export class Keyframe implements IEntryExitAnimationBuilder {
188
188
  };
189
189
  }
190
190
 
191
- build: EntryExitAnimationBuild = () => {
191
+ build = (): EntryExitAnimationFunction => {
192
192
  const delay = this.delayV;
193
193
  const delayFunction = this.getDelayFunction();
194
194
  const { keyframes, initialValues } = this.parseDefinitions();
@@ -27,8 +27,6 @@ export type EntryExitAnimationFunction = (
27
27
  targetValues: EntryExitAnimationsValues
28
28
  ) => LayoutAnimation;
29
29
 
30
- export type EntryExitAnimationBuild = () => EntryExitAnimationFunction;
31
-
32
30
  export interface LayoutAnimationsValues {
33
31
  originX: number;
34
32
  originY: number;
@@ -42,14 +40,14 @@ export interface LayoutAnimationsValues {
42
40
  bheight: number;
43
41
  bglobalOriginX: number;
44
42
  bglobalOriginY: number;
43
+ windowWidth: number;
44
+ windowHeight: number;
45
45
  }
46
46
 
47
47
  export type LayoutAnimationFunction = (
48
48
  targetValues: LayoutAnimationsValues
49
49
  ) => LayoutAnimation;
50
50
 
51
- export type LayoutAnimationBuild = () => LayoutAnimationFunction;
52
-
53
51
  export interface ILayoutAnimationBuilder {
54
52
  build: () => LayoutAnimationFunction;
55
53
  }
@@ -75,10 +73,6 @@ export type LayoutAnimationAndConfig = [
75
73
  BaseBuilderAnimationConfig
76
74
  ];
77
75
 
78
- export interface BounceBuilderAnimationConfig {
79
- duration?: number;
80
- }
81
-
82
76
  export interface IEntryExitAnimationBuilder {
83
- build: EntryExitAnimationBuild;
77
+ build: () => EntryExitAnimationFunction;
84
78
  }
@@ -1,20 +1,16 @@
1
1
  export { BaseAnimationBuilder } from './BaseAnimationBuilder';
2
- export { BaseBounceAnimationBuilder } from './BaseBounceAnimationBuilder';
3
- export { LayoutAnimationBuilder, Layout } from './LayoutAnimationBuilder';
2
+ export { ComplexAnimationBuilder } from './ComplexAnimationBuilder';
4
3
  export { Keyframe } from './Keyframe';
5
4
  export {
6
5
  LayoutAnimation,
7
6
  AnimationFunction,
8
7
  EntryExitAnimationsValues,
9
8
  EntryExitAnimationFunction,
10
- EntryExitAnimationBuild,
11
9
  LayoutAnimationsValues,
12
10
  LayoutAnimationFunction,
13
11
  ILayoutAnimationBuilder,
14
12
  BaseLayoutAnimationConfig,
15
13
  BaseBuilderAnimationConfig,
16
14
  LayoutAnimationAndConfig,
17
- BounceBuilderAnimationConfig,
18
15
  IEntryExitAnimationBuilder,
19
- LayoutAnimationBuild,
20
16
  } from './commonTypes';
@@ -1,24 +1,32 @@
1
1
  import {
2
+ EntryExitAnimationFunction,
2
3
  IEntryExitAnimationBuilder,
3
- EntryExitAnimationBuild,
4
4
  } from '../animationBuilder/commonTypes';
5
- import { BaseBounceAnimationBuilder } from '../animationBuilder/BaseBounceAnimationBuilder';
6
5
  import { withSequence, withTiming } from '../../animation';
7
6
  import { Dimensions } from 'react-native';
7
+ import { BaseAnimationBuilder } from '../animationBuilder/BaseAnimationBuilder';
8
8
 
9
9
  const { width, height } = Dimensions.get('window');
10
10
 
11
11
  export class BounceIn
12
- extends BaseBounceAnimationBuilder
12
+ extends BaseAnimationBuilder
13
13
  implements IEntryExitAnimationBuilder {
14
14
  static createInstance(): BounceIn {
15
15
  return new BounceIn();
16
16
  }
17
17
 
18
- build: EntryExitAnimationBuild = () => {
18
+ static getDuration(): number {
19
+ return 600;
20
+ }
21
+
22
+ getDuration(): number {
23
+ return this.durationV ?? 600;
24
+ }
25
+
26
+ build = (): EntryExitAnimationFunction => {
19
27
  const delayFunction = this.getDelayFunction();
20
- const delay = this.delayV;
21
- const duration = this.durationV ? this.durationV : 250;
28
+ const delay = this.getDelay();
29
+ const duration = this.getDuration();
22
30
  const callback = this.callbackV;
23
31
 
24
32
  return () => {
@@ -30,10 +38,10 @@ export class BounceIn
30
38
  scale: delayFunction(
31
39
  delay,
32
40
  withSequence(
33
- withTiming(1.2, { duration: duration }),
34
- withTiming(0.9, { duration: (duration * 100) / 250 }),
35
- withTiming(1.1, { duration: (duration * 100) / 250 }),
36
- withTiming(1, { duration: (duration * 100) / 250 })
41
+ withTiming(1.2, { duration: duration * 0.55 }),
42
+ withTiming(0.9, { duration: duration * 0.15 }),
43
+ withTiming(1.1, { duration: duration * 0.15 }),
44
+ withTiming(1, { duration: duration * 0.15 })
37
45
  )
38
46
  ),
39
47
  },
@@ -49,16 +57,24 @@ export class BounceIn
49
57
  }
50
58
 
51
59
  export class BounceInDown
52
- extends BaseBounceAnimationBuilder
60
+ extends BaseAnimationBuilder
53
61
  implements IEntryExitAnimationBuilder {
54
62
  static createInstance(): BounceInDown {
55
63
  return new BounceInDown();
56
64
  }
57
65
 
58
- build: EntryExitAnimationBuild = () => {
66
+ static getDuration(): number {
67
+ return 600;
68
+ }
69
+
70
+ getDuration(): number {
71
+ return this.durationV ?? 600;
72
+ }
73
+
74
+ build = (): EntryExitAnimationFunction => {
59
75
  const delayFunction = this.getDelayFunction();
60
- const delay = this.delayV;
61
- const duration = this.durationV ? this.durationV : 250;
76
+ const delay = this.getDelay();
77
+ const duration = this.getDuration();
62
78
  const callback = this.callbackV;
63
79
 
64
80
  return () => {
@@ -70,10 +86,10 @@ export class BounceInDown
70
86
  translateY: delayFunction(
71
87
  delay,
72
88
  withSequence(
73
- withTiming(-20, { duration: duration }),
74
- withTiming(10, { duration: (duration * 100) / 250 }),
75
- withTiming(-10, { duration: (duration * 100) / 250 }),
76
- withTiming(0, { duration: (duration * 100) / 250 })
89
+ withTiming(-20, { duration: duration * 0.55 }),
90
+ withTiming(10, { duration: duration * 0.15 }),
91
+ withTiming(-10, { duration: duration * 0.15 }),
92
+ withTiming(0, { duration: duration * 0.15 })
77
93
  )
78
94
  ),
79
95
  },
@@ -93,16 +109,24 @@ export class BounceInDown
93
109
  }
94
110
 
95
111
  export class BounceInUp
96
- extends BaseBounceAnimationBuilder
112
+ extends BaseAnimationBuilder
97
113
  implements IEntryExitAnimationBuilder {
98
114
  static createInstance(): BounceInUp {
99
115
  return new BounceInUp();
100
116
  }
101
117
 
102
- build: EntryExitAnimationBuild = () => {
118
+ static getDuration(): number {
119
+ return 600;
120
+ }
121
+
122
+ getDuration(): number {
123
+ return this.durationV ?? 600;
124
+ }
125
+
126
+ build = (): EntryExitAnimationFunction => {
103
127
  const delayFunction = this.getDelayFunction();
104
- const delay = this.delayV;
105
- const duration = this.durationV ? this.durationV : 250;
128
+ const delay = this.getDelay();
129
+ const duration = this.getDuration();
106
130
  const callback = this.callbackV;
107
131
 
108
132
  return () => {
@@ -114,10 +138,10 @@ export class BounceInUp
114
138
  translateY: delayFunction(
115
139
  delay,
116
140
  withSequence(
117
- withTiming(20, { duration: duration }),
118
- withTiming(-10, { duration: (duration * 100) / 250 }),
119
- withTiming(10, { duration: (duration * 100) / 250 }),
120
- withTiming(0, { duration: (duration * 100) / 250 })
141
+ withTiming(20, { duration: duration * 0.55 }),
142
+ withTiming(-10, { duration: duration * 0.15 }),
143
+ withTiming(10, { duration: duration * 0.15 }),
144
+ withTiming(0, { duration: duration * 0.15 })
121
145
  )
122
146
  ),
123
147
  },
@@ -133,16 +157,24 @@ export class BounceInUp
133
157
  }
134
158
 
135
159
  export class BounceInLeft
136
- extends BaseBounceAnimationBuilder
160
+ extends BaseAnimationBuilder
137
161
  implements IEntryExitAnimationBuilder {
138
162
  static createInstance(): BounceInLeft {
139
163
  return new BounceInLeft();
140
164
  }
141
165
 
142
- build: EntryExitAnimationBuild = () => {
166
+ static getDuration(): number {
167
+ return 600;
168
+ }
169
+
170
+ getDuration(): number {
171
+ return this.durationV ?? 600;
172
+ }
173
+
174
+ build = (): EntryExitAnimationFunction => {
143
175
  const delayFunction = this.getDelayFunction();
144
- const delay = this.delayV;
145
- const duration = this.durationV ? this.durationV : 250;
176
+ const delay = this.getDelay();
177
+ const duration = this.getDuration();
146
178
  const callback = this.callbackV;
147
179
 
148
180
  return () => {
@@ -154,10 +186,10 @@ export class BounceInLeft
154
186
  translateX: delayFunction(
155
187
  delay,
156
188
  withSequence(
157
- withTiming(20, { duration: duration }),
158
- withTiming(-10, { duration: (duration * 100) / 250 }),
159
- withTiming(10, { duration: (duration * 100) / 250 }),
160
- withTiming(0, { duration: (duration * 100) / 250 })
189
+ withTiming(20, { duration: duration * 0.55 }),
190
+ withTiming(-10, { duration: duration * 0.15 }),
191
+ withTiming(10, { duration: duration * 0.15 }),
192
+ withTiming(0, { duration: duration * 0.15 })
161
193
  )
162
194
  ),
163
195
  },
@@ -173,16 +205,24 @@ export class BounceInLeft
173
205
  }
174
206
 
175
207
  export class BounceInRight
176
- extends BaseBounceAnimationBuilder
208
+ extends BaseAnimationBuilder
177
209
  implements IEntryExitAnimationBuilder {
178
210
  static createInstance(): BounceInRight {
179
211
  return new BounceInRight();
180
212
  }
181
213
 
182
- build: EntryExitAnimationBuild = () => {
214
+ static getDuration(): number {
215
+ return 600;
216
+ }
217
+
218
+ getDuration(): number {
219
+ return this.durationV ?? 600;
220
+ }
221
+
222
+ build = (): EntryExitAnimationFunction => {
183
223
  const delayFunction = this.getDelayFunction();
184
- const delay = this.delayV;
185
- const duration = this.durationV ? this.durationV : 250;
224
+ const delay = this.getDelay();
225
+ const duration = this.getDuration();
186
226
  const callback = this.callbackV;
187
227
 
188
228
  return () => {
@@ -194,10 +234,10 @@ export class BounceInRight
194
234
  translateX: delayFunction(
195
235
  delay,
196
236
  withSequence(
197
- withTiming(-20, { duration: duration }),
198
- withTiming(10, { duration: (duration * 100) / 250 }),
199
- withTiming(-10, { duration: (duration * 100) / 250 }),
200
- withTiming(0, { duration: (duration * 100) / 250 })
237
+ withTiming(-20, { duration: duration * 0.55 }),
238
+ withTiming(10, { duration: duration * 0.15 }),
239
+ withTiming(-10, { duration: duration * 0.15 }),
240
+ withTiming(0, { duration: duration * 0.15 })
201
241
  )
202
242
  ),
203
243
  },
@@ -213,16 +253,24 @@ export class BounceInRight
213
253
  }
214
254
 
215
255
  export class BounceOut
216
- extends BaseBounceAnimationBuilder
256
+ extends BaseAnimationBuilder
217
257
  implements IEntryExitAnimationBuilder {
218
258
  static createInstance(): BounceOut {
219
259
  return new BounceOut();
220
260
  }
221
261
 
222
- build: EntryExitAnimationBuild = () => {
262
+ static getDuration(): number {
263
+ return 600;
264
+ }
265
+
266
+ getDuration(): number {
267
+ return this.durationV ?? 600;
268
+ }
269
+
270
+ build = (): EntryExitAnimationFunction => {
223
271
  const delayFunction = this.getDelayFunction();
224
- const delay = this.delayV;
225
- const duration = this.durationV ? this.durationV : 250;
272
+ const delay = this.getDelay();
273
+ const duration = this.getDuration();
226
274
  const callback = this.callbackV;
227
275
 
228
276
  return () => {
@@ -234,10 +282,10 @@ export class BounceOut
234
282
  scale: delayFunction(
235
283
  delay,
236
284
  withSequence(
237
- withTiming(1.1, { duration: (duration * 100) / 250 }),
238
- withTiming(0.9, { duration: (duration * 100) / 250 }),
239
- withTiming(1.2, { duration: (duration * 100) / 250 }),
240
- withTiming(0, { duration: duration })
285
+ withTiming(1.1, { duration: duration * 0.15 }),
286
+ withTiming(0.9, { duration: duration * 0.15 }),
287
+ withTiming(1.2, { duration: duration * 0.15 }),
288
+ withTiming(0, { duration: duration * 0.55 })
241
289
  )
242
290
  ),
243
291
  },
@@ -253,16 +301,24 @@ export class BounceOut
253
301
  }
254
302
 
255
303
  export class BounceOutDown
256
- extends BaseBounceAnimationBuilder
304
+ extends BaseAnimationBuilder
257
305
  implements IEntryExitAnimationBuilder {
258
306
  static createInstance(): BounceOutDown {
259
307
  return new BounceOutDown();
260
308
  }
261
309
 
262
- build: EntryExitAnimationBuild = () => {
310
+ static getDuration(): number {
311
+ return 600;
312
+ }
313
+
314
+ getDuration(): number {
315
+ return this.durationV ?? 600;
316
+ }
317
+
318
+ build = (): EntryExitAnimationFunction => {
263
319
  const delayFunction = this.getDelayFunction();
264
- const delay = this.delayV;
265
- const duration = this.durationV ? this.durationV : 250;
320
+ const delay = this.getDelay();
321
+ const duration = this.getDuration();
266
322
  const callback = this.callbackV;
267
323
 
268
324
  return () => {
@@ -274,11 +330,11 @@ export class BounceOutDown
274
330
  translateY: delayFunction(
275
331
  delay,
276
332
  withSequence(
277
- withTiming(-10, { duration: (duration * 100) / 250 }),
278
- withTiming(10, { duration: (duration * 100) / 250 }),
279
- withTiming(-20, { duration: (duration * 100) / 250 }),
333
+ withTiming(-10, { duration: duration * 0.15 }),
334
+ withTiming(10, { duration: duration * 0.15 }),
335
+ withTiming(-20, { duration: duration * 0.15 }),
280
336
  withTiming(height, {
281
- duration: duration,
337
+ duration: duration * 0.55,
282
338
  })
283
339
  )
284
340
  ),
@@ -295,16 +351,24 @@ export class BounceOutDown
295
351
  }
296
352
 
297
353
  export class BounceOutUp
298
- extends BaseBounceAnimationBuilder
354
+ extends BaseAnimationBuilder
299
355
  implements IEntryExitAnimationBuilder {
300
356
  static createInstance(): BounceOutUp {
301
357
  return new BounceOutUp();
302
358
  }
303
359
 
304
- build: EntryExitAnimationBuild = () => {
360
+ static getDuration(): number {
361
+ return 600;
362
+ }
363
+
364
+ getDuration(): number {
365
+ return this.durationV ?? 600;
366
+ }
367
+
368
+ build = (): EntryExitAnimationFunction => {
305
369
  const delayFunction = this.getDelayFunction();
306
- const delay = this.delayV;
307
- const duration = this.durationV ? this.durationV : 250;
370
+ const delay = this.getDelay();
371
+ const duration = this.getDuration();
308
372
  const callback = this.callbackV;
309
373
 
310
374
  return () => {
@@ -316,11 +380,11 @@ export class BounceOutUp
316
380
  translateY: delayFunction(
317
381
  delay,
318
382
  withSequence(
319
- withTiming(10, { duration: (duration * 100) / 250 }),
320
- withTiming(-10, { duration: (duration * 100) / 250 }),
321
- withTiming(20, { duration: (duration * 100) / 250 }),
383
+ withTiming(10, { duration: duration * 0.15 }),
384
+ withTiming(-10, { duration: duration * 0.15 }),
385
+ withTiming(20, { duration: duration * 0.15 }),
322
386
  withTiming(-height, {
323
- duration: duration,
387
+ duration: duration * 0.55,
324
388
  })
325
389
  )
326
390
  ),
@@ -337,16 +401,24 @@ export class BounceOutUp
337
401
  }
338
402
 
339
403
  export class BounceOutLeft
340
- extends BaseBounceAnimationBuilder
404
+ extends BaseAnimationBuilder
341
405
  implements IEntryExitAnimationBuilder {
342
406
  static createInstance(): BounceOutRight {
343
407
  return new BounceOutLeft();
344
408
  }
345
409
 
346
- build: EntryExitAnimationBuild = () => {
410
+ static getDuration(): number {
411
+ return 600;
412
+ }
413
+
414
+ getDuration(): number {
415
+ return this.durationV ?? 600;
416
+ }
417
+
418
+ build = (): EntryExitAnimationFunction => {
347
419
  const delayFunction = this.getDelayFunction();
348
- const delay = this.delayV;
349
- const duration = this.durationV ? this.durationV : 250;
420
+ const delay = this.getDelay();
421
+ const duration = this.getDuration();
350
422
  const callback = this.callbackV;
351
423
 
352
424
  return () => {
@@ -358,11 +430,11 @@ export class BounceOutLeft
358
430
  translateX: delayFunction(
359
431
  delay,
360
432
  withSequence(
361
- withTiming(10, { duration: (duration * 100) / 250 }),
362
- withTiming(-10, { duration: (duration * 100) / 250 }),
363
- withTiming(20, { duration: (duration * 100) / 250 }),
433
+ withTiming(10, { duration: duration * 0.15 }),
434
+ withTiming(-10, { duration: duration * 0.15 }),
435
+ withTiming(20, { duration: duration * 0.15 }),
364
436
  withTiming(-width, {
365
- duration: duration,
437
+ duration: duration * 0.55,
366
438
  })
367
439
  )
368
440
  ),
@@ -379,16 +451,24 @@ export class BounceOutLeft
379
451
  }
380
452
 
381
453
  export class BounceOutRight
382
- extends BaseBounceAnimationBuilder
454
+ extends BaseAnimationBuilder
383
455
  implements IEntryExitAnimationBuilder {
384
456
  static createInstance(): BounceOutRight {
385
457
  return new BounceOutRight();
386
458
  }
387
459
 
388
- build: EntryExitAnimationBuild = () => {
460
+ static getDuration(): number {
461
+ return 600;
462
+ }
463
+
464
+ getDuration(): number {
465
+ return this.durationV ?? 600;
466
+ }
467
+
468
+ build = (): EntryExitAnimationFunction => {
389
469
  const delayFunction = this.getDelayFunction();
390
- const delay = this.delayV;
391
- const duration = this.durationV ? this.durationV : 250;
470
+ const delay = this.getDelay();
471
+ const duration = this.getDuration();
392
472
  const callback = this.callbackV;
393
473
 
394
474
  return () => {
@@ -400,11 +480,11 @@ export class BounceOutRight
400
480
  translateX: delayFunction(
401
481
  delay,
402
482
  withSequence(
403
- withTiming(-10, { duration: (duration * 100) / 250 }),
404
- withTiming(10, { duration: (duration * 100) / 250 }),
405
- withTiming(-20, { duration: (duration * 100) / 250 }),
483
+ withTiming(-10, { duration: duration * 0.15 }),
484
+ withTiming(10, { duration: duration * 0.15 }),
485
+ withTiming(-20, { duration: duration * 0.15 }),
406
486
  withTiming(width, {
407
- duration: duration,
487
+ duration: duration * 0.55,
408
488
  })
409
489
  )
410
490
  ),