react-native-reanimated 2.3.3 → 2.5.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/AnimatedSensor/AnimatedSensorModule.cpp +72 -0
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +30 -1
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +64 -39
- package/Common/cpp/Tools/RuntimeDecorator.cpp +2 -0
- package/Common/cpp/headers/AnimatedSensor/AnimatedSensorModule.h +41 -0
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +14 -0
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +14 -0
- package/Common/cpp/headers/SharedItems/MutableValue.h +4 -1
- package/Common/cpp/headers/SharedItems/ShareableValue.h +3 -0
- package/Common/cpp/headers/SharedItems/ValueWrapper.h +3 -0
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +11 -0
- package/Common/cpp/headers/Tools/RuntimeDecorator.h +2 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/7.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/7.2/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/checksums/checksums.lock +0 -0
- package/android/.gradle/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/CMakeLists.txt +198 -0
- package/android/README.md +15 -0
- package/android/build.gradle +686 -73
- package/android/empty.cpp +1 -0
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/android/gradle.properties +25 -0
- package/android/gradlew +234 -0
- package/android/gradlew.bat +89 -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/android/react-native-reanimated-68-hermes.aar +0 -0
- package/android/react-native-reanimated-68-jsc.aar +0 -0
- package/android/rnVersionPatch/62/layoutReanimation/ReanimatedNativeHierarchyManager.java +412 -0
- package/android/rnVersionPatch/62/layoutReanimation/ReanimatedUIImplementation.java +68 -0
- package/android/rnVersionPatch/63/layoutReanimation/ReanimatedUIImplementation.java +68 -0
- package/android/rnVersionPatch/64/layoutReanimation/ReanimatedUIImplementation.java +68 -0
- package/android/rnVersionPatch/65/.gitkeep +0 -0
- package/android/rnVersionPatch/66/.gitkeep +0 -0
- package/android/rnVersionPatch/67/.gitkeep +0 -0
- package/android/rnVersionPatch/68/.gitkeep +0 -0
- package/android/rnVersionPatch/backup/.gitkeep +0 -0
- package/android/settings.gradle +1 -0
- package/android/spotless.gradle +9 -0
- package/android/src/{AndroidManifest.xml → main/AndroidManifest.xml} +0 -0
- package/android/src/main/cpp/AndroidErrorHandler.cpp +42 -0
- package/android/src/main/cpp/AndroidLogger.cpp +27 -0
- package/android/src/main/cpp/AndroidScheduler.cpp +59 -0
- package/android/src/main/cpp/JNIHelper.cpp +59 -0
- package/android/src/main/cpp/LayoutAnimations.cpp +103 -0
- package/android/src/main/cpp/NativeProxy.cpp +327 -0
- package/android/src/main/cpp/OnLoad.cpp +17 -0
- package/android/src/main/cpp/TurboModule.cpp +44 -0
- package/android/src/main/cpp/headers/AndroidErrorHandler.h +30 -0
- package/android/src/main/cpp/headers/AndroidLogger.h +16 -0
- package/android/src/main/cpp/headers/AndroidScheduler.h +41 -0
- package/android/src/main/cpp/headers/JNIHelper.h +30 -0
- package/android/src/main/cpp/headers/LayoutAnimations.h +42 -0
- package/android/src/main/cpp/headers/NativeProxy.h +170 -0
- package/android/src/main/cpp/headers/TurboModule.h +70 -0
- package/android/src/main/java/com/facebook/react/uimanager/UIManagerReanimatedHelper.java +15 -0
- package/android/src/main/java/com/swmansion/common/GestureHandlerStateManager.java +5 -0
- package/android/src/main/java/com/swmansion/reanimated/AndroidErrorHandler.java +8 -0
- package/android/src/main/java/com/swmansion/reanimated/CopiedEvent.java +43 -0
- package/android/src/main/java/com/swmansion/reanimated/MapUtils.java +26 -0
- package/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java +117 -0
- package/android/src/main/java/com/swmansion/reanimated/NativeProxy.java +285 -0
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +682 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedJSIModulePackage.java +29 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedModule.java +251 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +96 -0
- package/android/src/main/java/com/swmansion/reanimated/Scheduler.java +51 -0
- package/android/src/main/java/com/swmansion/reanimated/UpdateContext.java +11 -0
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +32 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +517 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +56 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +11 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +410 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIImplementation.java +68 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +292 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +121 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java +12 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/AlwaysNode.java +29 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/BezierNode.java +87 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/BlockNode.java +24 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/CallFuncNode.java +49 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ClockNode.java +38 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ClockOpNode.java +73 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ConcatNode.java +36 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/CondNode.java +41 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/DebugNode.java +33 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/EventNode.java +83 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/FinalNode.java +5 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/FunctionNode.java +20 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/JSCallNode.java +41 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/Node.java +139 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/NoopNode.java +37 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/OperatorNode.java +377 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ParamNode.java +71 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/PropsNode.java +153 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/SetNode.java +32 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/StyleNode.java +40 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/TransformNode.java +84 -0
- package/android/src/main/java/com/swmansion/reanimated/nodes/ValueNode.java +40 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +41 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +40 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/ChangeTransition.java +84 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/SaneSidePropagation.java +25 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/Scale.java +86 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionModule.java +41 -0
- package/android/src/main/java/com/swmansion/reanimated/transitions/TransitionUtils.java +161 -0
- package/ios/LayoutReanimation/REAAnimationsManager.h +1 -1
- package/ios/LayoutReanimation/REAAnimationsManager.m +18 -4
- package/ios/REAModule.m +8 -9
- package/ios/REANodesManager.h +4 -1
- package/ios/REANodesManager.m +75 -3
- package/ios/native/NativeMethods.h +1 -1
- package/ios/native/NativeProxy.mm +85 -5
- package/ios/sensor/ReanimatedSensor.h +21 -0
- package/ios/sensor/ReanimatedSensor.m +169 -0
- package/ios/sensor/ReanimatedSensorContainer.h +13 -0
- package/ios/sensor/ReanimatedSensorContainer.m +41 -0
- package/ios/sensor/ReanimatedSensorType.h +7 -0
- package/lib/ConfigHelper.js +2 -2
- package/lib/createAnimatedComponent.js +3 -4
- package/lib/reanimated1/core/AnimatedFunction.js +1 -1
- package/lib/reanimated1/derived/interpolate.js +2 -4
- package/lib/reanimated2/Colors.js +3 -98
- package/lib/reanimated2/Easing.js +5 -0
- package/lib/reanimated2/NativeMethods.js +15 -5
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +25 -12
- package/lib/reanimated2/NativeReanimated/index.js +2 -6
- package/lib/reanimated2/ViewDescriptorsSet.js +2 -2
- package/lib/reanimated2/animation/styleAnimation.js +2 -1
- package/lib/reanimated2/core.js +30 -24
- package/lib/reanimated2/globals.d.ts +6 -0
- package/lib/reanimated2/hook/index.js +1 -0
- package/lib/reanimated2/hook/useAnimatedGestureHandler.js +1 -2
- package/lib/reanimated2/hook/useAnimatedSensor.js +66 -0
- 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/interpolation.js +1 -1
- package/lib/reanimated2/jestUtils.js +9 -4
- package/lib/reanimated2/js-reanimated/JSReanimated.js +24 -3
- package/lib/reanimated2/js-reanimated/commonTypes.js +1 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +8 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +2 -1
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +32 -42
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.js +20 -38
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +32 -44
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -16
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +6 -10
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +20 -36
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +16 -20
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +8 -12
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +32 -48
- package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +22 -18
- package/lib/reanimated2/mock.js +3 -2
- package/mock.js +6 -4
- package/package.json +44 -36
- package/plugin.js +3 -0
- package/react-native-reanimated.d.ts +102 -15
- package/src/ConfigHelper.ts +4 -4
- package/src/createAnimatedComponent.tsx +3 -3
- package/src/reanimated1/core/AnimatedFunction.js +1 -1
- package/src/reanimated1/derived/interpolate.js +2 -4
- package/src/reanimated2/Colors.ts +8 -151
- package/src/reanimated2/Easing.ts +11 -0
- package/src/reanimated2/NativeMethods.ts +19 -6
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +42 -14
- package/src/reanimated2/NativeReanimated/index.ts +2 -8
- package/src/reanimated2/ViewDescriptorsSet.ts +2 -3
- 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 +8 -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 +11 -25
- package/src/reanimated2/animation/timing.ts +4 -2
- package/src/reanimated2/animation/util.ts +22 -20
- package/src/reanimated2/commonTypes.ts +68 -1
- package/src/reanimated2/component/FlatList.tsx +2 -1
- package/src/reanimated2/core.ts +35 -29
- package/src/reanimated2/globals.d.ts +6 -0
- package/src/reanimated2/hook/commonTypes.ts +5 -0
- package/src/reanimated2/hook/index.ts +1 -0
- package/src/reanimated2/hook/useAnimatedGestureHandler.ts +1 -2
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -5
- package/src/reanimated2/hook/useAnimatedSensor.ts +91 -0
- package/src/reanimated2/hook/useAnimatedStyle.ts +35 -16
- package/src/reanimated2/hook/utils.ts +20 -18
- package/src/reanimated2/index.ts +2 -0
- package/src/reanimated2/interpolateColor.ts +178 -0
- package/src/reanimated2/interpolation.ts +2 -6
- package/src/reanimated2/jestUtils.ts +9 -4
- package/src/reanimated2/js-reanimated/JSReanimated.ts +28 -6
- 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/ComplexAnimationBuilder.ts +13 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +2 -3
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +51 -21
- package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +40 -10
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +48 -12
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +16 -4
- package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +8 -2
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +16 -4
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +32 -8
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -10
- package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +16 -4
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +64 -16
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +2 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +32 -21
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +2 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +2 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +2 -1
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +2 -1
- package/src/reanimated2/mock.ts +3 -2
- package/src/reanimated2/utils.ts +1 -1
- package/android/react-native-reanimated-63-hermes.aar +0 -0
- package/android/react-native-reanimated-63-jsc.aar +0 -0
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedProxyPackage.java +0 -15
- package/libSo/fbjni/jni/arm64-v8a/libfbjni.so +0 -0
- package/libSo/fbjni/jni/armeabi-v7a/libfbjni.so +0 -0
- package/libSo/fbjni/jni/x86/libfbjni.so +0 -0
- package/libSo/fbjni/jni/x86_64/libfbjni.so +0 -0
package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
package com.facebook.react.uimanager;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Nullable;
|
|
4
|
+
import com.facebook.react.bridge.Callback;
|
|
5
|
+
import com.facebook.react.bridge.Dynamic;
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
8
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
9
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
10
|
+
import com.facebook.react.bridge.WritableMap;
|
|
11
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
12
|
+
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
13
|
+
import java.util.List;
|
|
14
|
+
|
|
15
|
+
class ReaUiImplementationProvider extends UIImplementationProvider {
|
|
16
|
+
|
|
17
|
+
@Override
|
|
18
|
+
UIImplementation createUIImplementation(
|
|
19
|
+
ReactApplicationContext reactContext,
|
|
20
|
+
ViewManagerRegistry viewManagerRegistry,
|
|
21
|
+
EventDispatcher eventDispatcher,
|
|
22
|
+
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
|
23
|
+
return new ReanimatedUIImplementation(
|
|
24
|
+
reactContext,
|
|
25
|
+
viewManagerRegistry,
|
|
26
|
+
eventDispatcher,
|
|
27
|
+
minTimeLeftInFrameForNonBatchedOperationMs);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@ReactModule(name = UIManagerModule.NAME)
|
|
32
|
+
public class ReanimatedUIManager extends UIManagerModule {
|
|
33
|
+
|
|
34
|
+
public ReanimatedUIManager(
|
|
35
|
+
ReactApplicationContext reactContext,
|
|
36
|
+
List<ViewManager> viewManagersList,
|
|
37
|
+
int minTimeLeftInFrameForNonBatchedOperationMs) {
|
|
38
|
+
super(
|
|
39
|
+
reactContext,
|
|
40
|
+
viewManagersList,
|
|
41
|
+
new ReaUiImplementationProvider(),
|
|
42
|
+
minTimeLeftInFrameForNonBatchedOperationMs);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public void onBatchComplete() {
|
|
46
|
+
super.onBatchComplete();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Override
|
|
50
|
+
public boolean canOverrideExistingModule() {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
55
|
+
public @Nullable WritableMap getConstantsForViewManager(@Nullable String viewManagerName) {
|
|
56
|
+
return super.getConstantsForViewManager(viewManagerName);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
60
|
+
public WritableMap getDefaultEventTypes() {
|
|
61
|
+
return super.getDefaultEventTypes();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Unregisters a new root view. */
|
|
65
|
+
@ReactMethod
|
|
66
|
+
public void removeRootView(int rootViewTag) {
|
|
67
|
+
super.removeRootView(rootViewTag);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@ReactMethod
|
|
71
|
+
public void createView(int tag, String className, int rootViewTag, ReadableMap props) {
|
|
72
|
+
super.createView(tag, className, rootViewTag, props);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@ReactMethod
|
|
76
|
+
public void updateView(final int tag, final String className, final ReadableMap props) {
|
|
77
|
+
super.updateView(tag, className, props);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Interface for adding/removing/moving views within a parent view from JS.
|
|
82
|
+
*
|
|
83
|
+
* @param viewTag the view tag of the parent view
|
|
84
|
+
* @param moveFrom a list of indices in the parent view to move views from
|
|
85
|
+
* @param moveTo parallel to moveFrom, a list of indices in the parent view to move views to
|
|
86
|
+
* @param addChildTags a list of tags of views to add to the parent
|
|
87
|
+
* @param addAtIndices parallel to addChildTags, a list of indices to insert those children at
|
|
88
|
+
* @param removeFrom a list of indices of views to permanently remove. The memory for the
|
|
89
|
+
* corresponding views and data structures should be reclaimed.
|
|
90
|
+
*/
|
|
91
|
+
@ReactMethod
|
|
92
|
+
public void manageChildren(
|
|
93
|
+
int viewTag,
|
|
94
|
+
@Nullable ReadableArray moveFrom,
|
|
95
|
+
@Nullable ReadableArray moveTo,
|
|
96
|
+
@Nullable ReadableArray addChildTags,
|
|
97
|
+
@Nullable ReadableArray addAtIndices,
|
|
98
|
+
@Nullable ReadableArray removeFrom) {
|
|
99
|
+
super.manageChildren(viewTag, moveFrom, moveTo, addChildTags, addAtIndices, removeFrom);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Interface for fast tracking the initial adding of views. Children view tags are assumed to be
|
|
104
|
+
* in order
|
|
105
|
+
*
|
|
106
|
+
* @param viewTag the view tag of the parent view
|
|
107
|
+
* @param childrenTags An array of tags to add to the parent in order
|
|
108
|
+
*/
|
|
109
|
+
@ReactMethod
|
|
110
|
+
public void setChildren(int viewTag, ReadableArray childrenTags) {
|
|
111
|
+
super.setChildren(viewTag, childrenTags);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Replaces the View specified by oldTag with the View specified by newTag within oldTag's parent.
|
|
116
|
+
* This resolves to a simple {@link #manageChildren} call, but React doesn't have enough info in
|
|
117
|
+
* JS to formulate it itself.
|
|
118
|
+
*
|
|
119
|
+
* @deprecated This method will not be available in Fabric UIManager class.
|
|
120
|
+
*/
|
|
121
|
+
@ReactMethod
|
|
122
|
+
@Deprecated
|
|
123
|
+
public void replaceExistingNonRootView(int oldTag, int newTag) {
|
|
124
|
+
super.replaceExistingNonRootView(oldTag, newTag);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Method which takes a container tag and then releases all subviews for that container upon
|
|
129
|
+
* receipt.
|
|
130
|
+
*
|
|
131
|
+
* @param containerTag the tag of the container for which the subviews must be removed
|
|
132
|
+
* @deprecated This method will not be available in Fabric UIManager class.
|
|
133
|
+
*/
|
|
134
|
+
@ReactMethod
|
|
135
|
+
@Deprecated
|
|
136
|
+
public void removeSubviewsFromContainerWithID(int containerTag) {
|
|
137
|
+
super.removeSubviewsFromContainerWithID(containerTag);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Determines the location on screen, width, and height of the given view and returns the values
|
|
142
|
+
* via an async callback.
|
|
143
|
+
*/
|
|
144
|
+
@ReactMethod
|
|
145
|
+
public void measure(int reactTag, Callback callback) {
|
|
146
|
+
super.measure(reactTag, callback);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Determines the location on screen, width, and height of the given view relative to the device
|
|
151
|
+
* screen and returns the values via an async callback. This is the absolute position including
|
|
152
|
+
* things like the status bar
|
|
153
|
+
*/
|
|
154
|
+
@ReactMethod
|
|
155
|
+
public void measureInWindow(int reactTag, Callback callback) {
|
|
156
|
+
super.measureInWindow(reactTag, callback);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Measures the view specified by tag relative to the given ancestorTag. This means that the
|
|
161
|
+
* returned x, y are relative to the origin x, y of the ancestor view. Results are stored in the
|
|
162
|
+
* given outputBuffer. We allow ancestor view and measured view to be the same, in which case the
|
|
163
|
+
* position always will be (0, 0) and method will only measure the view dimensions.
|
|
164
|
+
*
|
|
165
|
+
* <p>NB: Unlike {@link #measure}, this will measure relative to the view layout, not the visible
|
|
166
|
+
* window which can cause unexpected results when measuring relative to things like ScrollViews
|
|
167
|
+
* that can have offset content on the screen.
|
|
168
|
+
*/
|
|
169
|
+
@ReactMethod
|
|
170
|
+
public void measureLayout(
|
|
171
|
+
int tag, int ancestorTag, Callback errorCallback, Callback successCallback) {
|
|
172
|
+
super.measureLayout(tag, ancestorTag, errorCallback, successCallback);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Like {@link #measure} and {@link #measureLayout} but measures relative to the immediate parent.
|
|
177
|
+
*
|
|
178
|
+
* <p>NB: Unlike {@link #measure}, this will measure relative to the view layout, not the visible
|
|
179
|
+
* window which can cause unexpected results when measuring relative to things like ScrollViews
|
|
180
|
+
* that can have offset content on the screen.
|
|
181
|
+
*
|
|
182
|
+
* @deprecated this method will not be available in FabricUIManager class.
|
|
183
|
+
*/
|
|
184
|
+
@ReactMethod
|
|
185
|
+
@Deprecated
|
|
186
|
+
public void measureLayoutRelativeToParent(
|
|
187
|
+
int tag, Callback errorCallback, Callback successCallback) {
|
|
188
|
+
super.measureLayoutRelativeToParent(tag, errorCallback, successCallback);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Find the touch target child native view in the supplied root view hierarchy, given a react
|
|
193
|
+
* target location.
|
|
194
|
+
*
|
|
195
|
+
* <p>This method is currently used only by Element Inspector DevTool.
|
|
196
|
+
*
|
|
197
|
+
* @param reactTag the tag of the root view to traverse
|
|
198
|
+
* @param point an array containing both X and Y target location
|
|
199
|
+
* @param callback will be called if with the identified child view react ID, and measurement
|
|
200
|
+
* info. If no view was found, callback will be invoked with no data.
|
|
201
|
+
*/
|
|
202
|
+
@ReactMethod
|
|
203
|
+
public void findSubviewIn(
|
|
204
|
+
final int reactTag, final ReadableArray point, final Callback callback) {
|
|
205
|
+
super.findSubviewIn(reactTag, point, callback);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Check if the first shadow node is the descendant of the second shadow node
|
|
210
|
+
*
|
|
211
|
+
* @deprecated this method will not be available in FabricUIManager class.
|
|
212
|
+
*/
|
|
213
|
+
@ReactMethod
|
|
214
|
+
@Deprecated
|
|
215
|
+
public void viewIsDescendantOf(
|
|
216
|
+
final int reactTag, final int ancestorReactTag, final Callback callback) {
|
|
217
|
+
super.viewIsDescendantOf(reactTag, ancestorReactTag, callback);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@ReactMethod
|
|
221
|
+
public void setJSResponder(int reactTag, boolean blockNativeResponder) {
|
|
222
|
+
super.setJSResponder(reactTag, blockNativeResponder);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@ReactMethod
|
|
226
|
+
public void clearJSResponder() {
|
|
227
|
+
super.clearJSResponder();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@ReactMethod
|
|
231
|
+
public void dispatchViewManagerCommand(
|
|
232
|
+
int reactTag, Dynamic commandId, @Nullable ReadableArray commandArgs) {
|
|
233
|
+
super.dispatchViewManagerCommand(reactTag, commandId, commandArgs);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Show a PopupMenu.
|
|
238
|
+
*
|
|
239
|
+
* @param reactTag the tag of the anchor view (the PopupMenu is displayed next to this view); this
|
|
240
|
+
* needs to be the tag of a native view (shadow views can not be anchors)
|
|
241
|
+
* @param items the menu items as an array of strings
|
|
242
|
+
* @param error will be called if there is an error displaying the menu
|
|
243
|
+
* @param success will be called with the position of the selected item as the first argument, or
|
|
244
|
+
* no arguments if the menu is dismissed
|
|
245
|
+
*/
|
|
246
|
+
@ReactMethod
|
|
247
|
+
public void showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success) {
|
|
248
|
+
super.showPopupMenu(reactTag, items, error, success);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@ReactMethod
|
|
252
|
+
public void dismissPopupMenu() {
|
|
253
|
+
super.dismissPopupMenu();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* LayoutAnimation API on Android is currently experimental. Therefore, it needs to be enabled
|
|
258
|
+
* explicitly in order to avoid regression in existing application written for iOS using this API.
|
|
259
|
+
*
|
|
260
|
+
* <p>Warning : This method will be removed in future version of React Native, and layout
|
|
261
|
+
* animation will be enabled by default, so always check for its existence before invoking it.
|
|
262
|
+
*
|
|
263
|
+
* <p>TODO(9139831) : remove this method once layout animation is fully stable.
|
|
264
|
+
*
|
|
265
|
+
* @param enabled whether layout animation is enabled or not
|
|
266
|
+
*/
|
|
267
|
+
@ReactMethod
|
|
268
|
+
public void setLayoutAnimationEnabledExperimental(boolean enabled) {
|
|
269
|
+
super.setLayoutAnimationEnabledExperimental(enabled);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Configure an animation to be used for the native layout changes, and native views creation. The
|
|
274
|
+
* animation will only apply during the current batch operations.
|
|
275
|
+
*
|
|
276
|
+
* <p>TODO(7728153) : animating view deletion is currently not supported.
|
|
277
|
+
*
|
|
278
|
+
* @param config the configuration of the animation for view addition/removal/update.
|
|
279
|
+
* @param success will be called when the animation completes, or when the animation get
|
|
280
|
+
* interrupted. In this case, callback parameter will be false.
|
|
281
|
+
* @param error will be called if there was an error processing the animation
|
|
282
|
+
*/
|
|
283
|
+
@ReactMethod
|
|
284
|
+
public void configureNextLayoutAnimation(ReadableMap config, Callback success, Callback error) {
|
|
285
|
+
super.configureNextLayoutAnimation(config, success, error);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
@ReactMethod
|
|
289
|
+
public void sendAccessibilityEvent(int tag, int eventType) {
|
|
290
|
+
super.sendAccessibilityEvent(tag, eventType);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
package com.swmansion.reanimated.layoutReanimation;
|
|
2
|
+
|
|
3
|
+
import android.view.View;
|
|
4
|
+
import android.view.ViewGroup;
|
|
5
|
+
import com.facebook.react.uimanager.IllegalViewOperationException;
|
|
6
|
+
import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
|
7
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
8
|
+
import java.util.ArrayList;
|
|
9
|
+
import java.util.Arrays;
|
|
10
|
+
import java.util.HashMap;
|
|
11
|
+
|
|
12
|
+
public class Snapshot {
|
|
13
|
+
public static final String WIDTH = "width";
|
|
14
|
+
public static final String HEIGHT = "height";
|
|
15
|
+
public static final String ORIGIN_X = "originX";
|
|
16
|
+
public static final String ORIGIN_Y = "originY";
|
|
17
|
+
public static final String GLOBAL_ORIGIN_X = "globalOriginX";
|
|
18
|
+
public static final String GLOBAL_ORIGIN_Y = "globalOriginY";
|
|
19
|
+
|
|
20
|
+
public static final String CURRENT_WIDTH = "currentWidth";
|
|
21
|
+
public static final String CURRENT_HEIGHT = "currentHeight";
|
|
22
|
+
public static final String CURRENT_ORIGIN_X = "currentOriginX";
|
|
23
|
+
public static final String CURRENT_ORIGIN_Y = "currentOriginY";
|
|
24
|
+
public static final String CURRENT_GLOBAL_ORIGIN_X = "currentGlobalOriginX";
|
|
25
|
+
public static final String CURRENT_GLOBAL_ORIGIN_Y = "currentGlobalOriginY";
|
|
26
|
+
|
|
27
|
+
public static final String TARGET_WIDTH = "targetWidth";
|
|
28
|
+
public static final String TARGET_HEIGHT = "targetHeight";
|
|
29
|
+
public static final String TARGET_ORIGIN_X = "targetOriginX";
|
|
30
|
+
public static final String TARGET_ORIGIN_Y = "targetOriginY";
|
|
31
|
+
public static final String TARGET_GLOBAL_ORIGIN_X = "targetGlobalOriginX";
|
|
32
|
+
public static final String TARGET_GLOBAL_ORIGIN_Y = "targetGlobalOriginY";
|
|
33
|
+
|
|
34
|
+
public View view;
|
|
35
|
+
public ViewGroup parent;
|
|
36
|
+
public ViewManager viewManager;
|
|
37
|
+
public ViewManager parentViewManager;
|
|
38
|
+
public int width;
|
|
39
|
+
public int height;
|
|
40
|
+
public int originX;
|
|
41
|
+
public int originY;
|
|
42
|
+
public int globalOriginX;
|
|
43
|
+
public int globalOriginY;
|
|
44
|
+
|
|
45
|
+
public static ArrayList<String> targetKeysToTransform;
|
|
46
|
+
public static ArrayList<String> currentKeysToTransform;
|
|
47
|
+
|
|
48
|
+
Snapshot(View view, NativeViewHierarchyManager viewHierarchyManager) {
|
|
49
|
+
parent = (ViewGroup) view.getParent();
|
|
50
|
+
try {
|
|
51
|
+
viewManager = viewHierarchyManager.resolveViewManager(view.getId());
|
|
52
|
+
parentViewManager = viewHierarchyManager.resolveViewManager(parent.getId());
|
|
53
|
+
} catch (IllegalViewOperationException | NullPointerException e) {
|
|
54
|
+
// do nothing
|
|
55
|
+
}
|
|
56
|
+
width = view.getWidth();
|
|
57
|
+
height = view.getHeight();
|
|
58
|
+
originX = view.getLeft();
|
|
59
|
+
originY = view.getTop();
|
|
60
|
+
this.view = view;
|
|
61
|
+
int[] location = new int[2];
|
|
62
|
+
view.getLocationOnScreen(location);
|
|
63
|
+
globalOriginX = location[0];
|
|
64
|
+
globalOriginY = location[1];
|
|
65
|
+
|
|
66
|
+
targetKeysToTransform =
|
|
67
|
+
new ArrayList<>(
|
|
68
|
+
Arrays.asList(
|
|
69
|
+
Snapshot.TARGET_WIDTH,
|
|
70
|
+
Snapshot.TARGET_HEIGHT,
|
|
71
|
+
Snapshot.TARGET_ORIGIN_X,
|
|
72
|
+
Snapshot.TARGET_ORIGIN_Y,
|
|
73
|
+
Snapshot.TARGET_GLOBAL_ORIGIN_X,
|
|
74
|
+
Snapshot.TARGET_GLOBAL_ORIGIN_Y));
|
|
75
|
+
currentKeysToTransform =
|
|
76
|
+
new ArrayList<>(
|
|
77
|
+
Arrays.asList(
|
|
78
|
+
Snapshot.CURRENT_WIDTH,
|
|
79
|
+
Snapshot.CURRENT_HEIGHT,
|
|
80
|
+
Snapshot.CURRENT_ORIGIN_X,
|
|
81
|
+
Snapshot.CURRENT_ORIGIN_Y,
|
|
82
|
+
Snapshot.CURRENT_GLOBAL_ORIGIN_X,
|
|
83
|
+
Snapshot.CURRENT_GLOBAL_ORIGIN_Y));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private void addTargetConfig(HashMap<String, Object> data) {
|
|
87
|
+
data.put(Snapshot.TARGET_ORIGIN_Y, originY);
|
|
88
|
+
data.put(Snapshot.TARGET_ORIGIN_X, originX);
|
|
89
|
+
data.put(Snapshot.TARGET_GLOBAL_ORIGIN_Y, globalOriginY);
|
|
90
|
+
data.put(Snapshot.TARGET_GLOBAL_ORIGIN_X, globalOriginX);
|
|
91
|
+
data.put(Snapshot.TARGET_HEIGHT, height);
|
|
92
|
+
data.put(Snapshot.TARGET_WIDTH, width);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private void addCurrentConfig(HashMap<String, Object> data) {
|
|
96
|
+
data.put(Snapshot.CURRENT_ORIGIN_Y, originY);
|
|
97
|
+
data.put(Snapshot.CURRENT_ORIGIN_X, originX);
|
|
98
|
+
data.put(Snapshot.CURRENT_GLOBAL_ORIGIN_Y, globalOriginY);
|
|
99
|
+
data.put(Snapshot.CURRENT_GLOBAL_ORIGIN_X, globalOriginX);
|
|
100
|
+
data.put(Snapshot.CURRENT_HEIGHT, height);
|
|
101
|
+
data.put(Snapshot.CURRENT_WIDTH, width);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public HashMap<String, Object> toTargetMap() {
|
|
105
|
+
HashMap<String, Object> data = new HashMap<>();
|
|
106
|
+
addTargetConfig(data);
|
|
107
|
+
return data;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public HashMap<String, Object> toCurrentMap() {
|
|
111
|
+
HashMap<String, Object> data = new HashMap<>();
|
|
112
|
+
addCurrentConfig(data);
|
|
113
|
+
return data;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public HashMap<String, Object> toLayoutMap(Snapshot target) {
|
|
117
|
+
HashMap<String, Object> data = target.toTargetMap();
|
|
118
|
+
addCurrentConfig(data);
|
|
119
|
+
return data;
|
|
120
|
+
}
|
|
121
|
+
}
|
package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ViewHierarchyObserver.java
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.swmansion.reanimated.layoutReanimation;
|
|
2
|
+
|
|
3
|
+
import android.view.View;
|
|
4
|
+
import android.view.ViewGroup;
|
|
5
|
+
|
|
6
|
+
public interface ViewHierarchyObserver {
|
|
7
|
+
void onViewRemoval(View view, ViewGroup parent, Snapshot before, Runnable callback);
|
|
8
|
+
|
|
9
|
+
void onViewCreate(View view, ViewGroup parent, Snapshot after);
|
|
10
|
+
|
|
11
|
+
void onViewUpdate(View view, Snapshot before, Snapshot after);
|
|
12
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.swmansion.reanimated.nodes;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
4
|
+
import com.swmansion.reanimated.MapUtils;
|
|
5
|
+
import com.swmansion.reanimated.NodesManager;
|
|
6
|
+
|
|
7
|
+
public class AlwaysNode extends Node implements FinalNode {
|
|
8
|
+
public AlwaysNode(int nodeID, ReadableMap config, NodesManager nodesManager) {
|
|
9
|
+
super(nodeID, config, nodesManager);
|
|
10
|
+
mNodeToBeEvaluated =
|
|
11
|
+
MapUtils.getInt(
|
|
12
|
+
config,
|
|
13
|
+
"what",
|
|
14
|
+
"Reanimated: Argument passed to always node is either of wrong type or is missing.");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
private int mNodeToBeEvaluated;
|
|
18
|
+
|
|
19
|
+
@Override
|
|
20
|
+
public void update() {
|
|
21
|
+
this.value();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Override
|
|
25
|
+
protected Double evaluate() {
|
|
26
|
+
mNodesManager.findNodeById(mNodeToBeEvaluated, Node.class).value();
|
|
27
|
+
return ZERO;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
package com.swmansion.reanimated.nodes;
|
|
2
|
+
|
|
3
|
+
import android.graphics.PointF;
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
5
|
+
import com.swmansion.reanimated.MapUtils;
|
|
6
|
+
import com.swmansion.reanimated.NodesManager;
|
|
7
|
+
|
|
8
|
+
public class BezierNode extends Node {
|
|
9
|
+
|
|
10
|
+
private static class CubicBezierInterpolator {
|
|
11
|
+
|
|
12
|
+
protected PointF start;
|
|
13
|
+
protected PointF end;
|
|
14
|
+
protected PointF a = new PointF();
|
|
15
|
+
protected PointF b = new PointF();
|
|
16
|
+
protected PointF c = new PointF();
|
|
17
|
+
|
|
18
|
+
public CubicBezierInterpolator(PointF start, PointF end) {
|
|
19
|
+
this.start = start;
|
|
20
|
+
this.end = end;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public CubicBezierInterpolator(float startX, float startY, float endX, float endY) {
|
|
24
|
+
this(new PointF(startX, startY), new PointF(endX, endY));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public float getInterpolation(float time) {
|
|
28
|
+
return getBezierCoordinateY(getXForTime(time));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
protected float getBezierCoordinateY(float time) {
|
|
32
|
+
c.y = 3 * start.y;
|
|
33
|
+
b.y = 3 * (end.y - start.y) - c.y;
|
|
34
|
+
a.y = 1 - c.y - b.y;
|
|
35
|
+
return time * (c.y + time * (b.y + time * a.y));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected float getXForTime(float time) {
|
|
39
|
+
float x = time;
|
|
40
|
+
float z;
|
|
41
|
+
for (int i = 1; i < 14; i++) {
|
|
42
|
+
z = getBezierCoordinateX(x) - time;
|
|
43
|
+
if (Math.abs(z) < 1e-3) {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
x -= z / getXDerivate(x);
|
|
47
|
+
}
|
|
48
|
+
return x;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private float getXDerivate(float t) {
|
|
52
|
+
return c.x + t * (2 * b.x + 3 * a.x * t);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private float getBezierCoordinateX(float time) {
|
|
56
|
+
c.x = 3 * start.x;
|
|
57
|
+
b.x = 3 * (end.x - start.x) - c.x;
|
|
58
|
+
a.x = 1 - c.x - b.x;
|
|
59
|
+
return time * (c.x + time * (b.x + time * a.x));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private final int mInputID;
|
|
64
|
+
private final CubicBezierInterpolator mInterpolator;
|
|
65
|
+
|
|
66
|
+
public BezierNode(int nodeID, ReadableMap config, NodesManager nodesManager) {
|
|
67
|
+
super(nodeID, config, nodesManager);
|
|
68
|
+
|
|
69
|
+
mInputID =
|
|
70
|
+
MapUtils.getInt(
|
|
71
|
+
config,
|
|
72
|
+
"input",
|
|
73
|
+
"Reanimated: Argument passed to bezier node is either of wrong type or is missing.");
|
|
74
|
+
|
|
75
|
+
float startX = (float) config.getDouble("mX1");
|
|
76
|
+
float startY = (float) config.getDouble("mY1");
|
|
77
|
+
float endX = (float) config.getDouble("mX2");
|
|
78
|
+
float endY = (float) config.getDouble("mY2");
|
|
79
|
+
mInterpolator = new CubicBezierInterpolator(startX, startY, endX, endY);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Override
|
|
83
|
+
protected Double evaluate() {
|
|
84
|
+
Double in = (Double) mNodesManager.getNodeValue(mInputID);
|
|
85
|
+
return Double.valueOf(mInterpolator.getInterpolation(in.floatValue()));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.swmansion.reanimated.nodes;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
4
|
+
import com.swmansion.reanimated.NodesManager;
|
|
5
|
+
import com.swmansion.reanimated.Utils;
|
|
6
|
+
|
|
7
|
+
public class BlockNode extends Node {
|
|
8
|
+
|
|
9
|
+
private final int[] mBlock;
|
|
10
|
+
|
|
11
|
+
public BlockNode(int nodeID, ReadableMap config, NodesManager nodesManager) {
|
|
12
|
+
super(nodeID, config, nodesManager);
|
|
13
|
+
mBlock = Utils.processIntArray(config.getArray("block"));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Override
|
|
17
|
+
protected Object evaluate() {
|
|
18
|
+
Object res = null;
|
|
19
|
+
for (int i = 0; i < mBlock.length; i++) {
|
|
20
|
+
res = mNodesManager.findNodeById(mBlock[i], Node.class).value();
|
|
21
|
+
}
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
package com.swmansion.reanimated.nodes;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
4
|
+
import com.swmansion.reanimated.NodesManager;
|
|
5
|
+
import com.swmansion.reanimated.Utils;
|
|
6
|
+
|
|
7
|
+
public class CallFuncNode extends Node {
|
|
8
|
+
|
|
9
|
+
private String mPreviousCallID;
|
|
10
|
+
private final int mWhatNodeID;
|
|
11
|
+
private final int[] mArgs;
|
|
12
|
+
private final int[] mParams;
|
|
13
|
+
|
|
14
|
+
public CallFuncNode(int nodeID, ReadableMap config, NodesManager nodesManager) {
|
|
15
|
+
super(nodeID, config, nodesManager);
|
|
16
|
+
mWhatNodeID = config.getInt("what");
|
|
17
|
+
mParams = Utils.processIntArray(config.getArray("params"));
|
|
18
|
+
mArgs = Utils.processIntArray(config.getArray("args"));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private void beginContext() {
|
|
22
|
+
mPreviousCallID = mNodesManager.updateContext.callID;
|
|
23
|
+
mNodesManager.updateContext.callID =
|
|
24
|
+
mNodesManager.updateContext.callID + '/' + String.valueOf(mNodeID);
|
|
25
|
+
for (int i = 0; i < mParams.length; i++) {
|
|
26
|
+
int paramId = mParams[i];
|
|
27
|
+
ParamNode paramNode = mNodesManager.findNodeById(paramId, ParamNode.class);
|
|
28
|
+
paramNode.beginContext(mArgs[i], mPreviousCallID);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private void endContext() {
|
|
33
|
+
for (int i = 0; i < mParams.length; i++) {
|
|
34
|
+
int paramId = mParams[i];
|
|
35
|
+
ParamNode paramNode = mNodesManager.findNodeById(paramId, ParamNode.class);
|
|
36
|
+
paramNode.endContext();
|
|
37
|
+
}
|
|
38
|
+
mNodesManager.updateContext.callID = mPreviousCallID;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Override
|
|
42
|
+
protected Object evaluate() {
|
|
43
|
+
beginContext();
|
|
44
|
+
Node whatNode = mNodesManager.findNodeById(mWhatNodeID, Node.class);
|
|
45
|
+
Object retVal = whatNode.value();
|
|
46
|
+
endContext();
|
|
47
|
+
return retVal;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package com.swmansion.reanimated.nodes;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
4
|
+
import com.swmansion.reanimated.NodesManager;
|
|
5
|
+
|
|
6
|
+
public class ClockNode extends Node implements NodesManager.OnAnimationFrame {
|
|
7
|
+
|
|
8
|
+
public boolean isRunning;
|
|
9
|
+
|
|
10
|
+
public ClockNode(int nodeID, ReadableMap config, NodesManager nodesManager) {
|
|
11
|
+
super(nodeID, config, nodesManager);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public void start() {
|
|
15
|
+
if (isRunning) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
isRunning = true;
|
|
19
|
+
mNodesManager.postOnAnimation(this);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public void stop() {
|
|
23
|
+
isRunning = false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Override
|
|
27
|
+
protected Double evaluate() {
|
|
28
|
+
return mNodesManager.currentFrameTimeMs;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@Override
|
|
32
|
+
public void onAnimationFrame(double timestampMs) {
|
|
33
|
+
if (isRunning) {
|
|
34
|
+
markUpdated();
|
|
35
|
+
mNodesManager.postOnAnimation(this);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|