react-native-reanimated 2.3.0-beta.2 → 2.3.1

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 (168) hide show
  1. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +12 -3
  2. package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +13 -0
  3. package/Common/cpp/Registries/EventHandlerRegistry.cpp +2 -2
  4. package/Common/cpp/Registries/MapperRegistry.cpp +5 -5
  5. package/Common/cpp/SharedItems/FrozenObject.cpp +1 -3
  6. package/Common/cpp/SharedItems/ShareableValue.cpp +8 -10
  7. package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
  8. package/Common/cpp/Tools/JSIStoreValueUser.cpp +8 -8
  9. package/Common/cpp/Tools/Mapper.cpp +1 -1
  10. package/Common/cpp/Tools/RuntimeDecorator.cpp +40 -4
  11. package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -1
  12. package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +5 -0
  13. package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +6 -1
  14. package/Common/cpp/headers/Registries/EventHandlerRegistry.h +1 -0
  15. package/Common/cpp/headers/Registries/MapperRegistry.h +1 -0
  16. package/Common/cpp/headers/SharedItems/FrozenObject.h +4 -0
  17. package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +2 -0
  18. package/Common/cpp/headers/SharedItems/MutableValue.h +2 -0
  19. package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +3 -1
  20. package/Common/cpp/headers/SharedItems/RemoteObject.h +4 -1
  21. package/Common/cpp/headers/SharedItems/ShareableValue.h +2 -0
  22. package/Common/cpp/headers/SharedItems/SharedParent.h +9 -9
  23. package/Common/cpp/headers/SharedItems/ValueWrapper.h +32 -28
  24. package/Common/cpp/headers/SpecTools/ErrorHandler.h +1 -0
  25. package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
  26. package/Common/cpp/headers/Tools/JSIStoreValueUser.h +2 -5
  27. package/Common/cpp/headers/Tools/Mapper.h +2 -0
  28. package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +5 -0
  29. package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +1 -5
  30. package/Common/cpp/headers/Tools/RuntimeDecorator.h +10 -7
  31. package/Common/cpp/headers/Tools/Scheduler.h +2 -0
  32. package/Common/cpp/headers/Tools/WorkletEventHandler.h +2 -1
  33. package/Common/cpp/hidden_headers/Logger.h +2 -2
  34. package/Common/cpp/hidden_headers/LoggerInterface.h +1 -1
  35. package/README.md +1 -1
  36. package/RNReanimated.podspec +21 -3
  37. package/android/build.gradle +33 -13
  38. package/android/expo/linking.gradle +46 -0
  39. package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +12 -0
  40. package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +26 -0
  41. package/android/react-native-reanimated-63-hermes.aar +0 -0
  42. package/android/react-native-reanimated-63-jsc.aar +0 -0
  43. package/android/react-native-reanimated-64-hermes.aar +0 -0
  44. package/android/react-native-reanimated-64-jsc.aar +0 -0
  45. package/android/react-native-reanimated-65-hermes.aar +0 -0
  46. package/android/react-native-reanimated-65-jsc.aar +0 -0
  47. package/android/react-native-reanimated-66-hermes.aar +0 -0
  48. package/android/react-native-reanimated-66-jsc.aar +0 -0
  49. package/android/react-native-reanimated-67-hermes.aar +0 -0
  50. package/android/react-native-reanimated-67-jsc.aar +0 -0
  51. package/expo-module.config.json +3 -0
  52. package/ios/LayoutReanimation/REAAnimationsManager.m +65 -19
  53. package/ios/LayoutReanimation/REAUIManager.mm +101 -61
  54. package/ios/Nodes/REAPropsNode.m +1 -1
  55. package/ios/REAEventDispatcher.m +1 -1
  56. package/ios/REAModule.h +0 -2
  57. package/ios/REAModule.m +0 -3
  58. package/ios/REANodesManager.m +1 -0
  59. package/ios/RNGestureHandlerStateManager.h +5 -0
  60. package/ios/native/NativeMethods.h +5 -0
  61. package/ios/native/NativeMethods.mm +14 -6
  62. package/ios/native/NativeProxy.h +1 -0
  63. package/ios/native/NativeProxy.mm +84 -63
  64. package/ios/native/REAIOSErrorHandler.mm +19 -15
  65. package/ios/native/REAIOSLogger.mm +10 -6
  66. package/ios/native/REAIOSScheduler.mm +17 -10
  67. package/ios/native/REAInitializer.mm +39 -37
  68. package/ios/native/UIResponder+Reanimated.mm +2 -2
  69. package/lib/Animated.js +11 -5
  70. package/lib/ConfigHelper.js +121 -138
  71. package/lib/ReanimatedEventEmitter.js +0 -1
  72. package/lib/ReanimatedModule.js +0 -1
  73. package/lib/ReanimatedModule.macos.js +0 -1
  74. package/lib/ReanimatedModule.native.js +5 -6
  75. package/lib/ReanimatedModule.windows.js +0 -1
  76. package/lib/ReanimatedModuleCompat.js +64 -35
  77. package/lib/createAnimatedComponent.js +469 -499
  78. package/lib/index.js +11 -5
  79. package/lib/reanimated1/core/Core.test.js +1 -1
  80. package/lib/reanimated2/NativeMethods.js +7 -0
  81. package/lib/reanimated2/NativeReanimated/NativeReanimated.js +3 -0
  82. package/lib/reanimated2/PropAdapters.js +0 -1
  83. package/lib/reanimated2/UpdateProps.js +1 -1
  84. package/lib/reanimated2/ViewDescriptorsSet.js +4 -2
  85. package/lib/reanimated2/animation/spring.js +2 -0
  86. package/lib/reanimated2/animation/styleAnimation.js +5 -1
  87. package/lib/reanimated2/animation/util.js +23 -0
  88. package/lib/reanimated2/component/FlatList.js +30 -0
  89. package/lib/reanimated2/component/WrappedComponents.js +9 -0
  90. package/lib/reanimated2/component/index.js +4 -0
  91. package/lib/reanimated2/core.js +34 -6
  92. package/lib/reanimated2/globals.d.ts +8 -0
  93. package/lib/reanimated2/js-reanimated/JSReanimated.js +4 -0
  94. package/lib/reanimated2/js-reanimated/Mapper.js +4 -3
  95. package/lib/reanimated2/js-reanimated/MapperRegistry.js +3 -6
  96. package/lib/reanimated2/js-reanimated/MutableValue.js +0 -2
  97. package/lib/reanimated2/js-reanimated/index.js +10 -8
  98. package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +14 -5
  99. package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +14 -14
  100. package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +8 -8
  101. package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +16 -16
  102. package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +16 -16
  103. package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +4 -4
  104. package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +20 -8
  105. package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +3 -3
  106. package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +8 -8
  107. package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +10 -10
  108. package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +8 -8
  109. package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -8
  110. package/lib/reanimated2/mock.js +3 -1
  111. package/lib/setAndForwardRef.js +14 -48
  112. package/mock.js +1 -1
  113. package/package.json +27 -23
  114. package/plugin.js +111 -110
  115. package/react-native-reanimated.d.ts +56 -27
  116. package/src/Animated.js +11 -5
  117. package/src/{ConfigHelper.js → ConfigHelper.ts} +15 -7
  118. package/src/{ReanimatedEventEmitter.js → ReanimatedEventEmitter.ts} +0 -0
  119. package/src/{ReanimatedModule.js → ReanimatedModule.macos.ts} +0 -0
  120. package/src/{ReanimatedModule.native.js → ReanimatedModule.native.ts} +0 -0
  121. package/src/{ReanimatedModule.macos.js → ReanimatedModule.ts} +0 -0
  122. package/src/{ReanimatedModule.windows.js → ReanimatedModule.windows.ts} +0 -0
  123. package/src/ReanimatedModuleCompat.ts +51 -0
  124. package/src/{createAnimatedComponent.js → createAnimatedComponent.tsx} +278 -124
  125. package/src/reanimated1/core/Core.test.js +1 -1
  126. package/src/reanimated2/NativeMethods.ts +13 -1
  127. package/src/reanimated2/NativeReanimated/NativeReanimated.ts +5 -11
  128. package/src/reanimated2/PropAdapters.ts +0 -1
  129. package/src/reanimated2/UpdateProps.ts +1 -1
  130. package/src/reanimated2/ViewDescriptorsSet.ts +6 -2
  131. package/src/reanimated2/animation/commonTypes.ts +4 -4
  132. package/src/reanimated2/animation/decay.ts +2 -2
  133. package/src/reanimated2/animation/delay.ts +3 -3
  134. package/src/reanimated2/animation/index.ts +7 -7
  135. package/src/reanimated2/animation/repeat.ts +4 -4
  136. package/src/reanimated2/animation/sequence.ts +2 -2
  137. package/src/reanimated2/animation/spring.ts +6 -5
  138. package/src/reanimated2/animation/styleAnimation.ts +24 -12
  139. package/src/reanimated2/animation/timing.ts +5 -5
  140. package/src/reanimated2/animation/util.ts +45 -6
  141. package/src/reanimated2/component/FlatList.tsx +44 -0
  142. package/src/reanimated2/component/WrappedComponents.ts +11 -0
  143. package/src/reanimated2/component/index.ts +9 -0
  144. package/src/reanimated2/core.ts +62 -17
  145. package/src/reanimated2/globals.d.ts +8 -0
  146. package/src/reanimated2/hook/useAnimatedStyle.ts +2 -2
  147. package/src/reanimated2/js-reanimated/JSReanimated.ts +15 -26
  148. package/src/reanimated2/js-reanimated/Mapper.ts +22 -9
  149. package/src/reanimated2/js-reanimated/MapperRegistry.ts +22 -19
  150. package/src/reanimated2/js-reanimated/MutableValue.ts +11 -11
  151. package/src/reanimated2/js-reanimated/index.ts +31 -14
  152. package/src/reanimated2/layoutReanimation/{LayoutAnimationRepository.tsx → LayoutAnimationRepository.ts} +18 -5
  153. package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +39 -20
  154. package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +5 -1
  155. package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +21 -15
  156. package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +29 -24
  157. package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +61 -34
  158. package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +49 -34
  159. package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +17 -12
  160. package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +20 -8
  161. package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +9 -9
  162. package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +8 -8
  163. package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +20 -14
  164. package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +14 -8
  165. package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +24 -12
  166. package/src/reanimated2/mock.ts +3 -1
  167. package/src/{setAndForwardRef.js → setAndForwardRef.ts} +12 -2
  168. package/src/ReanimatedModuleCompat.js +0 -37
