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/lib/ConfigHelper.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { configureProps as jsiConfigureProps } from './reanimated2/core';
|
|
2
2
|
/**
|
|
3
3
|
* Styles allowed to be direcly updated in UI thread
|
|
4
4
|
*/
|
|
@@ -104,7 +104,7 @@ let NATIVE_THREAD_PROPS_WHITELIST = {
|
|
|
104
104
|
placeholderTextColor: true,
|
|
105
105
|
};
|
|
106
106
|
function configureProps() {
|
|
107
|
-
|
|
107
|
+
jsiConfigureProps(Object.keys(UI_THREAD_PROPS_WHITELIST), Object.keys(NATIVE_THREAD_PROPS_WHITELIST));
|
|
108
108
|
}
|
|
109
109
|
export function addWhitelistedNativeProps(props) {
|
|
110
110
|
const oldSize = Object.keys(NATIVE_THREAD_PROPS_WHITELIST).length;
|
|
@@ -90,6 +90,7 @@ export default function createAnimatedComponent(Component, options) {
|
|
|
90
90
|
this._viewTag = -1;
|
|
91
91
|
this._isFirstRender = true;
|
|
92
92
|
this.animatedStyle = { value: {} };
|
|
93
|
+
this.initialStyle = {};
|
|
93
94
|
this._component = null;
|
|
94
95
|
// The system is best designed when setNativeProps is implemented. It is
|
|
95
96
|
// able to avoid re-rendering and directly set the attributes that changed.
|
|
@@ -438,11 +439,9 @@ export default function createAnimatedComponent(Component, options) {
|
|
|
438
439
|
// this is how we recognize styles returned by useAnimatedStyle
|
|
439
440
|
style.viewsRef.add(this);
|
|
440
441
|
if (this._isFirstRender) {
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
else {
|
|
444
|
-
return style.initial.value;
|
|
442
|
+
this.initialStyle = Object.assign(Object.assign({}, style.initial.value), initialUpdaterRun(style.initial.updater));
|
|
445
443
|
}
|
|
444
|
+
return this.initialStyle;
|
|
446
445
|
}
|
|
447
446
|
else {
|
|
448
447
|
return style;
|
|
@@ -37,7 +37,7 @@ export function createAnimatedFunction(cb) {
|
|
|
37
37
|
for (let i = 0; i < params.length; i++) {
|
|
38
38
|
params[i] = createAnimatedParam();
|
|
39
39
|
}
|
|
40
|
-
// eslint-disable-next-line
|
|
40
|
+
// eslint-disable-next-line node/no-callback-literal
|
|
41
41
|
const what = cb(...params);
|
|
42
42
|
const func = new AnimatedFunction(what, ...params);
|
|
43
43
|
return (...args) => {
|
|
@@ -128,15 +128,13 @@ export default function interpolate(value, config) {
|
|
|
128
128
|
const right = extrapolateRight || extrapolate;
|
|
129
129
|
let output = interpolateInternal(value, inputRange, outputRange);
|
|
130
130
|
|
|
131
|
-
if (left === Extrapolate.
|
|
132
|
-
} else if (left === Extrapolate.CLAMP) {
|
|
131
|
+
if (left === Extrapolate.CLAMP) {
|
|
133
132
|
output = cond(lessThan(value, inputRange[0]), outputRange[0], output);
|
|
134
133
|
} else if (left === Extrapolate.IDENTITY) {
|
|
135
134
|
output = cond(lessThan(value, inputRange[0]), value, output);
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
if (right === Extrapolate.
|
|
139
|
-
} else if (right === Extrapolate.CLAMP) {
|
|
137
|
+
if (right === Extrapolate.CLAMP) {
|
|
140
138
|
output = cond(
|
|
141
139
|
greaterThan(value, inputRange[inputRange.length - 1]),
|
|
142
140
|
outputRange[outputRange.length - 1],
|
|
@@ -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 + '%';
|
|
@@ -34,7 +31,8 @@ function getMatchers() {
|
|
|
34
31
|
cachedMatchers.hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
|
|
35
32
|
cachedMatchers.hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
|
|
36
33
|
cachedMatchers.hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
|
37
|
-
cachedMatchers.hex4 =
|
|
34
|
+
cachedMatchers.hex4 =
|
|
35
|
+
/^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
|
|
38
36
|
cachedMatchers.hex6 = /^#([0-9a-fA-F]{6})$/;
|
|
39
37
|
cachedMatchers.hex8 = /^#([0-9a-fA-F]{8})$/;
|
|
40
38
|
}
|
|
@@ -381,7 +379,7 @@ export const rgbaColor = (r, g, b, alpha = 1) => {
|
|
|
381
379
|
}
|
|
382
380
|
return c;
|
|
383
381
|
};
|
|
384
|
-
function RGBtoHSV(r, g, b) {
|
|
382
|
+
export function RGBtoHSV(r, g, b) {
|
|
385
383
|
'worklet';
|
|
386
384
|
/* eslint-disable */
|
|
387
385
|
if (arguments.length === 1) {
|
|
@@ -522,96 +520,3 @@ export function toRGBA(HSVA) {
|
|
|
522
520
|
const { r, g, b } = HSVtoRGB(HSVA[0], HSVA[1], HSVA[2]);
|
|
523
521
|
return `rgba(${r}, ${g}, ${b}, ${HSVA[3]})`;
|
|
524
522
|
}
|
|
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
|
-
};
|
|
@@ -149,6 +149,10 @@ function bezier(x1, y1, x2, y2) {
|
|
|
149
149
|
},
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
+
function bezierFn(x1, y1, x2, y2) {
|
|
153
|
+
'worklet';
|
|
154
|
+
return Bezier(x1, y1, x2, y2);
|
|
155
|
+
}
|
|
152
156
|
/**
|
|
153
157
|
* Runs an easing function forwards.
|
|
154
158
|
*/
|
|
@@ -194,6 +198,7 @@ const EasingObject = {
|
|
|
194
198
|
back,
|
|
195
199
|
bounce,
|
|
196
200
|
bezier,
|
|
201
|
+
bezierFn,
|
|
197
202
|
in: in_,
|
|
198
203
|
out,
|
|
199
204
|
inOut,
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { findNodeHandle } from 'react-native';
|
|
2
|
-
import {
|
|
2
|
+
import { shouldBeUseWeb } from './PlatformChecker';
|
|
3
3
|
export function getTag(view) {
|
|
4
4
|
return findNodeHandle(view);
|
|
5
5
|
}
|
|
6
|
+
const isNativeIndefined = shouldBeUseWeb();
|
|
6
7
|
export function measure(animatedRef) {
|
|
7
8
|
'worklet';
|
|
8
|
-
if (!_WORKLET
|
|
9
|
-
|
|
9
|
+
if (!_WORKLET || isNativeIndefined) {
|
|
10
|
+
console.warn('[reanimated.measure] method cannot be used for web or Chrome Debugger');
|
|
11
|
+
return {
|
|
12
|
+
x: NaN,
|
|
13
|
+
y: NaN,
|
|
14
|
+
width: NaN,
|
|
15
|
+
height: NaN,
|
|
16
|
+
pageX: NaN,
|
|
17
|
+
pageY: NaN,
|
|
18
|
+
};
|
|
10
19
|
}
|
|
11
20
|
const viewTag = animatedRef();
|
|
12
21
|
const result = _measure(viewTag);
|
|
@@ -17,7 +26,7 @@ export function measure(animatedRef) {
|
|
|
17
26
|
}
|
|
18
27
|
export function scrollTo(animatedRef, x, y, animated) {
|
|
19
28
|
'worklet';
|
|
20
|
-
if (!_WORKLET
|
|
29
|
+
if (!_WORKLET || isNativeIndefined) {
|
|
21
30
|
return;
|
|
22
31
|
}
|
|
23
32
|
const viewTag = animatedRef();
|
|
@@ -25,8 +34,9 @@ export function scrollTo(animatedRef, x, y, animated) {
|
|
|
25
34
|
}
|
|
26
35
|
export function setGestureState(handlerTag, newState) {
|
|
27
36
|
'worklet';
|
|
28
|
-
if (!_WORKLET
|
|
37
|
+
if (!_WORKLET || isNativeIndefined) {
|
|
29
38
|
console.warn('[Reanimated] You can not use setGestureState in non-worklet function.');
|
|
39
|
+
return;
|
|
30
40
|
}
|
|
31
41
|
_setGestureState(handlerTag, newState);
|
|
32
42
|
}
|
|
@@ -1,37 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
2
|
export class NativeReanimated {
|
|
3
3
|
constructor(native = true) {
|
|
4
|
+
if (global.__reanimatedModuleProxy === undefined) {
|
|
5
|
+
const { ReanimatedModule } = NativeModules;
|
|
6
|
+
ReanimatedModule === null || ReanimatedModule === void 0 ? void 0 : ReanimatedModule.installTurboModule();
|
|
7
|
+
}
|
|
8
|
+
this.InnerNativeModule = global.__reanimatedModuleProxy;
|
|
4
9
|
this.native = native;
|
|
5
|
-
this.useOnlyV1 = InnerNativeModule === null;
|
|
6
10
|
}
|
|
7
11
|
installCoreFunctions(valueSetter) {
|
|
8
|
-
return InnerNativeModule.installCoreFunctions(valueSetter);
|
|
12
|
+
return this.InnerNativeModule.installCoreFunctions(valueSetter);
|
|
9
13
|
}
|
|
10
14
|
makeShareable(value) {
|
|
11
|
-
return InnerNativeModule.makeShareable(value);
|
|
15
|
+
return this.InnerNativeModule.makeShareable(value);
|
|
12
16
|
}
|
|
13
17
|
makeMutable(value) {
|
|
14
|
-
return InnerNativeModule.makeMutable(value);
|
|
18
|
+
return this.InnerNativeModule.makeMutable(value);
|
|
15
19
|
}
|
|
16
20
|
makeRemote(object = {}) {
|
|
17
|
-
return InnerNativeModule.makeRemote(object);
|
|
21
|
+
return this.InnerNativeModule.makeRemote(object);
|
|
22
|
+
}
|
|
23
|
+
registerSensor(sensorType, interval, sensorData) {
|
|
24
|
+
return this.InnerNativeModule.registerSensor(sensorType, interval, sensorData);
|
|
25
|
+
}
|
|
26
|
+
unregisterSensor(sensorId) {
|
|
27
|
+
return this.InnerNativeModule.unregisterSensor(sensorId);
|
|
18
28
|
}
|
|
19
29
|
startMapper(mapper, inputs = [], outputs = [], updater, viewDescriptors) {
|
|
20
|
-
return InnerNativeModule.startMapper(mapper, inputs, outputs, updater, viewDescriptors);
|
|
30
|
+
return this.InnerNativeModule.startMapper(mapper, inputs, outputs, updater, viewDescriptors);
|
|
21
31
|
}
|
|
22
32
|
stopMapper(mapperId) {
|
|
23
|
-
return InnerNativeModule.stopMapper(mapperId);
|
|
33
|
+
return this.InnerNativeModule.stopMapper(mapperId);
|
|
24
34
|
}
|
|
25
35
|
registerEventHandler(eventHash, eventHandler) {
|
|
26
|
-
return InnerNativeModule.registerEventHandler(eventHash, eventHandler);
|
|
36
|
+
return this.InnerNativeModule.registerEventHandler(eventHash, eventHandler);
|
|
27
37
|
}
|
|
28
38
|
unregisterEventHandler(id) {
|
|
29
|
-
return InnerNativeModule.unregisterEventHandler(id);
|
|
39
|
+
return this.InnerNativeModule.unregisterEventHandler(id);
|
|
30
40
|
}
|
|
31
41
|
getViewProp(viewTag, propName, callback) {
|
|
32
|
-
return InnerNativeModule.getViewProp(viewTag, propName, callback);
|
|
42
|
+
return this.InnerNativeModule.getViewProp(viewTag, propName, callback);
|
|
33
43
|
}
|
|
34
44
|
enableLayoutAnimations(flag) {
|
|
35
|
-
InnerNativeModule.enableLayoutAnimations(flag);
|
|
45
|
+
this.InnerNativeModule.enableLayoutAnimations(flag);
|
|
46
|
+
}
|
|
47
|
+
configureProps(uiProps, nativeProps) {
|
|
48
|
+
this.InnerNativeModule.configureProps(uiProps, nativeProps);
|
|
36
49
|
}
|
|
37
50
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import reanimatedJS from '../js-reanimated';
|
|
2
|
-
import {
|
|
3
|
-
import { Platform } from 'react-native';
|
|
2
|
+
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
4
3
|
import { NativeReanimated } from './NativeReanimated';
|
|
5
4
|
let exportedModule;
|
|
6
|
-
if (
|
|
5
|
+
if (shouldBeUseWeb()) {
|
|
7
6
|
exportedModule = reanimatedJS;
|
|
8
7
|
}
|
|
9
8
|
else {
|
|
10
9
|
exportedModule = new NativeReanimated();
|
|
11
|
-
if (exportedModule.useOnlyV1 && Platform.OS === 'android') {
|
|
12
|
-
console.warn(`If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation`);
|
|
13
|
-
}
|
|
14
10
|
}
|
|
15
11
|
export default exportedModule;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRef } from 'react';
|
|
2
2
|
import { makeMutable } from './core';
|
|
3
|
-
import {
|
|
4
|
-
const scheduleUpdates =
|
|
3
|
+
import { shouldBeUseWeb } from './PlatformChecker';
|
|
4
|
+
const scheduleUpdates = shouldBeUseWeb() ? requestAnimationFrame : setImmediate;
|
|
5
5
|
export function makeViewDescriptorsSet() {
|
|
6
6
|
const ref = useRef(null);
|
|
7
7
|
if (ref.current === null) {
|
package/lib/reanimated2/core.js
CHANGED
|
@@ -24,7 +24,7 @@ export const checkPluginState = (throwError = true) => {
|
|
|
24
24
|
return true;
|
|
25
25
|
};
|
|
26
26
|
export const isConfigured = (throwError = false) => {
|
|
27
|
-
return checkPluginState(throwError)
|
|
27
|
+
return checkPluginState(throwError);
|
|
28
28
|
};
|
|
29
29
|
export const isConfiguredCheck = () => {
|
|
30
30
|
if (!isConfigured(true)) {
|
|
@@ -259,29 +259,27 @@ export function runOnJS(fun) {
|
|
|
259
259
|
return fun.__callAsync;
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
global.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
})();
|
|
284
|
-
}
|
|
262
|
+
NativeReanimatedModule.installCoreFunctions(NativeReanimatedModule.native
|
|
263
|
+
? workletValueSetter
|
|
264
|
+
: workletValueSetterJS);
|
|
265
|
+
if (!isWeb() && isConfigured()) {
|
|
266
|
+
const capturableConsole = console;
|
|
267
|
+
runOnUI(() => {
|
|
268
|
+
'worklet';
|
|
269
|
+
const console = {
|
|
270
|
+
debug: runOnJS(capturableConsole.debug),
|
|
271
|
+
log: runOnJS(capturableConsole.log),
|
|
272
|
+
warn: runOnJS(capturableConsole.warn),
|
|
273
|
+
error: runOnJS(capturableConsole.error),
|
|
274
|
+
info: runOnJS(capturableConsole.info),
|
|
275
|
+
};
|
|
276
|
+
_setGlobalConsole(console);
|
|
277
|
+
if (global.performance == null) {
|
|
278
|
+
global.performance = {
|
|
279
|
+
now: global._chronoNow,
|
|
280
|
+
}; // due to conflict with lib.dom.d.ts -> Performance
|
|
281
|
+
}
|
|
282
|
+
})();
|
|
285
283
|
}
|
|
286
284
|
let featuresConfig = {
|
|
287
285
|
enableLayoutAnimations: false,
|
|
@@ -301,3 +299,11 @@ export function enableLayoutAnimations(flag, isCallByUser = true) {
|
|
|
301
299
|
NativeReanimatedModule.enableLayoutAnimations(flag);
|
|
302
300
|
}
|
|
303
301
|
}
|
|
302
|
+
export function configureProps(uiProps, nativeProps) {
|
|
303
|
+
if (!nativeShouldBeMock()) {
|
|
304
|
+
NativeReanimatedModule.configureProps(uiProps, nativeProps);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
export function jestResetJsReanimatedModule() {
|
|
308
|
+
NativeReanimatedModule.jestResetModule();
|
|
309
|
+
}
|
|
@@ -27,6 +27,9 @@ declare global {
|
|
|
27
27
|
animated: boolean
|
|
28
28
|
) => void;
|
|
29
29
|
const _chronoNow: () => number;
|
|
30
|
+
const ReanimatedDataMock: {
|
|
31
|
+
now: () => number;
|
|
32
|
+
};
|
|
30
33
|
namespace NodeJS {
|
|
31
34
|
interface Global {
|
|
32
35
|
__reanimatedWorkletInit: (worklet: WorkletFunction) => void;
|
|
@@ -50,6 +53,9 @@ declare global {
|
|
|
50
53
|
yogaValues: unknown
|
|
51
54
|
): void;
|
|
52
55
|
};
|
|
56
|
+
ReanimatedDataMock: {
|
|
57
|
+
now: () => number;
|
|
58
|
+
};
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
}
|
|
@@ -6,3 +6,4 @@ export { useAnimatedReaction, } from './useAnimatedReaction';
|
|
|
6
6
|
export { useAnimatedRef } from './useAnimatedRef';
|
|
7
7
|
export { useAnimatedScrollHandler, } from './useAnimatedScrollHandler';
|
|
8
8
|
export { useDerivedValue } from './useDerivedValue';
|
|
9
|
+
export { useAnimatedSensor, SensorType } from './useAnimatedSensor';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isWeb } from '../PlatformChecker';
|
|
2
1
|
import { useEvent, useHandler } from './Hooks';
|
|
3
2
|
export var EventType;
|
|
4
3
|
(function (EventType) {
|
|
@@ -43,7 +42,7 @@ export function useAnimatedGestureHandler(handlers, dependencies) {
|
|
|
43
42
|
handlers.onFinish(event, context, event.state === EventType.CANCELLED || event.state === EventType.FAILED);
|
|
44
43
|
}
|
|
45
44
|
};
|
|
46
|
-
if (
|
|
45
|
+
if (useWeb) {
|
|
47
46
|
return handler;
|
|
48
47
|
}
|
|
49
48
|
return useEvent(handler, ['onGestureHandlerStateChange', 'onGestureHandlerEvent'], doDependenciesDiffer);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { makeMutable } from '../core';
|
|
3
|
+
import NativeReanimated from '../NativeReanimated';
|
|
4
|
+
export var SensorType;
|
|
5
|
+
(function (SensorType) {
|
|
6
|
+
SensorType[SensorType["ACCELEROMETER"] = 1] = "ACCELEROMETER";
|
|
7
|
+
SensorType[SensorType["GYROSCOPE"] = 2] = "GYROSCOPE";
|
|
8
|
+
SensorType[SensorType["GRAVITY"] = 3] = "GRAVITY";
|
|
9
|
+
SensorType[SensorType["MAGNETIC_FIELD"] = 4] = "MAGNETIC_FIELD";
|
|
10
|
+
SensorType[SensorType["ROTATION"] = 5] = "ROTATION";
|
|
11
|
+
})(SensorType || (SensorType = {}));
|
|
12
|
+
export function useAnimatedSensor(sensorType, userConfig) {
|
|
13
|
+
const ref = useRef({
|
|
14
|
+
sensor: null,
|
|
15
|
+
unregister: () => {
|
|
16
|
+
// NOOP
|
|
17
|
+
},
|
|
18
|
+
isAvailable: false,
|
|
19
|
+
config: {
|
|
20
|
+
interval: 0,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
if (ref.current.sensor === null) {
|
|
24
|
+
ref.current.config = Object.assign({ interval: 10 }, userConfig);
|
|
25
|
+
let sensorData;
|
|
26
|
+
if (sensorType === SensorType.ROTATION) {
|
|
27
|
+
sensorData = {
|
|
28
|
+
qw: 0,
|
|
29
|
+
qx: 0,
|
|
30
|
+
qy: 0,
|
|
31
|
+
qz: 0,
|
|
32
|
+
yaw: 0,
|
|
33
|
+
pitch: 0,
|
|
34
|
+
roll: 0,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
sensorData = {
|
|
39
|
+
x: 0,
|
|
40
|
+
y: 0,
|
|
41
|
+
z: 0,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
ref.current.sensor = makeMutable(sensorData);
|
|
45
|
+
}
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
ref.current.config = Object.assign({ interval: 10 }, userConfig);
|
|
48
|
+
const id = NativeReanimated.registerSensor(sensorType, ref.current.config.interval, ref.current.sensor);
|
|
49
|
+
if (id !== -1) {
|
|
50
|
+
// if sensor is available
|
|
51
|
+
ref.current.unregister = () => NativeReanimated.unregisterSensor(id);
|
|
52
|
+
ref.current.isAvailable = true;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// if sensor is unavailable
|
|
56
|
+
ref.current.unregister = () => {
|
|
57
|
+
// NOOP
|
|
58
|
+
};
|
|
59
|
+
ref.current.isAvailable = false;
|
|
60
|
+
}
|
|
61
|
+
return () => {
|
|
62
|
+
ref.current.unregister();
|
|
63
|
+
};
|
|
64
|
+
}, [sensorType, userConfig]);
|
|
65
|
+
return ref.current;
|
|
66
|
+
}
|
|
@@ -164,7 +164,11 @@ function styleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsA
|
|
|
164
164
|
else {
|
|
165
165
|
state.isAnimationCancelled = true;
|
|
166
166
|
state.animations = [];
|
|
167
|
-
|
|
167
|
+
const diff = styleDiff(oldValues, newValues);
|
|
168
|
+
state.last = Object.assign({}, oldValues, newValues);
|
|
169
|
+
if (diff) {
|
|
170
|
+
updateProps(viewDescriptors, newValues, maybeViewRef);
|
|
171
|
+
}
|
|
168
172
|
}
|
|
169
173
|
}
|
|
170
174
|
function jestStyleUpdater(viewDescriptors, updater, state, maybeViewRef, animationsActive, animatedStyle, adapters = []) {
|
|
@@ -305,10 +309,10 @@ export function useAnimatedStyle(updater, dependencies, adapters) {
|
|
|
305
309
|
const maybeViewRef = NativeReanimatedModule.native ? undefined : viewsRef;
|
|
306
310
|
useEffect(() => {
|
|
307
311
|
let fun;
|
|
308
|
-
let
|
|
312
|
+
let updaterFn = updater;
|
|
309
313
|
let optimalization = updater.__optimalization;
|
|
310
314
|
if (adapters) {
|
|
311
|
-
|
|
315
|
+
updaterFn = () => {
|
|
312
316
|
'worklet';
|
|
313
317
|
const newValues = updater();
|
|
314
318
|
adaptersArray.forEach((adapter) => {
|
|
@@ -317,27 +321,40 @@ export function useAnimatedStyle(updater, dependencies, adapters) {
|
|
|
317
321
|
return newValues;
|
|
318
322
|
};
|
|
319
323
|
}
|
|
320
|
-
if (canApplyOptimalisation(
|
|
321
|
-
if (hasColorProps(
|
|
322
|
-
|
|
324
|
+
if (canApplyOptimalisation(updaterFn) && !shouldBeUseWeb()) {
|
|
325
|
+
if (hasColorProps(updaterFn())) {
|
|
326
|
+
updaterFn = () => {
|
|
327
|
+
'worklet';
|
|
328
|
+
const newValues = updaterFn();
|
|
329
|
+
const oldValues = remoteState.last;
|
|
330
|
+
const diff = styleDiff(oldValues, newValues);
|
|
331
|
+
remoteState.last = Object.assign({}, oldValues, newValues);
|
|
332
|
+
parseColors(diff);
|
|
333
|
+
return diff;
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
updaterFn = () => {
|
|
323
338
|
'worklet';
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
339
|
+
const newValues = updaterFn();
|
|
340
|
+
const oldValues = remoteState.last;
|
|
341
|
+
const diff = styleDiff(oldValues, newValues);
|
|
342
|
+
remoteState.last = Object.assign({}, oldValues, newValues);
|
|
343
|
+
return diff;
|
|
327
344
|
};
|
|
328
345
|
}
|
|
329
346
|
}
|
|
330
347
|
else if (!shouldBeUseWeb()) {
|
|
331
348
|
optimalization = 0;
|
|
332
|
-
|
|
349
|
+
updaterFn = () => {
|
|
333
350
|
'worklet';
|
|
334
|
-
const style =
|
|
351
|
+
const style = updaterFn();
|
|
335
352
|
parseColors(style);
|
|
336
353
|
return style;
|
|
337
354
|
};
|
|
338
355
|
}
|
|
339
356
|
if (typeof updater.__optimalization !== undefined) {
|
|
340
|
-
|
|
357
|
+
updaterFn.__optimalization = optimalization;
|
|
341
358
|
}
|
|
342
359
|
if (isJest()) {
|
|
343
360
|
fun = () => {
|
|
@@ -348,10 +365,10 @@ export function useAnimatedStyle(updater, dependencies, adapters) {
|
|
|
348
365
|
else {
|
|
349
366
|
fun = () => {
|
|
350
367
|
'worklet';
|
|
351
|
-
styleUpdater(sharableViewDescriptors,
|
|
368
|
+
styleUpdater(sharableViewDescriptors, updaterFn, remoteState, maybeViewRef, animationsActive);
|
|
352
369
|
};
|
|
353
370
|
}
|
|
354
|
-
const mapperId = startMapper(fun, inputs, [],
|
|
371
|
+
const mapperId = startMapper(fun, inputs, [], updaterFn,
|
|
355
372
|
// TODO fix this
|
|
356
373
|
sharableViewDescriptors);
|
|
357
374
|
return () => {
|