react-native-reanimated 2.3.0-beta.4 → 2.4.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.
- package/Common/cpp/Tools/RuntimeDecorator.cpp +17 -0
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/android/build.gradle +5 -3
- package/android/expo/linking.gradle +46 -0
- package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +12 -0
- package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +26 -0
- package/android/react-native-reanimated-63-hermes.aar +0 -0
- package/android/react-native-reanimated-63-jsc.aar +0 -0
- package/android/react-native-reanimated-64-hermes.aar +0 -0
- package/android/react-native-reanimated-64-jsc.aar +0 -0
- package/android/react-native-reanimated-65-hermes.aar +0 -0
- package/android/react-native-reanimated-65-jsc.aar +0 -0
- package/android/react-native-reanimated-66-hermes.aar +0 -0
- package/android/react-native-reanimated-66-jsc.aar +0 -0
- package/android/react-native-reanimated-67-hermes.aar +0 -0
- package/android/react-native-reanimated-67-jsc.aar +0 -0
- package/expo-module.config.json +3 -0
- package/ios/LayoutReanimation/REAAnimationsManager.h +1 -1
- package/ios/LayoutReanimation/REAAnimationsManager.m +68 -19
- package/ios/LayoutReanimation/REAUIManager.mm +8 -7
- package/ios/Nodes/REAPropsNode.m +1 -1
- package/ios/native/NativeMethods.h +1 -1
- package/ios/native/NativeProxy.mm +10 -2
- package/ios/native/REAInitializer.mm +3 -4
- package/lib/Animated.js +3 -5
- package/lib/createAnimatedComponent.js +4 -2
- package/lib/index.js +3 -5
- package/lib/reanimated1/core/Core.test.js +1 -1
- package/lib/reanimated2/Colors.js +1 -97
- package/lib/reanimated2/Easing.js +5 -0
- package/lib/reanimated2/NativeMethods.js +15 -5
- package/lib/reanimated2/NativeReanimated/index.js +2 -2
- package/lib/reanimated2/component/FlatList.js +30 -0
- package/lib/reanimated2/component/WrappedComponents.js +9 -0
- package/lib/reanimated2/component/index.js +4 -0
- package/lib/reanimated2/core.js +9 -3
- package/lib/reanimated2/globals.d.ts +3 -0
- package/lib/reanimated2/hook/useAnimatedGestureHandler.js +1 -2
- package/lib/reanimated2/hook/useAnimatedStyle.js +31 -14
- package/lib/reanimated2/hook/utils.js +14 -11
- package/lib/reanimated2/index.js +2 -0
- package/lib/reanimated2/interpolateColor.js +98 -0
- package/lib/reanimated2/js-reanimated/JSReanimated.js +1 -1
- package/lib/reanimated2/js-reanimated/commonTypes.js +1 -0
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +14 -14
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +8 -8
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +16 -16
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +15 -15
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +4 -4
- package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +20 -8
- package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +2 -2
- package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +8 -8
- package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +10 -10
- package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +8 -8
- package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -8
- package/mock.js +2 -0
- package/package.json +8 -5
- package/plugin.js +3 -1
- package/react-native-reanimated.d.ts +101 -27
- package/src/Animated.js +3 -5
- package/src/createAnimatedComponent.tsx +13 -5
- package/src/reanimated1/core/Core.test.js +1 -1
- package/src/reanimated2/Colors.ts +6 -150
- package/src/reanimated2/Easing.ts +11 -0
- package/src/reanimated2/NativeMethods.ts +19 -6
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +1 -0
- package/src/reanimated2/NativeReanimated/index.ts +2 -2
- package/src/reanimated2/animation/commonTypes.ts +44 -40
- package/src/reanimated2/animation/decay.ts +1 -1
- package/src/reanimated2/animation/delay.ts +2 -16
- package/src/reanimated2/animation/index.ts +7 -8
- package/src/reanimated2/animation/repeat.ts +2 -12
- package/src/reanimated2/animation/sequence.ts +3 -10
- package/src/reanimated2/animation/spring.ts +1 -1
- package/src/reanimated2/animation/styleAnimation.ts +1 -18
- package/src/reanimated2/animation/timing.ts +1 -1
- package/src/reanimated2/animation/util.ts +12 -9
- package/src/reanimated2/commonTypes.ts +48 -1
- package/src/reanimated2/component/FlatList.tsx +44 -0
- package/src/reanimated2/component/WrappedComponents.ts +11 -0
- package/src/reanimated2/component/index.ts +9 -0
- package/src/reanimated2/core.ts +10 -6
- package/src/reanimated2/globals.d.ts +3 -0
- package/src/reanimated2/hook/commonTypes.ts +5 -0
- package/src/reanimated2/hook/useAnimatedGestureHandler.ts +1 -2
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -5
- package/src/reanimated2/hook/useAnimatedStyle.ts +35 -16
- package/src/reanimated2/hook/utils.ts +18 -17
- package/src/reanimated2/index.ts +2 -0
- package/src/reanimated2/interpolateColor.ts +178 -0
- package/src/reanimated2/js-reanimated/JSReanimated.ts +3 -4
- package/src/reanimated2/js-reanimated/Mapper.ts +1 -1
- package/src/reanimated2/js-reanimated/MapperRegistry.ts +1 -1
- package/src/reanimated2/js-reanimated/commonTypes.ts +51 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +39 -20
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +5 -1
- package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +21 -15
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +29 -24
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +61 -34
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +48 -33
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +17 -12
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +20 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +14 -10
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +8 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +20 -14
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +14 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +24 -12
- package/src/reanimated2/utils.ts +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "RuntimeDecorator.h"
|
|
2
|
+
#include <chrono>
|
|
2
3
|
#include <memory>
|
|
3
4
|
#include <unordered_map>
|
|
4
5
|
#include "LayoutAnimationsProxy.h"
|
|
@@ -83,6 +84,22 @@ void RuntimeDecorator::decorateRuntime(
|
|
|
83
84
|
jsi::PropNameID::forAscii(rt, "_setGlobalConsole"),
|
|
84
85
|
1,
|
|
85
86
|
setGlobalConsole));
|
|
87
|
+
|
|
88
|
+
rt.global().setProperty(
|
|
89
|
+
rt,
|
|
90
|
+
"_chronoNow",
|
|
91
|
+
jsi::Function::createFromHostFunction(
|
|
92
|
+
rt,
|
|
93
|
+
jsi::PropNameID::forAscii(rt, "_chronoNow"),
|
|
94
|
+
0,
|
|
95
|
+
[](jsi::Runtime &rt,
|
|
96
|
+
const jsi::Value &thisValue,
|
|
97
|
+
const jsi::Value *args,
|
|
98
|
+
size_t count) -> jsi::Value {
|
|
99
|
+
double now = std::chrono::system_clock::now().time_since_epoch() /
|
|
100
|
+
std::chrono::milliseconds(1);
|
|
101
|
+
return jsi::Value(now);
|
|
102
|
+
}));
|
|
86
103
|
}
|
|
87
104
|
|
|
88
105
|
void RuntimeDecorator::decorateUIRuntime(
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2016
|
|
3
|
+
Copyright (c) 2016 Software Mansion <swmansion.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Check out our dedicated documentation page for info about this library, API refe
|
|
|
19
19
|
|
|
20
20
|
## Examples
|
|
21
21
|
|
|
22
|
-
The source code for the example (showcase) app is under the [`Example/`](https://github.com/software-mansion/react-native-reanimated/blob/
|
|
22
|
+
The source code for the example (showcase) app is under the [`Example/`](https://github.com/software-mansion/react-native-reanimated/blob/main/Example/) directory.
|
|
23
23
|
If you want to play with the API but don't feel like trying it on a real app, you can run the example project. Check Example/ directory README for installation instructions.
|
|
24
24
|
|
|
25
25
|
## License
|
package/android/build.gradle
CHANGED
|
@@ -96,10 +96,10 @@ while (!aar.exists()) {
|
|
|
96
96
|
println "\n\n\n"
|
|
97
97
|
println "****************************************************************************************"
|
|
98
98
|
println "\n\n\n"
|
|
99
|
-
println "WARNING reanimated - no version-specific reanimated AAR for react-native version "
|
|
100
|
-
println "Falling back to AAR for react-native version "
|
|
99
|
+
println "WARNING reanimated - no version-specific reanimated AAR for react-native version " + minor + " found."
|
|
100
|
+
println "Falling back to AAR for react-native version " + minorCopy
|
|
101
101
|
println "The react-native JSI interface is not ABI-safe yet, this may result in crashes."
|
|
102
|
-
println "Please post a pull request to implement support for react-native version "
|
|
102
|
+
println "Please post a pull request to implement support for react-native version " + minor + " to the reanimated repo."
|
|
103
103
|
println "Thanks!"
|
|
104
104
|
println "\n\n\n"
|
|
105
105
|
println "****************************************************************************************"
|
|
@@ -107,3 +107,5 @@ while (!aar.exists()) {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
artifacts.add("default", aar)
|
|
110
|
+
|
|
111
|
+
apply from: './expo/linking.gradle'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
def isExpoLinked = false
|
|
2
|
+
rootProject.getSubprojects().forEach({ project ->
|
|
3
|
+
if (project.plugins.hasPlugin("com.android.application")) {
|
|
4
|
+
if (project.configurations.implementation.getDependencies().find { dep -> dep.name == "expo" }) {
|
|
5
|
+
isExpoLinked = true
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
def safeExtGet(prop, fallback) {
|
|
11
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (isExpoLinked) {
|
|
15
|
+
apply plugin: 'com.android.library'
|
|
16
|
+
|
|
17
|
+
android {
|
|
18
|
+
// Disable aar bundling to fix the error when running `gradle assembleRelease` over `gradle :app:assembleRelease`
|
|
19
|
+
// which will throw `Direct local .aar file dependencies are not supported when building an AAR.`
|
|
20
|
+
tasks.whenTaskAdded { task ->
|
|
21
|
+
if (['bundleDebugAar', 'bundleReleaseAar'].contains(task.name)) {
|
|
22
|
+
task.enabled = false
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 30)
|
|
27
|
+
|
|
28
|
+
sourceSets {
|
|
29
|
+
main.manifest.srcFile 'src/AndroidManifest.xml'
|
|
30
|
+
main.java.srcDirs = [ 'expo/src/main/java' ]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
libraryVariants.all {
|
|
34
|
+
generateBuildConfigProvider?.get()?.enabled = false
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
dependencies {
|
|
39
|
+
implementation 'com.facebook.react:react-native:+'
|
|
40
|
+
implementation project(':expo-modules-core')
|
|
41
|
+
|
|
42
|
+
project.configurations.default.artifacts.each { artifact ->
|
|
43
|
+
api files(artifact.file)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.swmansion.reanimated;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.JavaScriptContextHolder;
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
5
|
+
|
|
6
|
+
public class EXReanimatedAdapter {
|
|
7
|
+
public static void registerJSIModules(ReactApplicationContext reactApplicationContext, JavaScriptContextHolder jsContext) {
|
|
8
|
+
NodesManager nodesManager =
|
|
9
|
+
reactApplicationContext.getNativeModule(ReanimatedModule.class).getNodesManager();
|
|
10
|
+
nodesManager.initWithContext(reactApplicationContext);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
package expo.modules.adapters.reanimated;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.JavaScriptContextHolder;
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.swmansion.reanimated.EXReanimatedAdapter;
|
|
8
|
+
|
|
9
|
+
import java.util.Collections;
|
|
10
|
+
import java.util.List;
|
|
11
|
+
|
|
12
|
+
import expo.modules.core.interfaces.Package;
|
|
13
|
+
import expo.modules.core.interfaces.ReactNativeHostHandler;
|
|
14
|
+
|
|
15
|
+
public class EXReanimatedPackage implements Package {
|
|
16
|
+
@Override
|
|
17
|
+
public List<? extends ReactNativeHostHandler> createReactNativeHostHandlers(Context context) {
|
|
18
|
+
final ReactNativeHostHandler handler = new ReactNativeHostHandler() {
|
|
19
|
+
@Override
|
|
20
|
+
public void onRegisterJSIModules(ReactApplicationContext reactApplicationContext, JavaScriptContextHolder jsContext, boolean useDeveloperSupport) {
|
|
21
|
+
EXReanimatedAdapter.registerJSIModules(reactApplicationContext, jsContext);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
return Collections.singletonList(handler);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
@interface REAAnimationsManager ()
|
|
9
9
|
|
|
10
|
+
typedef NS_ENUM(NSInteger, FrameConfigType) { EnteringFrame, ExitingFrame };
|
|
11
|
+
|
|
10
12
|
@property (atomic, nullable) void (^startAnimationForTag)(NSNumber *, NSString *, NSDictionary *, NSNumber *);
|
|
11
13
|
@property (atomic, nullable) void (^removeConfigForTag)(NSNumber *);
|
|
12
14
|
|
|
@@ -21,6 +23,8 @@
|
|
|
21
23
|
NSMutableDictionary<NSNumber *, NSNumber *> *_states;
|
|
22
24
|
NSMutableDictionary<NSNumber *, UIView *> *_viewForTag;
|
|
23
25
|
NSMutableSet<NSNumber *> *_toRemove;
|
|
26
|
+
NSMutableArray<NSString *> *_targetKeys;
|
|
27
|
+
NSMutableArray<NSString *> *_currentKeys;
|
|
24
28
|
BOOL _cleaningScheduled;
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -43,6 +47,13 @@
|
|
|
43
47
|
_viewForTag = [NSMutableDictionary new];
|
|
44
48
|
_toRemove = [NSMutableSet new];
|
|
45
49
|
_cleaningScheduled = false;
|
|
50
|
+
|
|
51
|
+
_targetKeys = [NSMutableArray new];
|
|
52
|
+
_currentKeys = [NSMutableArray new];
|
|
53
|
+
for (NSString *key in [[self class] layoutKeys]) {
|
|
54
|
+
[_targetKeys addObject:[NSString stringWithFormat:@"target%@", [key capitalizedString]]];
|
|
55
|
+
[_currentKeys addObject:[NSString stringWithFormat:@"current%@", [key capitalizedString]]];
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
58
|
return self;
|
|
48
59
|
}
|
|
@@ -56,6 +67,8 @@
|
|
|
56
67
|
_viewForTag = nil;
|
|
57
68
|
_toRemove = nil;
|
|
58
69
|
_cleaningScheduled = false;
|
|
70
|
+
_targetKeys = nil;
|
|
71
|
+
_currentKeys = nil;
|
|
59
72
|
}
|
|
60
73
|
|
|
61
74
|
- (void)setAnimationStartingBlock:
|
|
@@ -137,6 +150,10 @@
|
|
|
137
150
|
NSMutableSet<NSNumber *> *roots = [NSMutableSet new];
|
|
138
151
|
for (NSNumber *viewTag in _toRemove) {
|
|
139
152
|
UIView *view = _viewForTag[viewTag];
|
|
153
|
+
if (view == nil) {
|
|
154
|
+
view = [_reaUiManager viewForReactTag:viewTag];
|
|
155
|
+
_viewForTag[viewTag] = view;
|
|
156
|
+
}
|
|
140
157
|
[self findRoot:view roots:roots];
|
|
141
158
|
}
|
|
142
159
|
for (NSNumber *viewTag in roots) {
|
|
@@ -208,16 +225,53 @@
|
|
|
208
225
|
[componentData setProps:newProps forView:view];
|
|
209
226
|
}
|
|
210
227
|
|
|
211
|
-
- (NSDictionary *)prepareDataForAnimatingWorklet:(NSMutableDictionary *)values
|
|
228
|
+
- (NSDictionary *)prepareDataForAnimatingWorklet:(NSMutableDictionary *)values frameConfig:(FrameConfigType)frameConfig
|
|
229
|
+
{
|
|
230
|
+
UIView *windowView = UIApplication.sharedApplication.keyWindow;
|
|
231
|
+
if (frameConfig == EnteringFrame) {
|
|
232
|
+
NSDictionary *preparedData = @{
|
|
233
|
+
@"targetWidth" : values[@"width"],
|
|
234
|
+
@"targetHeight" : values[@"height"],
|
|
235
|
+
@"targetOriginX" : values[@"originX"],
|
|
236
|
+
@"targetOriginY" : values[@"originY"],
|
|
237
|
+
@"targetGlobalOriginX" : values[@"globalOriginX"],
|
|
238
|
+
@"targetGlobalOriginY" : values[@"globalOriginY"],
|
|
239
|
+
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
240
|
+
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
241
|
+
};
|
|
242
|
+
return preparedData;
|
|
243
|
+
} else {
|
|
244
|
+
NSDictionary *preparedData = @{
|
|
245
|
+
@"currentWidth" : values[@"width"],
|
|
246
|
+
@"currentHeight" : values[@"height"],
|
|
247
|
+
@"currentOriginX" : values[@"originX"],
|
|
248
|
+
@"currentOriginY" : values[@"originY"],
|
|
249
|
+
@"currentGlobalOriginX" : values[@"globalOriginX"],
|
|
250
|
+
@"currentGlobalOriginY" : values[@"globalOriginY"],
|
|
251
|
+
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
252
|
+
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
253
|
+
};
|
|
254
|
+
return preparedData;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
- (NSDictionary *)prepareDataForLayoutAnimatingWorklet:(NSMutableDictionary *)currentValues
|
|
259
|
+
targetValues:(NSMutableDictionary *)targetValues
|
|
212
260
|
{
|
|
213
261
|
UIView *windowView = UIApplication.sharedApplication.keyWindow;
|
|
214
262
|
NSDictionary *preparedData = @{
|
|
215
|
-
@"
|
|
216
|
-
@"
|
|
217
|
-
@"
|
|
218
|
-
@"
|
|
219
|
-
@"
|
|
220
|
-
@"
|
|
263
|
+
@"currentWidth" : currentValues[@"width"],
|
|
264
|
+
@"currentHeight" : currentValues[@"height"],
|
|
265
|
+
@"currentOriginX" : currentValues[@"originX"],
|
|
266
|
+
@"currentOriginY" : currentValues[@"originY"],
|
|
267
|
+
@"currentGlobalOriginX" : currentValues[@"globalOriginX"],
|
|
268
|
+
@"currentGlobalOriginY" : currentValues[@"globalOriginY"],
|
|
269
|
+
@"targetWidth" : targetValues[@"width"],
|
|
270
|
+
@"targetHeight" : targetValues[@"height"],
|
|
271
|
+
@"targetOriginX" : targetValues[@"originX"],
|
|
272
|
+
@"targetOriginY" : targetValues[@"originY"],
|
|
273
|
+
@"targetGlobalOriginX" : targetValues[@"globalOriginX"],
|
|
274
|
+
@"targetGlobalOriginY" : targetValues[@"globalOriginY"],
|
|
221
275
|
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
222
276
|
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
223
277
|
};
|
|
@@ -241,7 +295,7 @@
|
|
|
241
295
|
return;
|
|
242
296
|
}
|
|
243
297
|
_states[tag] = [NSNumber numberWithInt:Disappearing];
|
|
244
|
-
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:startValues];
|
|
298
|
+
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:startValues frameConfig:ExitingFrame];
|
|
245
299
|
_startAnimationForTag(tag, @"exiting", preparedValues, @(0));
|
|
246
300
|
}
|
|
247
301
|
|
|
@@ -257,7 +311,7 @@
|
|
|
257
311
|
ViewState state = [_states[tag] intValue];
|
|
258
312
|
if (state == Inactive) {
|
|
259
313
|
if (targetValues != nil) {
|
|
260
|
-
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues];
|
|
314
|
+
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues frameConfig:EnteringFrame];
|
|
261
315
|
_startAnimationForTag(tag, @"entering", preparedValues, @(0));
|
|
262
316
|
}
|
|
263
317
|
return;
|
|
@@ -268,7 +322,7 @@
|
|
|
268
322
|
{
|
|
269
323
|
NSNumber *tag = view.reactTag;
|
|
270
324
|
NSMutableDictionary *targetValues = after.values;
|
|
271
|
-
NSMutableDictionary *
|
|
325
|
+
NSMutableDictionary *currentValues = before.values;
|
|
272
326
|
if (_states[tag] == nil) {
|
|
273
327
|
return;
|
|
274
328
|
}
|
|
@@ -278,8 +332,9 @@
|
|
|
278
332
|
}
|
|
279
333
|
if (state == Appearing) {
|
|
280
334
|
BOOL doNotStartLayout = true;
|
|
281
|
-
for (
|
|
282
|
-
if ([((NSNumber *)
|
|
335
|
+
for (int i = 0; i < [[self class] layoutKeys].count; ++i) {
|
|
336
|
+
if ([((NSNumber *)currentValues[_currentKeys[i]]) doubleValue] !=
|
|
337
|
+
[((NSNumber *)targetValues[_targetKeys[i]]) doubleValue]) {
|
|
283
338
|
doNotStartLayout = false;
|
|
284
339
|
}
|
|
285
340
|
}
|
|
@@ -288,13 +343,7 @@
|
|
|
288
343
|
}
|
|
289
344
|
}
|
|
290
345
|
_states[view.reactTag] = [NSNumber numberWithInt:Layout];
|
|
291
|
-
NSDictionary *
|
|
292
|
-
NSDictionary *preparedTargetValues = [self prepareDataForAnimatingWorklet:targetValues];
|
|
293
|
-
NSMutableDictionary *preparedValues = [NSMutableDictionary new];
|
|
294
|
-
[preparedValues addEntriesFromDictionary:preparedTargetValues];
|
|
295
|
-
for (NSString *key in preparedStartValues.allKeys) {
|
|
296
|
-
preparedValues[[NSString stringWithFormat:@"%@%@", @"b", key]] = preparedStartValues[key];
|
|
297
|
-
}
|
|
346
|
+
NSDictionary *preparedValues = [self prepareDataForLayoutAnimatingWorklet:currentValues targetValues:targetValues];
|
|
298
347
|
_startAnimationForTag(view.reactTag, @"layout", preparedValues, @(0));
|
|
299
348
|
}
|
|
300
349
|
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#import "REAUIManager.h"
|
|
2
2
|
#import <Foundation/Foundation.h>
|
|
3
3
|
#include "FeaturesConfig.h"
|
|
4
|
-
#import "RCTComponentData.h"
|
|
5
|
-
#import "RCTLayoutAnimation.h"
|
|
6
|
-
#import "RCTLayoutAnimationGroup.h"
|
|
7
|
-
#import "RCTModalHostView.h"
|
|
8
|
-
#import "RCTRootShadowView.h"
|
|
9
|
-
#import "RCTRootViewInternal.h"
|
|
10
|
-
#import "RCTUIManagerObserverCoordinator.h"
|
|
11
4
|
#import "REAIOSScheduler.h"
|
|
12
5
|
#include "Scheduler.h"
|
|
13
6
|
|
|
7
|
+
#import <React/RCTComponentData.h>
|
|
8
|
+
#import <React/RCTLayoutAnimation.h>
|
|
9
|
+
#import <React/RCTLayoutAnimationGroup.h>
|
|
10
|
+
#import <React/RCTModalHostView.h>
|
|
11
|
+
#import <React/RCTRootShadowView.h>
|
|
12
|
+
#import <React/RCTRootViewInternal.h>
|
|
13
|
+
#import <React/RCTUIManagerObserverCoordinator.h>
|
|
14
|
+
|
|
14
15
|
#if __has_include(<RNScreens/RNSScreen.h>)
|
|
15
16
|
#import <RNScreens/RNSScreen.h>
|
|
16
17
|
#endif
|
package/ios/Nodes/REAPropsNode.m
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
#import "REANodesManager.h"
|
|
5
5
|
#import "REAStyleNode.h"
|
|
6
6
|
|
|
7
|
+
#import <React/RCTComponentData.h>
|
|
7
8
|
#import <React/RCTLog.h>
|
|
8
9
|
#import <React/RCTUIManager.h>
|
|
9
|
-
#import "React/RCTComponentData.h"
|
|
10
10
|
|
|
11
11
|
@implementation REAPropsNode {
|
|
12
12
|
NSNumber *_connectedViewTag;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <RNGestureHandlerStateManager.h>
|
|
2
3
|
#import <React/RCTUIManager.h>
|
|
3
4
|
#include <string>
|
|
4
5
|
#import <string>
|
|
5
6
|
#include <utility>
|
|
6
7
|
#include <vector>
|
|
7
8
|
#import <vector>
|
|
8
|
-
#import "RNGestureHandlerStateManager.h"
|
|
9
9
|
|
|
10
10
|
namespace reanimated {
|
|
11
11
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#import <React/RCTUIManager.h>
|
|
4
4
|
#import <folly/json.h>
|
|
5
5
|
|
|
6
|
+
#import <RNGestureHandlerStateManager.h>
|
|
6
7
|
#import "LayoutAnimationsProxy.h"
|
|
7
8
|
#import "NativeMethods.h"
|
|
8
9
|
#import "NativeProxy.h"
|
|
@@ -12,7 +13,6 @@
|
|
|
12
13
|
#import "REAModule.h"
|
|
13
14
|
#import "REANodesManager.h"
|
|
14
15
|
#import "REAUIManager.h"
|
|
15
|
-
#import "RNGestureHandlerStateManager.h"
|
|
16
16
|
|
|
17
17
|
#if __has_include(<reacthermes/HermesExecutorFactory.h>)
|
|
18
18
|
#import <reacthermes/HermesExecutorFactory.h>
|
|
@@ -246,7 +246,15 @@ std::shared_ptr<NativeReanimatedModule> createReanimatedModule(
|
|
|
246
246
|
|
|
247
247
|
[reanimatedModule.nodesManager registerEventHandler:^(NSString *eventName, id<RCTEvent> event) {
|
|
248
248
|
std::string eventNameString([eventName UTF8String]);
|
|
249
|
-
|
|
249
|
+
|
|
250
|
+
std::string eventAsString;
|
|
251
|
+
try {
|
|
252
|
+
eventAsString = folly::toJson(convertIdToFollyDynamic([event arguments][2]));
|
|
253
|
+
} catch (folly::json::parse_error &) {
|
|
254
|
+
// Events from other libraries may contain NaN or INF values which cannot be represented in JSON.
|
|
255
|
+
// See https://github.com/software-mansion/react-native-reanimated/issues/1776 for details.
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
250
258
|
|
|
251
259
|
eventAsString = "{ NativeMap:" + eventAsString + "}";
|
|
252
260
|
jsi::Object global = module->runtime->global();
|
|
@@ -46,10 +46,9 @@ JSIExecutor::RuntimeInstaller REAJSIExecutorRuntimeInstaller(
|
|
|
46
46
|
auto reanimatedModule = reanimated::createReanimatedModule(bridge, callInvoker);
|
|
47
47
|
#endif
|
|
48
48
|
runtime.global().setProperty(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
reinterpret_cast<std::uintptr_t>(reanimatedModule->runtime.get())));
|
|
49
|
+
runtime,
|
|
50
|
+
"_WORKLET_RUNTIME",
|
|
51
|
+
static_cast<double>(reinterpret_cast<std::uintptr_t>(reanimatedModule->runtime.get())));
|
|
53
52
|
|
|
54
53
|
runtime.global().setProperty(
|
|
55
54
|
runtime,
|
package/lib/Animated.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LogBox } from 'react-native';
|
|
2
2
|
import createAnimatedComponent from './createAnimatedComponent';
|
|
3
3
|
import {
|
|
4
4
|
addWhitelistedNativeProps,
|
|
5
5
|
addWhitelistedUIProps,
|
|
6
6
|
} from './ConfigHelper';
|
|
7
7
|
import * as reanimated1 from './reanimated1';
|
|
8
|
+
import ReanimatedComponents from './reanimated2/component';
|
|
8
9
|
|
|
9
10
|
const Animated = {
|
|
10
11
|
// components
|
|
11
|
-
|
|
12
|
-
Text: createAnimatedComponent(Text),
|
|
13
|
-
Image: createAnimatedComponent(Image),
|
|
14
|
-
ScrollView: createAnimatedComponent(ScrollView),
|
|
12
|
+
...ReanimatedComponents,
|
|
15
13
|
createAnimatedComponent,
|
|
16
14
|
// configuration
|
|
17
15
|
addWhitelistedNativeProps,
|
|
@@ -64,8 +64,9 @@ function onlyAnimatedStyles(styles) {
|
|
|
64
64
|
function isSameAnimatedStyle(style1, style2) {
|
|
65
65
|
// We cannot use equality check to compare useAnimatedStyle outputs directly.
|
|
66
66
|
// Instead, we can compare its viewsRefs.
|
|
67
|
-
return style1.viewsRef === style2.viewsRef;
|
|
67
|
+
return (style1 === null || style1 === void 0 ? void 0 : style1.viewsRef) === (style2 === null || style2 === void 0 ? void 0 : style2.viewsRef);
|
|
68
68
|
}
|
|
69
|
+
const isSameAnimatedProps = isSameAnimatedStyle;
|
|
69
70
|
const has = (key, x) => {
|
|
70
71
|
if (typeof x === 'function' || typeof x === 'object') {
|
|
71
72
|
if (x === null || x === undefined) {
|
|
@@ -381,7 +382,8 @@ export default function createAnimatedComponent(Component, options) {
|
|
|
381
382
|
}
|
|
382
383
|
});
|
|
383
384
|
// detach old animatedProps
|
|
384
|
-
if (prevAnimatedProps &&
|
|
385
|
+
if (prevAnimatedProps &&
|
|
386
|
+
!isSameAnimatedProps(prevAnimatedProps, this.props.animatedProps)) {
|
|
385
387
|
prevAnimatedProps.viewDescriptors.remove(viewTag);
|
|
386
388
|
}
|
|
387
389
|
// attach animatedProps property
|
package/lib/index.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LogBox } from 'react-native';
|
|
2
2
|
import createAnimatedComponent from './createAnimatedComponent';
|
|
3
3
|
import {
|
|
4
4
|
addWhitelistedNativeProps,
|
|
5
5
|
addWhitelistedUIProps,
|
|
6
6
|
} from './ConfigHelper';
|
|
7
7
|
import * as reanimated1 from './reanimated1';
|
|
8
|
+
import ReanimatedComponents from './reanimated2/component';
|
|
8
9
|
|
|
9
10
|
const Animated = {
|
|
10
11
|
// components
|
|
11
|
-
|
|
12
|
-
Text: createAnimatedComponent(Text),
|
|
13
|
-
Image: createAnimatedComponent(Image),
|
|
14
|
-
ScrollView: createAnimatedComponent(ScrollView),
|
|
12
|
+
...ReanimatedComponents,
|
|
15
13
|
createAnimatedComponent,
|
|
16
14
|
// configuration
|
|
17
15
|
addWhitelistedNativeProps,
|
|
@@ -5,7 +5,7 @@ import renderer from 'react-test-renderer';
|
|
|
5
5
|
|
|
6
6
|
jest.mock('../../ReanimatedEventEmitter');
|
|
7
7
|
jest.mock('../../ReanimatedModule');
|
|
8
|
-
jest.mock('../../reanimated2/NativeReanimated');
|
|
8
|
+
jest.mock('../../reanimated2/NativeReanimated/NativeReanimated');
|
|
9
9
|
|
|
10
10
|
describe('Core Animated components', () => {
|
|
11
11
|
xit('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {
|
|
@@ -8,9 +8,6 @@
|
|
|
8
8
|
/* eslint no-bitwise: 0 */
|
|
9
9
|
import { Platform } from 'react-native';
|
|
10
10
|
import { makeRemote, makeShareable, isConfigured } from './core';
|
|
11
|
-
import { interpolate } from './interpolation';
|
|
12
|
-
// @ts-ignore JS file
|
|
13
|
-
import { Extrapolate } from '../reanimated1/derived';
|
|
14
11
|
// var INTEGER = '[-+]?\\d+';
|
|
15
12
|
const NUMBER = '[-+]?\\d*\\.?\\d+';
|
|
16
13
|
const PERCENTAGE = NUMBER + '%';
|
|
@@ -381,7 +378,7 @@ export const rgbaColor = (r, g, b, alpha = 1) => {
|
|
|
381
378
|
}
|
|
382
379
|
return c;
|
|
383
380
|
};
|
|
384
|
-
function RGBtoHSV(r, g, b) {
|
|
381
|
+
export function RGBtoHSV(r, g, b) {
|
|
385
382
|
'worklet';
|
|
386
383
|
/* eslint-disable */
|
|
387
384
|
if (arguments.length === 1) {
|
|
@@ -522,96 +519,3 @@ export function toRGBA(HSVA) {
|
|
|
522
519
|
const { r, g, b } = HSVtoRGB(HSVA[0], HSVA[1], HSVA[2]);
|
|
523
520
|
return `rgba(${r}, ${g}, ${b}, ${HSVA[3]})`;
|
|
524
521
|
}
|
|
525
|
-
const interpolateColorsHSV = (value, inputRange, colors) => {
|
|
526
|
-
'worklet';
|
|
527
|
-
const h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);
|
|
528
|
-
const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);
|
|
529
|
-
const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);
|
|
530
|
-
return hsvToColor(h, s, v);
|
|
531
|
-
};
|
|
532
|
-
const interpolateColorsRGB = (value, inputRange, colors) => {
|
|
533
|
-
'worklet';
|
|
534
|
-
const r = interpolate(value, inputRange, colors.r, Extrapolate.CLAMP);
|
|
535
|
-
const g = interpolate(value, inputRange, colors.g, Extrapolate.CLAMP);
|
|
536
|
-
const b = interpolate(value, inputRange, colors.b, Extrapolate.CLAMP);
|
|
537
|
-
const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);
|
|
538
|
-
return rgbaColor(r, g, b, a);
|
|
539
|
-
};
|
|
540
|
-
const BUFFER_SIZE = 200;
|
|
541
|
-
const hashOrderRGBA = new ArrayBuffer(BUFFER_SIZE);
|
|
542
|
-
let curentHashIndexRGBA = 0;
|
|
543
|
-
const interpolateCacheRGBA = {};
|
|
544
|
-
const getInterpolateCacheRGBA = (colors) => {
|
|
545
|
-
'worklet';
|
|
546
|
-
const hash = colors.join('');
|
|
547
|
-
const cache = interpolateCacheRGBA[hash];
|
|
548
|
-
if (cache !== undefined) {
|
|
549
|
-
return cache;
|
|
550
|
-
}
|
|
551
|
-
const r = [];
|
|
552
|
-
const g = [];
|
|
553
|
-
const b = [];
|
|
554
|
-
const a = [];
|
|
555
|
-
for (let i = 0; i < colors.length; ++i) {
|
|
556
|
-
const color = colors[i];
|
|
557
|
-
const proocessedColor = processColor(color);
|
|
558
|
-
// explicit check in case if processedColor is 0
|
|
559
|
-
if (proocessedColor !== null && proocessedColor !== undefined) {
|
|
560
|
-
r.push(red(proocessedColor));
|
|
561
|
-
g.push(green(proocessedColor));
|
|
562
|
-
b.push(blue(proocessedColor));
|
|
563
|
-
a.push(opacity(proocessedColor));
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
const newCache = { r, g, b, a };
|
|
567
|
-
const overrideHash = hashOrderRGBA[curentHashIndexRGBA];
|
|
568
|
-
if (overrideHash) {
|
|
569
|
-
delete interpolateCacheRGBA[overrideHash];
|
|
570
|
-
}
|
|
571
|
-
interpolateCacheRGBA[hash] = newCache;
|
|
572
|
-
hashOrderRGBA[curentHashIndexRGBA] = hash;
|
|
573
|
-
curentHashIndexRGBA = (curentHashIndexRGBA + 1) % BUFFER_SIZE;
|
|
574
|
-
return newCache;
|
|
575
|
-
};
|
|
576
|
-
const hashOrderHSV = new ArrayBuffer(BUFFER_SIZE);
|
|
577
|
-
let curentHashIndexHSV = 0;
|
|
578
|
-
const interpolateCacheHSV = {};
|
|
579
|
-
const getInterpolateCacheHSV = (colors) => {
|
|
580
|
-
'worklet';
|
|
581
|
-
const hash = colors.join('');
|
|
582
|
-
const cache = interpolateCacheHSV[hash];
|
|
583
|
-
if (cache !== undefined) {
|
|
584
|
-
return cache;
|
|
585
|
-
}
|
|
586
|
-
const h = [];
|
|
587
|
-
const s = [];
|
|
588
|
-
const v = [];
|
|
589
|
-
for (let i = 0; i < colors.length; ++i) {
|
|
590
|
-
const color = colors[i];
|
|
591
|
-
const proocessedColor = RGBtoHSV(processColor(color));
|
|
592
|
-
if (proocessedColor) {
|
|
593
|
-
h.push(proocessedColor.h);
|
|
594
|
-
s.push(proocessedColor.s);
|
|
595
|
-
v.push(proocessedColor.v);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
const newCache = { h, s, v };
|
|
599
|
-
const overrideHash = hashOrderHSV[curentHashIndexHSV];
|
|
600
|
-
if (overrideHash) {
|
|
601
|
-
delete interpolateCacheHSV[overrideHash];
|
|
602
|
-
}
|
|
603
|
-
interpolateCacheHSV[hash] = newCache;
|
|
604
|
-
hashOrderHSV[curentHashIndexHSV] = hash;
|
|
605
|
-
curentHashIndexHSV = (curentHashIndexHSV + 1) % BUFFER_SIZE;
|
|
606
|
-
return newCache;
|
|
607
|
-
};
|
|
608
|
-
export const interpolateColor = (value, inputRange, outputRange, colorSpace = 'RGB') => {
|
|
609
|
-
'worklet';
|
|
610
|
-
if (colorSpace === 'HSV') {
|
|
611
|
-
return interpolateColorsHSV(value, inputRange, getInterpolateCacheHSV(outputRange));
|
|
612
|
-
}
|
|
613
|
-
else if (colorSpace === 'RGB') {
|
|
614
|
-
return interpolateColorsRGB(value, inputRange, getInterpolateCacheRGBA(outputRange));
|
|
615
|
-
}
|
|
616
|
-
throw new Error(`invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`);
|
|
617
|
-
};
|