@@ -22,8 +22,8 @@ export class RotateInDownLeft extends ComplexAnimationBuilder {
22
22
  opacity: 0,
23
23
  transform: [
24
24
  { rotate: '-90deg' },
25
- { translateX: values.width / 2 - values.height / 2 },
26
- { translateY: -(values.width / 2 - values.height / 2) },
25
+ { translateX: values.targetWidth / 2 - values.targetHeight / 2 },
26
+ { translateY: -(values.targetWidth / 2 - values.targetHeight / 2) },
27
27
  ],
28
28
  },
29
29
  callback: callback,
@@ -58,8 +58,8 @@ export class RotateInDownRight extends ComplexAnimationBuilder {
58
58
  opacity: 0,
59
59
  transform: [
60
60
  { rotate: '90deg' },
61
- { translateX: -(values.width / 2 - values.height / 2) },
62
- { translateY: -(values.width / 2 - values.height / 2) },
61
+ { translateX: -(values.targetWidth / 2 - values.targetHeight / 2) },
62
+ { translateY: -(values.targetWidth / 2 - values.targetHeight / 2) },
63
63
  ],
64
64
  },
65
65
  callback: callback,
@@ -94,8 +94,8 @@ export class RotateInUpLeft extends ComplexAnimationBuilder {
94
94
  opacity: 0,
95
95
  transform: [
96
96
  { rotate: '90deg' },
97
- { translateX: values.width / 2 - values.height / 2 },
98
- { translateY: values.width / 2 - values.height / 2 },
97
+ { translateX: values.targetWidth / 2 - values.targetHeight / 2 },
98
+ { translateY: values.targetWidth / 2 - values.targetHeight / 2 },
99
99
  ],
100
100
  },
