react-native-reanimated 2.3.0-beta.4 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/cpp/Tools/RuntimeDecorator.cpp +17 -0
- package/android/build.gradle +2 -0
- package/android/expo/linking.gradle +34 -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.m +64 -19
- 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/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 +3 -0
- package/lib/reanimated2/globals.d.ts +3 -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/package.json +3 -2
- package/plugin.js +2 -1
- package/react-native-reanimated.d.ts +37 -21
- package/src/Animated.js +3 -5
- package/src/createAnimatedComponent.tsx +13 -5
- package/src/reanimated1/core/Core.test.js +1 -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 +3 -0
- package/src/reanimated2/globals.d.ts +3 -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 +8 -8
- 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
|
@@ -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/android/build.gradle
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 30)
|
|
19
|
+
|
|
20
|
+
sourceSets {
|
|
21
|
+
main.manifest.srcFile 'src/AndroidManifest.xml'
|
|
22
|
+
main.java.srcDirs = [ 'expo/src/main/java' ]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
dependencies {
|
|
27
|
+
implementation 'com.facebook.react:react-native:+'
|
|
28
|
+
implementation project(':expo-modules-core')
|
|
29
|
+
|
|
30
|
+
project.configurations.default.artifacts.each { artifact ->
|
|
31
|
+
api files(artifact.file)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -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:
|
|
@@ -208,16 +221,53 @@
|
|
|
208
221
|
[componentData setProps:newProps forView:view];
|
|
209
222
|
}
|
|
210
223
|
|
|
211
|
-
- (NSDictionary *)prepareDataForAnimatingWorklet:(NSMutableDictionary *)values
|
|
224
|
+
- (NSDictionary *)prepareDataForAnimatingWorklet:(NSMutableDictionary *)values frameConfig:(FrameConfigType)frameConfig
|
|
225
|
+
{
|
|
226
|
+
UIView *windowView = UIApplication.sharedApplication.keyWindow;
|
|
227
|
+
if (frameConfig == EnteringFrame) {
|
|
228
|
+
NSDictionary *preparedData = @{
|
|
229
|
+
@"targetWidth" : values[@"width"],
|
|
230
|
+
@"targetHeight" : values[@"height"],
|
|
231
|
+
@"targetOriginX" : values[@"originX"],
|
|
232
|
+
@"targetOriginY" : values[@"originY"],
|
|
233
|
+
@"targetGlobalOriginX" : values[@"globalOriginX"],
|
|
234
|
+
@"targetGlobalOriginY" : values[@"globalOriginY"],
|
|
235
|
+
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
236
|
+
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
237
|
+
};
|
|
238
|
+
return preparedData;
|
|
239
|
+
} else {
|
|
240
|
+
NSDictionary *preparedData = @{
|
|
241
|
+
@"currentWidth" : values[@"width"],
|
|
242
|
+
@"currentHeight" : values[@"height"],
|
|
243
|
+
@"currentOriginX" : values[@"originX"],
|
|
244
|
+
@"currentOriginY" : values[@"originY"],
|
|
245
|
+
@"currentGlobalOriginX" : values[@"globalOriginX"],
|
|
246
|
+
@"currentGlobalOriginY" : values[@"globalOriginY"],
|
|
247
|
+
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
248
|
+
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
249
|
+
};
|
|
250
|
+
return preparedData;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
- (NSDictionary *)prepareDataForLayoutAnimatingWorklet:(NSMutableDictionary *)currentValues
|
|
255
|
+
targetValues:(NSMutableDictionary *)targetValues
|
|
212
256
|
{
|
|
213
257
|
UIView *windowView = UIApplication.sharedApplication.keyWindow;
|
|
214
258
|
NSDictionary *preparedData = @{
|
|
215
|
-
@"
|
|
216
|
-
@"
|
|
217
|
-
@"
|
|
218
|
-
@"
|
|
219
|
-
@"
|
|
220
|
-
@"
|
|
259
|
+
@"currentWidth" : currentValues[@"width"],
|
|
260
|
+
@"currentHeight" : currentValues[@"height"],
|
|
261
|
+
@"currentOriginX" : currentValues[@"originX"],
|
|
262
|
+
@"currentOriginY" : currentValues[@"originY"],
|
|
263
|
+
@"currentGlobalOriginX" : currentValues[@"globalOriginX"],
|
|
264
|
+
@"currentGlobalOriginY" : currentValues[@"globalOriginY"],
|
|
265
|
+
@"targetWidth" : targetValues[@"width"],
|
|
266
|
+
@"targetHeight" : targetValues[@"height"],
|
|
267
|
+
@"targetOriginX" : targetValues[@"originX"],
|
|
268
|
+
@"targetOriginY" : targetValues[@"originY"],
|
|
269
|
+
@"targetGlobalOriginX" : targetValues[@"globalOriginX"],
|
|
270
|
+
@"targetGlobalOriginY" : targetValues[@"globalOriginY"],
|
|
221
271
|
@"windowWidth" : [NSNumber numberWithDouble:windowView.bounds.size.width],
|
|
222
272
|
@"windowHeight" : [NSNumber numberWithDouble:windowView.bounds.size.height]
|
|
223
273
|
};
|
|
@@ -241,7 +291,7 @@
|
|
|
241
291
|
return;
|
|
242
292
|
}
|
|
243
293
|
_states[tag] = [NSNumber numberWithInt:Disappearing];
|
|
244
|
-
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:startValues];
|
|
294
|
+
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:startValues frameConfig:ExitingFrame];
|
|
245
295
|
_startAnimationForTag(tag, @"exiting", preparedValues, @(0));
|
|
246
296
|
}
|
|
247
297
|
|
|
@@ -257,7 +307,7 @@
|
|
|
257
307
|
ViewState state = [_states[tag] intValue];
|
|
258
308
|
if (state == Inactive) {
|
|
259
309
|
if (targetValues != nil) {
|
|
260
|
-
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues];
|
|
310
|
+
NSDictionary *preparedValues = [self prepareDataForAnimatingWorklet:targetValues frameConfig:EnteringFrame];
|
|
261
311
|
_startAnimationForTag(tag, @"entering", preparedValues, @(0));
|
|
262
312
|
}
|
|
263
313
|
return;
|
|
@@ -268,7 +318,7 @@
|
|
|
268
318
|
{
|
|
269
319
|
NSNumber *tag = view.reactTag;
|
|
270
320
|
NSMutableDictionary *targetValues = after.values;
|
|
271
|
-
NSMutableDictionary *
|
|
321
|
+
NSMutableDictionary *currentValues = before.values;
|
|
272
322
|
if (_states[tag] == nil) {
|
|
273
323
|
return;
|
|
274
324
|
}
|
|
@@ -278,8 +328,9 @@
|
|
|
278
328
|
}
|
|
279
329
|
if (state == Appearing) {
|
|
280
330
|
BOOL doNotStartLayout = true;
|
|
281
|
-
for (
|
|
282
|
-
if ([((NSNumber *)
|
|
331
|
+
for (int i = 0; i < [[self class] layoutKeys].count; ++i) {
|
|
332
|
+
if ([((NSNumber *)currentValues[_currentKeys[i]]) doubleValue] !=
|
|
333
|
+
[((NSNumber *)targetValues[_targetKeys[i]]) doubleValue]) {
|
|
283
334
|
doNotStartLayout = false;
|
|
284
335
|
}
|
|
285
336
|
}
|
|
@@ -288,13 +339,7 @@
|
|
|
288
339
|
}
|
|
289
340
|
}
|
|
290
341
|
_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
|
-
}
|
|
342
|
+
NSDictionary *preparedValues = [self prepareDataForLayoutAnimatingWorklet:currentValues targetValues:targetValues];
|
|
298
343
|
_startAnimationForTag(view.reactTag, @"layout", preparedValues, @(0));
|
|
299
344
|
}
|
|
300
345
|
|
|
@@ -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', () => {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { FlatList } from 'react-native';
|
|
14
|
+
import WrappedComponents from './WrappedComponents';
|
|
15
|
+
import createAnimatedComponent from '../../createAnimatedComponent';
|
|
16
|
+
const AnimatedFlatList = createAnimatedComponent(FlatList);
|
|
17
|
+
const createCellRenderer = (itemLayoutAnimation) => {
|
|
18
|
+
const cellRenderer = (props) => {
|
|
19
|
+
return (<WrappedComponents.View layout={itemLayoutAnimation} onLayout={props.onLayout}>
|
|
20
|
+
{props.children}
|
|
21
|
+
</WrappedComponents.View>);
|
|
22
|
+
};
|
|
23
|
+
return cellRenderer;
|
|
24
|
+
};
|
|
25
|
+
const ReanimatedFlatlist = (_a) => {
|
|
26
|
+
var { itemLayoutAnimation } = _a, restProps = __rest(_a, ["itemLayoutAnimation"]);
|
|
27
|
+
const cellRenderer = React.useMemo(() => createCellRenderer(itemLayoutAnimation), []);
|
|
28
|
+
return (<AnimatedFlatList {...restProps} CellRendererComponent={cellRenderer}/>);
|
|
29
|
+
};
|
|
30
|
+
export default ReanimatedFlatlist;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Image, ScrollView, Text, View } from 'react-native';
|
|
2
|
+
import createAnimatedComponent from '../../createAnimatedComponent';
|
|
3
|
+
const WrappedComponents = {
|
|
4
|
+
View: createAnimatedComponent(View),
|
|
5
|
+
Text: createAnimatedComponent(Text),
|
|
6
|
+
Image: createAnimatedComponent(Image),
|
|
7
|
+
ScrollView: createAnimatedComponent(ScrollView),
|
|
8
|
+
};
|
|
9
|
+
export default WrappedComponents;
|
package/lib/reanimated2/core.js
CHANGED
|
@@ -26,6 +26,7 @@ declare global {
|
|
|
26
26
|
y: number,
|
|
27
27
|
animated: boolean
|
|
28
28
|
) => void;
|
|
29
|
+
const _chronoNow: () => number;
|
|
29
30
|
namespace NodeJS {
|
|
30
31
|
interface Global {
|
|
31
32
|
__reanimatedWorkletInit: (worklet: WorkletFunction) => void;
|
|
@@ -37,6 +38,8 @@ declare global {
|
|
|
37
38
|
_frameTimestamp: number | null;
|
|
38
39
|
_measure: () => MeasuredDimensions;
|
|
39
40
|
_scrollTo: () => void;
|
|
41
|
+
_chronoNow: () => number;
|
|
42
|
+
performance: { now: () => number };
|
|
40
43
|
LayoutAnimationRepository: {
|
|
41
44
|
configs: Record<string, unknown>;
|
|
42
45
|
registerConfig(tag: number, config: Record<string, unknown>): void;
|
|
@@ -2,34 +2,34 @@ export const DefaultLayout = (values) => {
|
|
|
2
2
|
'worklet';
|
|
3
3
|
return {
|
|
4
4
|
initialValues: {
|
|
5
|
-
originX: values.
|
|
6
|
-
originY: values.
|
|
7
|
-
width: values.
|
|
8
|
-
height: values.
|
|
5
|
+
originX: values.targetOriginX,
|
|
6
|
+
originY: values.targetOriginY,
|
|
7
|
+
width: values.targetWidth,
|
|
8
|
+
height: values.targetHeight,
|
|
9
9
|
},
|
|
10
10
|
animations: {},
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export const DefaultEntering = (
|
|
13
|
+
export const DefaultEntering = (values) => {
|
|
14
14
|
'worklet';
|
|
15
15
|
return {
|
|
16
16
|
initialValues: {
|
|
17
|
-
originX:
|
|
18
|
-
originY:
|
|
19
|
-
width:
|
|
20
|
-
height:
|
|
17
|
+
originX: values.targetOriginX,
|
|
18
|
+
originY: values.targetOriginY,
|
|
19
|
+
width: values.targetWidth,
|
|
20
|
+
height: values.targetHeight,
|
|
21
21
|
},
|
|
22
22
|
animations: {},
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
export const DefaultExiting = (
|
|
25
|
+
export const DefaultExiting = (values) => {
|
|
26
26
|
'worklet';
|
|
27
27
|
return {
|
|
28
28
|
initialValues: {
|
|
29
|
-
originX:
|
|
30
|
-
originY:
|
|
31
|
-
width:
|
|
32
|
-
height:
|
|
29
|
+
originX: values.currentOriginX,
|
|
30
|
+
originY: values.currentOriginY,
|
|
31
|
+
width: values.currentWidth,
|
|
32
|
+
height: values.currentHeight,
|
|
33
33
|
},
|
|
34
34
|
animations: {},
|
|
35
35
|
};
|
|
@@ -14,7 +14,7 @@ export class FlipInXUp extends ComplexAnimationBuilder {
|
|
|
14
14
|
transform: [
|
|
15
15
|
{ perspective: 500 },
|
|
16
16
|
{ rotateX: '90deg' },
|
|
17
|
-
{ translateY: -targetValues.
|
|
17
|
+
{ translateY: -targetValues.targetHeight },
|
|
18
18
|
],
|
|
19
19
|
},
|
|
20
20
|
animations: {
|
|
@@ -48,7 +48,7 @@ export class FlipInYLeft extends ComplexAnimationBuilder {
|
|
|
48
48
|
transform: [
|
|
49
49
|
{ perspective: 500 },
|
|
50
50
|
{ rotateY: '-90deg' },
|
|
51
|
-
{ translateX: -targetValues.
|
|
51
|
+
{ translateX: -targetValues.targetWidth },
|
|
52
52
|
],
|
|
53
53
|
},
|
|
54
54
|
animations: {
|
|
@@ -82,7 +82,7 @@ export class FlipInXDown extends ComplexAnimationBuilder {
|
|
|
82
82
|
transform: [
|
|
83
83
|
{ perspective: 500 },
|
|
84
84
|
{ rotateX: '-90deg' },
|
|
85
|
-
{ translateY: targetValues.
|
|
85
|
+
{ translateY: targetValues.targetHeight },
|
|
86
86
|
],
|
|
87
87
|
},
|
|
88
88
|
animations: {
|
|
@@ -116,7 +116,7 @@ export class FlipInYRight extends ComplexAnimationBuilder {
|
|
|
116
116
|
transform: [
|
|
117
117
|
{ perspective: 500 },
|
|
118
118
|
{ rotateY: '90deg' },
|
|
119
|
-
{ translateX: targetValues.
|
|
119
|
+
{ translateX: targetValues.targetWidth },
|
|
120
120
|
],
|
|
121
121
|
},
|
|
122
122
|
animations: {
|
|
@@ -216,7 +216,7 @@ export class FlipOutXUp extends ComplexAnimationBuilder {
|
|
|
216
216
|
{ perspective: delayFunction(delay, animation(500, config)) },
|
|
217
217
|
{ rotateX: delayFunction(delay, animation('90deg', config)) },
|
|
218
218
|
{
|
|
219
|
-
translateY: delayFunction(delay, animation(-targetValues.
|
|
219
|
+
translateY: delayFunction(delay, animation(-targetValues.currentHeight, config)),
|
|
220
220
|
},
|
|
221
221
|
],
|
|
222
222
|
},
|
|
@@ -252,7 +252,7 @@ export class FlipOutYLeft extends ComplexAnimationBuilder {
|
|
|
252
252
|
{ perspective: delayFunction(delay, animation(500, config)) },
|
|
253
253
|
{ rotateY: delayFunction(delay, animation('-90deg', config)) },
|
|
254
254
|
{
|
|
255
|
-
translateX: delayFunction(delay, animation(-targetValues.
|
|
255
|
+
translateX: delayFunction(delay, animation(-targetValues.currentWidth, config)),
|
|
256
256
|
},
|
|
257
257
|
],
|
|
258
258
|
},
|
|
@@ -288,7 +288,7 @@ export class FlipOutXDown extends ComplexAnimationBuilder {
|
|
|
288
288
|
{ perspective: delayFunction(delay, animation(500, config)) },
|
|
289
289
|
{ rotateX: delayFunction(delay, animation('-90deg', config)) },
|
|
290
290
|
{
|
|
291
|
-
translateY: delayFunction(delay, animation(targetValues.
|
|
291
|
+
translateY: delayFunction(delay, animation(targetValues.currentHeight, config)),
|
|
292
292
|
},
|
|
293
293
|
],
|
|
294
294
|
},
|
|
@@ -324,7 +324,7 @@ export class FlipOutYRight extends ComplexAnimationBuilder {
|
|
|
324
324
|
{ perspective: delayFunction(delay, animation(500, config)) },
|
|
325
325
|
{ rotateY: delayFunction(delay, animation('90deg', config)) },
|
|
326
326
|
{
|
|
327
|
-
translateX: delayFunction(delay, animation(targetValues.
|
|
327
|
+
translateX: delayFunction(delay, animation(targetValues.currentWidth, config)),
|
|
328
328
|
},
|
|
329
329
|
],
|
|
330
330
|
},
|