101
101
  callback: callback,
@@ -130,8 +130,8 @@ export class RotateInUpRight extends ComplexAnimationBuilder {
130
130
  opacity: 0,
131
131
  transform: [
132
132
  { rotate: '-90deg' },
133
- { translateX: -(values.width / 2 - values.height / 2) },
134
- { translateY: values.width / 2 - values.height / 2 },
133
+ { translateX: -(values.targetWidth / 2 - values.targetHeight / 2) },
134
+ { translateY: values.targetWidth / 2 - values.targetHeight / 2 },
135
135
  ],
136
136
  },
137
137
  callback: callback,
@@ -159,10 +159,10 @@ export class RotateOutDownLeft extends ComplexAnimationBuilder {
159
159
  transform: [
160
160
  { rotate: delayFunction(delay, animation('90deg', config)) },
161
161
  {
162
- translateX: delayFunction(delay, animation(values.width / 2 - values.height / 2, config)),
162
+ translateX: delayFunction(delay, animation(values.currentWidth / 2 - values.currentHeight / 2, config)),
163
163
  },
164
164
  {
165
- translateY: delayFunction(delay, animation(values.width / 2 - values.height / 2, config)),
165
+ translateY: delayFunction(delay, animation(values.currentWidth / 2 - values.currentHeight / 2, config)),
166
166
  },
167
167
  ],
168
168
  },
@@ -195,10 +195,10 @@ export class RotateOutDownRight extends ComplexAnimationBuilder {
195
195
  transform: [
196
196
  { rotate: delayFunction(delay, animation('-90deg', config)) },
197
197
  {
198
- translateX: delayFunction(delay, animation(-(values.width / 2 - values.height / 2), config)),
198
+ translateX: delayFunction(delay, animation(-(values.currentWidth / 2 - values.currentHeight / 2), config)),
199
199
  },
200
200
  {
201
- translateY: delayFunction(delay, animation(values.width / 2 - values.height / 2, config)),
201
+ translateY: delayFunction(delay, animation(values.currentWidth / 2 - values.currentHeight / 2, config)),
202
202
  },
203
203
  ],
204
204
  },
@@ -231,10 +231,10 @@ export class RotateOutUpLeft extends ComplexAnimationBuilder {
231
231
  transform: [
232
232
  { rotate: delayFunction(delay, animation('-90deg', config)) },
233
233
  {
234
- translateX: delayFunction(delay, animation(values.width / 2 - values.height / 2, config)),
234
+ translateX: delayFunction(delay, animation(values.currentWidth / 2 - values.currentHeight / 2, config)),
235
235
  },
236
236
  {
237
- translateY: delayFunction(delay, animation(-(values.width / 2 - values.height / 2), config)),
237
+ translateY: delayFunction(delay, animation(-(values.currentWidth / 2 - values.currentHeight / 2), config)),
238
238
  },
239
239
  ],
240
240
  },
@@ -267,10 +267,10 @@ export class RotateOutUpRight extends ComplexAnimationBuilder {
267
267
  transform: [
268
268
  { rotate: delayFunction(delay, animation('90deg', config)) },
269
269
  {
270
- translateX: delayFunction(delay, animation(-(values.width / 2 - values.height / 2), config)),
270
+ translateX: delayFunction(delay, animation(-(values.currentWidth / 2 - values.currentHeight / 2), config)),
271
271
  },
272
272
  {
273
- translateY: delayFunction(delay, animation(-(values.width / 2 - values.height / 2), config)),
273
+ translateY: delayFunction(delay, animation(-(values.currentWidth / 2 - values.currentHeight / 2), config)),
274
274
  },
275
275
  ],
276
276
  },
@@ -13,10 +13,10 @@ export class SlideInRight extends ComplexAnimationBuilder {
13
13
  'worklet';
14
14
  return {
15
15
  animations: {
16
- originX: delayFunction(delay, animation(values.originX, config)),
16
+ originX: delayFunction(delay, animation(values.targetOriginX, config)),
17
17
  },
18
18
  initialValues: {
19
- originX: values.originX + width,
19
+ originX: values.targetOriginX + width,
20
20
  },
21
21
  callback: callback,
22
22
  };
@@ -39,10 +39,10 @@ export class SlideInLeft extends ComplexAnimationBuilder {
39
39
  'worklet';
40
40
  return {
41
41
  animations: {
42
- originX: delayFunction(delay, animation(values.originX, config)),
42
+ originX: delayFunction(delay, animation(values.targetOriginX, config)),
43
43
  },
44
44
  initialValues: {
45
- originX: values.originX - width,
45
+ originX: values.targetOriginX - width,
46
46
  },
47
47
  callback: callback,
48
48
  };
@@ -65,10 +65,10 @@ export class SlideOutRight extends ComplexAnimationBuilder {
65
65
  'worklet';
66
66
  return {
67
67
  animations: {
68
- originX: delayFunction(delay, animation(Math.max(values.originX + width, width), config)),
68
+ originX: delayFunction(delay, animation(Math.max(values.currentOriginX + width, width), config)),
69
69
  },
70
70
  initialValues: {
71
- originX: values.originX,
71
+ originX: values.currentOriginX,
72
72
  },
73
73
  callback: callback,
74
74
  };
@@ -91,10 +91,10 @@ export class SlideOutLeft extends ComplexAnimationBuilder {
91
91
  'worklet';
92
92
  return {
93
93
  animations: {
94
- originX: delayFunction(delay, animation(Math.min(values.originX - width, -width), config)),
94
+ originX: delayFunction(delay, animation(Math.min(values.currentOriginX - width, -width), config)),
95
95
  },
96
96
  initialValues: {
97
- originX: values.originX,
97
+ originX: values.currentOriginX,
98
98
  },
99
99
  callback: callback,
100
100
  };
@@ -117,10 +117,10 @@ export class SlideInUp extends ComplexAnimationBuilder {
117
117
  'worklet';
118
118
  return {
119
119
  animations: {
120
- originY: delayFunction(delay, animation(values.originY, config)),
120
+ originY: delayFunction(delay, animation(values.targetOriginY, config)),
121
121
  },
122
122
  initialValues: {
123
- originY: height,
123
+ originY: -height,
124
124
  },
125
125
  callback: callback,
126
126
  };
@@ -143,10 +143,10 @@ export class SlideInDown extends ComplexAnimationBuilder {
143
143
  'worklet';
144
144
  return {
145
145
  animations: {
146
- originY: delayFunction(delay, animation(values.originY, config)),
146
+ originY: delayFunction(delay, animation(values.targetOriginY, config)),
147
147
  },
148
148
  initialValues: {
149
- originY: values.originY + height,
149
+ originY: values.targetOriginY + height,
150
150
  },
151
151
  callback: callback,
152
152
  };
@@ -169,9 +169,9 @@ export class SlideOutUp extends ComplexAnimationBuilder {
169
169
  'worklet';
170
170
  return {
171
171
  animations: {
172
- originY: delayFunction(delay, animation(Math.min(values.originY - height, -height), config)),
172
+ originY: delayFunction(delay, animation(Math.min(values.currentOriginY - height, -height), config)),
173
173
  },
174
- initialValues: { originY: values.originY },
174
+ initialValues: { originY: values.currentOriginY },
175
175
  callback: callback,
176
176
  };
177
177
  };
@@ -193,9 +193,9 @@ export class SlideOutDown extends ComplexAnimationBuilder {
193
193
  'worklet';
194
194
  return {
195
195
  animations: {
196
- originY: delayFunction(delay, animation(Math.max(values.originY + height, height), config)),
196
+ originY: delayFunction(delay, animation(Math.max(values.currentOriginY + height, height), config)),
197
197
  },
198
- initialValues: { originY: values.originY },
198
+ initialValues: { originY: values.currentOriginY },
199
199
  callback: callback,
200
200
  };
201
201
  };
@@ -191,7 +191,7 @@ export class ZoomInEasyUp extends ComplexAnimationBuilder {
191
191
  ],
192
192
  },
193
193
  initialValues: {
194
- transform: [{ translateY: -values.height }, { scale: 0 }],
194
+ transform: [{ translateY: -values.targetHeight }, { scale: 0 }],
195
195
  },
196
196
  callback: callback,
197
197
  };
@@ -220,7 +220,7 @@ export class ZoomInEasyDown extends ComplexAnimationBuilder {
220
220
  ],
221
221
  },
222
222
  initialValues: {
223
- transform: [{ translateY: values.height }, { scale: 0 }],
223
+ transform: [{ translateY: values.targetHeight }, { scale: 0 }],
224
224
  },
225
225
  callback: callback,
226
226
  };
@@ -417,7 +417,7 @@ export class ZoomOutEasyUp extends ComplexAnimationBuilder {
417
417
  animations: {
418
418
  transform: [
419
419
  {
420
- translateY: delayFunction(delay, animation(-values.height, config)),
420
+ translateY: delayFunction(delay, animation(-values.currentHeight, config)),
421
421
  },
422
422
  { scale: delayFunction(delay, animation(0, config)) },
423
423
  ],
@@ -448,7 +448,7 @@ export class ZoomOutEasyDown extends ComplexAnimationBuilder {
448
448
  animations: {
449
449
  transform: [
450
450
  {
451
- translateY: delayFunction(delay, animation(values.height, config)),
451
+ translateY: delayFunction(delay, animation(values.currentHeight, config)),
452
452
  },
453
453
  { scale: delayFunction(delay, animation(0, config)) },
454
454
  ],
@@ -24,16 +24,28 @@ export class CurvedTransition extends BaseAnimationBuilder {
24
24
  'worklet';
25
25
  return {
26
26
  initialValues: {
27
- originX: values.boriginX,
28
- originY: values.boriginY,
29
- width: values.bwidth,
30
- height: values.bheight,
27
+ originX: values.currentOriginX,
28
+ originY: values.currentOriginY,
29
+ width: values.currentWidth,
30
+ height: values.currentHeight,
31
31
  },
32
32
  animations: {
33
- originX: delayFunction(delay, withTiming(values.originX, { duration, easing: easing.easingX })),
34
- originY: delayFunction(delay, withTiming(values.originY, { duration, easing: easing.easingY })),
35
- width: delayFunction(delay, withTiming(values.width, { duration, easing: easing.easingWidth })),
36
- height: delayFunction(delay, withTiming(values.height, { duration, easing: easing.easingHeight })),
33
+ originX: delayFunction(delay, withTiming(values.targetOriginX, {
34
+ duration,
35
+ easing: easing.easingX,
36
+ })),
37
+ originY: delayFunction(delay, withTiming(values.targetOriginY, {
38
+ duration,
39
+ easing: easing.easingY,
40
+ })),
41
+ width: delayFunction(delay, withTiming(values.targetWidth, {
42
+ duration,
43
+ easing: easing.easingWidth,
44
+ })),
45
+ height: delayFunction(delay, withTiming(values.targetHeight, {
46
+ duration,
47
+ easing: easing.easingHeight,
48
+ })),
37
49
  },
38
50
  callback: callback,
39
51
  };
@@ -60,7 +60,7 @@ export class EntryExitTransition extends BaseAnimationBuilder {
60
60
  (_a = animations.transform) === null || _a === void 0 ? void 0 : _a.push({
61
61
  [transformProp]: delayFunction(delay + exitingDuration, withSequence(withTiming(enteringValues.initialValues.transform
62
62
  ? enteringValues.initialValues.transform[index][transformProp]
63
- : 0, { duration: 0 }), value[transformProp])),
63
+ : 0, { duration: exitingDuration }), value[transformProp])),
64
64
  });
65
65
  }
66
66
  });
@@ -96,8 +96,8 @@ export class EntryExitTransition extends BaseAnimationBuilder {
96
96
  return value;
97
97
  }));
98
98
  return {
99
- initialValues: Object.assign(Object.assign({}, exitingValues.initialValues), { originX: values.boriginX, originY: values.boriginY, width: values.bwidth, height: values.bheight, transform: mergedTransform }),
100
- animations: Object.assign({ originX: delayFunction(delay + exitingDuration, withTiming(values.originX, { duration: 0 })), originY: delayFunction(delay + exitingDuration, withTiming(values.originY, { duration: 0 })), width: delayFunction(delay + exitingDuration, withTiming(values.width, { duration: 0 })), height: delayFunction(delay + exitingDuration, withTiming(values.height, { duration: 0 })) }, animations),
99
+ initialValues: Object.assign(Object.assign({}, exitingValues.initialValues), { originX: values.currentOriginX, originY: values.currentOriginY, width: values.currentWidth, height: values.currentHeight, transform: mergedTransform }),
100
+ animations: Object.assign({ originX: delayFunction(delay + exitingDuration, withTiming(values.targetOriginX, { duration: exitingDuration })), originY: delayFunction(delay + exitingDuration, withTiming(values.targetOriginY, { duration: exitingDuration })), width: delayFunction(delay + exitingDuration, withTiming(values.targetWidth, { duration: exitingDuration })), height: delayFunction(delay + exitingDuration, withTiming(values.targetHeight, { duration: exitingDuration })) }, animations),
101
101
  callback: callback,
102
102
  };
103
103
  };
@@ -14,17 +14,17 @@ export class FadingTransition extends BaseAnimationBuilder {
14
14
  return {
15
15
  initialValues: {
16
16
  opacity: 1,
17
- originX: values.boriginX,
18
- originY: values.boriginY,
19
- width: values.bwidth,
20
- height: values.bheight,
17
+ originX: values.currentOriginX,
18
+ originY: values.currentOriginY,
19
+ width: values.currentWidth,
20
+ height: values.currentHeight,
21
21
  },
22
22
  animations: {
23
23
  opacity: delayFunction(delay, withSequence(withTiming(0, { duration: duration }), withTiming(1, { duration: duration }))),
24
- originX: delayFunction(delay + duration, withTiming(values.originX, { duration: 50 })),
25
- originY: delayFunction(delay + duration, withTiming(values.originY, { duration: 50 })),
26
- width: delayFunction(delay + duration, withTiming(values.width, { duration: 50 })),
27
- height: delayFunction(delay + duration, withTiming(values.height, { duration: 50 })),
24
+ originX: delayFunction(delay + duration, withTiming(values.targetOriginX, { duration: 50 })),
25
+ originY: delayFunction(delay + duration, withTiming(values.targetOriginY, { duration: 50 })),
26
+ width: delayFunction(delay + duration, withTiming(values.targetWidth, { duration: 50 })),
27
+ height: delayFunction(delay + duration, withTiming(values.targetHeight, { duration: 50 })),
28
28
  },
29
29
  callback: callback,
30
30
  };
@@ -13,22 +13,22 @@ export class JumpingTransition extends BaseAnimationBuilder {
13
13
  const config = { duration: duration * 2 };
14
14
  return (values) => {
15
15
  'worklet';
16
- const d = Math.max(Math.abs(values.originX - values.boriginX), Math.abs(values.originY - values.boriginY));
16
+ const d = Math.max(Math.abs(values.targetOriginX - values.currentOriginX), Math.abs(values.targetOriginY - values.currentOriginY));
17
17
  return {
18
18
  initialValues: {
19
- originX: values.boriginX,
20
- originY: values.boriginY,
21
- width: values.bwidth,
22
- height: values.bheight,
19
+ originX: values.currentOriginX,
20
+ originY: values.currentOriginY,
21
+ width: values.currentWidth,
22
+ height: values.currentHeight,
23
23
  },
24
24
  animations: {
25
- originX: delayFunction(delay, withTiming(values.originX, config)),
26
- originY: delayFunction(delay, withSequence(withTiming(Math.min(values.originY, values.boriginY) - d, {
25
+ originX: delayFunction(delay, withTiming(values.targetOriginX, config)),
26
+ originY: delayFunction(delay, withSequence(withTiming(Math.min(values.targetOriginY, values.currentOriginY) - d, {
27
27
  duration,
28
28
  easing: Easing.out(Easing.exp),
29
- }), withTiming(values.originY, Object.assign(Object.assign({}, config), { duration, easing: Easing.bounce })))),
30
- width: delayFunction(delay, withTiming(values.width, config)),
31
- height: delayFunction(delay, withTiming(values.height, config)),
29
+ }), withTiming(values.targetOriginY, Object.assign(Object.assign({}, config), { duration, easing: Easing.bounce })))),
30
+ width: delayFunction(delay, withTiming(values.targetWidth, config)),
31
+ height: delayFunction(delay, withTiming(values.targetHeight, config)),
32
32
  },
33
33
  callback: callback,
34
34
  };
@@ -11,16 +11,16 @@ export class LinearTransition extends ComplexAnimationBuilder {
11
11
  'worklet';
12
12
  return {
13
13
  initialValues: {
14
- originX: values.boriginX,
15
- originY: values.boriginY,
16
- width: values.bwidth,
17
- height: values.bheight,
14
+ originX: values.currentOriginX,
15
+ originY: values.currentOriginY,
16
+ width: values.currentWidth,
17
+ height: values.currentHeight,
18
18
  },
19
19
  animations: {
20
- originX: delayFunction(delay, animation(values.originX, config)),
21
- originY: delayFunction(delay, animation(values.originY, config)),
22
- width: delayFunction(delay, animation(values.width, config)),
23
- height: delayFunction(delay, animation(values.height, config)),
20
+ originX: delayFunction(delay, animation(values.targetOriginX, config)),
21
+ originY: delayFunction(delay, animation(values.targetOriginY, config)),
22
+ width: delayFunction(delay, animation(values.targetWidth, config)),
23
+ height: delayFunction(delay, animation(values.targetHeight, config)),
24
24
  },
25
25
  callback: callback,
26
26
  };
@@ -16,16 +16,16 @@ export class SequencedTransition extends BaseAnimationBuilder {
16
16
  'worklet';
17
17
  return {
18
18
  initialValues: {
19
- originX: values.boriginX,
20
- originY: values.boriginY,
21
- width: values.bwidth,
22
- height: values.bheight,
19
+ originX: values.currentOriginX,
20
+ originY: values.currentOriginY,
21
+ width: values.currentWidth,
22
+ height: values.currentHeight,
23
23
  },
24
24
  animations: {
25
- originX: delayFunction(delay, withSequence(withTiming(reverse ? values.boriginX : values.originX, config), withTiming(values.originX, config))),
26
- originY: delayFunction(delay, withSequence(withTiming(reverse ? values.originY : values.boriginY, config), withTiming(values.originY, config))),
27
- width: delayFunction(delay, withSequence(withTiming(reverse ? values.bwidth : values.width, config), withTiming(values.width, config))),
28
- height: delayFunction(delay, withSequence(withTiming(reverse ? values.height : values.bheight, config), withTiming(values.height, config))),
25
+ originX: delayFunction(delay, withSequence(withTiming(reverse ? values.currentOriginX : values.targetOriginX, config), withTiming(values.targetOriginX, config))),
26
+ originY: delayFunction(delay, withSequence(withTiming(reverse ? values.targetOriginY : values.currentOriginY, config), withTiming(values.targetOriginY, config))),
27
+ width: delayFunction(delay, withSequence(withTiming(reverse ? values.currentWidth : values.targetWidth, config), withTiming(values.targetWidth, config))),
28
+ height: delayFunction(delay, withSequence(withTiming(reverse ? values.targetHeight : values.currentHeight, config), withTiming(values.targetHeight, config))),
29
29
  },
30
30
  callback: callback,
31
31
  };
@@ -6,14 +6,16 @@ const NOOP = () => {
6
6
  // noop
7
7
  };
8
8
  const ID = (t) => t;
9
+ const IMMEDIATE_CB_INVOCATION = (cb) => cb();
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
  withTiming: (toValue, _, cb) => {
18
20
  cb && cb(true);
19
21
  return toValue;
@@ -1,53 +1,19 @@
1
1
  /**
2
2
  * imported from react-native
3
3
  */
4
-
5
- /**
6
- * This is a helper function for when a component needs to be able to forward a ref
7
- * to a child component, but still needs to have access to that component as part of
8
- * its implementation.
9
- *
10
- * Its main use case is in wrappers for native components.
11
- *
12
- * Usage:
13
- *
14
- * class MyView extends React.Component {
15
- * _nativeRef = null;
16
- *
17
- * _setNativeRef = setAndForwardRef({
18
- * getForwardedRef: () => this.props.forwardedRef,
19
- * setLocalRef: ref => {
20
- * this._nativeRef = ref;
21
- * },
22
- * });
23
- *
24
- * render() {
25
- * return <View ref={this._setNativeRef} />;
26
- * }
27
- * }
28
- *
29
- * const MyViewWithRef = React.forwardRef((props, ref) => (
30
- * <MyView {...props} forwardedRef={ref} />
31
- * ));
32
- *
33
- * module.exports = MyViewWithRef;
34
- */
35
-
36
- function setAndForwardRef({ getForwardedRef, setLocalRef }) {
37
- return function forwardRef(ref) {
38
- const forwardedRef = getForwardedRef();
39
-
40
- setLocalRef(ref);
41
-
42
- // Forward to user ref prop (if one has been specified)
43
- if (typeof forwardedRef === 'function') {
44
- // Handle function-based refs. String-based refs are handled as functions.
45
- forwardedRef(ref);
46
- } else if (typeof forwardedRef === 'object' && forwardedRef != null) {
47
- // Handle createRef-based refs
48
- forwardedRef.current = ref;
49
- }
50
- };
4
+ function setAndForwardRef({ getForwardedRef, setLocalRef, }) {
5
+ return function forwardRef(ref) {
6
+ const forwardedRef = getForwardedRef();
7
+ setLocalRef(ref);
8
+ // Forward to user ref prop (if one has been specified)
9
+ if (typeof forwardedRef === 'function') {
10
+ // Handle function-based refs. String-based refs are handled as functions.
11
+ forwardedRef(ref);
12
+ }
13
+ else if (typeof forwardedRef === 'object' && forwardedRef != null) {
14
+ // Handle createRef-based refs
15
+ forwardedRef.current = ref;
16
+ }
17
+ };
51
18
  }
52
-
53
19
  export default setAndForwardRef;
package/mock.js CHANGED
@@ -86,7 +86,7 @@ function createTransitioningComponent(Component) {
86
86
  }
87
87
 
88
88
  render() {
89
- return <Component {...this.props} />;
89
+ return React.createElement(Component, this.props);
90
90
  }
91
91
  };
92
92
  }
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "react-native-reanimated",
3
- "version": "2.3.0-beta.2",
3
+ "version": "2.3.1",
4
4
  "description": "More powerful alternative to Animated library for React Native.",
5
5
  "scripts": {
6
6
  "start": "node node_modules/react-native/local-cli/cli.js start",
7
- "test": "yarn run format && yarn run lint-check && yarn run test:unit",
7
+ "test": "yarn run format:js && yarn run lint:js && yarn run test:unit",
8
8
  "test:unit": "jest",
9
- "format": "prettier --write --list-different './src/'",
10
- "precommit": "yarn lint-java && yarn clang-format",
11
- "lint-check": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check src/",
12
- "lint-check-cpp": "./scripts/cpplint.sh",
13
- "lint-java": "node ./scripts/lint-java.js",
14
- "clang-format": "yarn clang-format-ios && yarn clang-format-android && yarn clang-format-common",
15
- "clang-format-ios": "find ios/ -iname *.h -o -iname *.m -o -iname *.cpp | xargs clang-format -i",
16
- "clang-format-android": "find android/src/ -iname *.h -o -iname *.m -o -iname *.cpp | xargs clang-format -i",
17
- "clang-format-common": "find Common/ -iname *.h -o -iname *.m -o -iname *.cpp | xargs clang-format -i",
9
+ "lint": "yarn lint:js && yarn lint:cpp && yarn lint:java",
10
+ "lint:js": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check src/",
11
+ "lint:java": "./android/gradlew -p android spotlessCheck -q",
12
+ "lint:cpp": "./scripts/cpplint.sh",
13
+ "format": "yarn format:js && yarn format:java && yarn format:ios && yarn format:android && yarn format:common",
14
+ "format:js": "prettier --write --list-different './src/'",
15
+ "format:java": "node ./scripts/format-java.js",
16
+ "format:ios": "find ios/ -iname *.h -o -iname *.m -o -iname *.mm -o -iname *.cpp | xargs clang-format -i",
17
+ "format:android": "find android/src/ -iname *.h -o -iname *.cpp | xargs clang-format -i",
18
+ "format:common": "find Common/ -iname *.h -o -iname *.cpp | xargs clang-format -i",
18
19
  "release": "npm login && release-it",
19
20
  "type:check": "yarn tsc --noEmit",
20
21
  "type:generate": "yarn type:generate:clean && yarn type:generate:cp-js-src && yarn type:generate:tsc && yarn type:generate:remove.ts && yarn type:generate:remove.tsx",
@@ -22,7 +23,8 @@
22
23
  "type:generate:cp-js-src": "cp -RL src/ lib/",
23
24
  "type:generate:tsc": "yarn tsc",
24
25
  "type:generate:remove.ts": "find ./lib -type f -name \"*.ts\" -and -not -name \"*.d.ts\" -delete",
25
- "type:generate:remove.tsx": "find ./lib -type f -name \"*.tsx\" -and -not -name \"*.d.ts\" -delete"
26
+ "type:generate:remove.tsx": "find ./lib -type f -name \"*.tsx\" -and -not -name \"*.d.ts\" -delete",
27
+ "prepare": "husky install"
26
28
  },
27
29
  "main": "lib/Animated.js",
28
30
  "module": "lib/Animated",
@@ -46,6 +48,7 @@
46
48
  "react-native-reanimated.d.ts",
47
49
  "mock.js",
48
50
  "plugin.js",
51
+ "expo-module.config.json",
49
52
  "!__snapshots__",
50
53
  "!*.test.js",
51
54
  "!*.test.js.map"
@@ -66,6 +69,7 @@
66
69
  "homepage": "https://github.com/software-mansion/react-native-reanimated#readme",
67
70
  "dependencies": {
68
71
  "@babel/plugin-transform-object-assign": "^7.10.4",
72
+ "@types/invariant": "^2.2.35",
69
73
  "invariant": "^2.2.4",
70
74
  "lodash.isequal": "^4.5.0",
71
75
  "mockdate": "^3.0.2",
@@ -107,28 +111,28 @@
107
111
  "eslint-plugin-node": "^10.0.0",
108
112
  "eslint-plugin-promise": "^4.2.1",
109
113
  "eslint-plugin-standard": "^4.0.1",
110
- "husky": "^4.2.5",
114
+ "husky": "^7.0.0",
111
115
  "jest": "^26.6.3",
112
- "lint-staged": "^10.2.11",
116
+ "lint-staged": "^11.2.0",
113
117
  "prettier": "^2.2.1",
114
118
  "react": "17.0.2",
115
- "react-native": "0.66.0-rc.4",
119
+ "react-native": "0.67.0-rc.4",
116
120
  "react-native-codegen": "^0.0.7",
117
121
  "react-native-gesture-handler": "^1.6.1",
118
122
  "react-test-renderer": "17.0.2",
119
- "release-it": "^13.1.1",
123
+ "release-it": "^13.7.2",
120
124
  "typescript": "^4.1.3"
121
125
  },
122
126
  "lint-staged": {
123
127
  "*.(js|ts|tsx)": [
124
- "eslint --ext '.js,.ts,.tsx' src/ --ignore-pattern src/reanimated1 --ignore-pattern react-native-reanimated.d.ts",
128
+ "eslint --ext '.js,.ts,.tsx' src/ --ignore-pattern src/reanimated1 --ignore-pattern react-native-reanimated.d.ts --ignore-pattern docs",
125
129
  "prettier --write"
126
- ]
127
- },
128
- "husky": {
129
- "hooks": {
130
- "pre-commit": "lint-staged"
131
- }
130
+ ],
131
+ "**/*.{h,cpp}": "yarn lint:cpp",
132
+ "android/src/**/*.java": "yarn format:java",
133
+ "android/src/**/*.{h,cpp}": "yarn format:android",
134
+ "ios/**/*.{h,m,mm,cpp}": "yarn format:ios",
135
+ "Common/**/*.{h,cpp}": "yarn format:common"
132
136
  },
133
137
  "release-it": {
134
138
  "hooks": {