react-native-reanimated 2.3.0-beta.3 → 2.4.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/NativeModules/NativeReanimatedModule.cpp +9 -0
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +13 -0
- package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +38 -2
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +3 -0
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +5 -0
- package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +2 -0
- package/Common/cpp/headers/Tools/RuntimeDecorator.h +8 -7
- package/README.md +1 -1
- package/RNReanimated.podspec +20 -3
- package/android/build.gradle +31 -5
- package/android/expo/linking.gradle +46 -0
- package/android/expo/src/main/java/com/swmansion/reanimated/EXReanimatedAdapter.java +12 -0
- package/android/expo/src/main/java/expo/modules/adapters/reanimated/EXReanimatedPackage.java +26 -0
- package/android/react-native-reanimated-63-hermes.aar +0 -0
- package/android/react-native-reanimated-63-jsc.aar +0 -0
- package/android/react-native-reanimated-64-hermes.aar +0 -0
- package/android/react-native-reanimated-64-jsc.aar +0 -0
- package/android/react-native-reanimated-65-hermes.aar +0 -0
- package/android/react-native-reanimated-65-jsc.aar +0 -0
- package/android/react-native-reanimated-66-hermes.aar +0 -0
- package/android/react-native-reanimated-66-jsc.aar +0 -0
- package/android/react-native-reanimated-67-hermes.aar +0 -0
- package/android/react-native-reanimated-67-jsc.aar +0 -0
- package/expo-module.config.json +3 -0
- package/ios/LayoutReanimation/REAAnimationsManager.h +1 -1
- package/ios/LayoutReanimation/REAAnimationsManager.m +68 -19
- package/ios/LayoutReanimation/REAUIManager.mm +63 -18
- package/ios/Nodes/REAPropsNode.m +1 -1
- package/ios/REAEventDispatcher.m +1 -1
- package/ios/REAModule.h +0 -2
- package/ios/REAModule.m +0 -3
- package/ios/REANodesManager.m +1 -0
- package/ios/RNGestureHandlerStateManager.h +5 -0
- package/ios/native/NativeMethods.h +5 -0
- package/ios/native/NativeMethods.mm +8 -1
- package/ios/native/NativeProxy.h +1 -0
- package/ios/native/NativeProxy.mm +19 -3
- package/ios/native/REAInitializer.mm +7 -3
- package/lib/src/Animated.js +31 -0
- package/lib/{ConfigHelper.js → src/ConfigHelper.js} +0 -0
- package/lib/{ReanimatedEventEmitter.js → src/ReanimatedEventEmitter.js} +0 -0
- package/lib/{ReanimatedModule.js → src/ReanimatedModule.js} +0 -0
- package/lib/{ReanimatedModule.macos.js → src/ReanimatedModule.macos.js} +0 -0
- package/lib/{ReanimatedModule.native.js → src/ReanimatedModule.native.js} +0 -0
- package/lib/{ReanimatedModule.windows.js → src/ReanimatedModule.windows.js} +0 -0
- package/lib/{ReanimatedModuleCompat.js → src/ReanimatedModuleCompat.js} +0 -0
- package/lib/{__mocks__ → src/__mocks__}/ReanimatedEventEmitter.js +0 -0
- package/lib/{__mocks__ → src/__mocks__}/ReanimatedModule.native.js +0 -0
- package/lib/{createAnimatedComponent.js → src/createAnimatedComponent.js} +55 -37
- package/lib/src/index.js +31 -0
- package/lib/{reanimated1 → src/reanimated1}/Easing.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/SpringConfig.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/Transitioning.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/Animation.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/SpringUtils.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/backwardCompatibleAnimWrapper.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/decay.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/spring.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/animations/timing.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/base.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedAlways.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedBezier.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedBlock.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCall.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCallFunc.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedClock.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedClockTest.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCode.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedConcat.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedCond.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedDebug.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedEvent.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedFunction.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedNode.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedOperator.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedParam.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedProps.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedSet.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStartClock.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStopClock.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedStyle.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedTransform.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/AnimatedValue.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/Core.test.js +1 -1
- package/lib/{reanimated1 → src/reanimated1}/core/InternalAnimatedValue.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/__mocks__/AnimatedProps.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/core/createEventObjectProxyPolyfill.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/__mocks__/evaluateOnce.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/acc.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/color.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/diff.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/diffClamp.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/evaluateOnce.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/index.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/interpolate.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/interpolateColors.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/onChange.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/derived/useCode.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/index.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/operators.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/useValue.js +0 -0
- package/lib/{reanimated1 → src/reanimated1}/val.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/Bezier.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/Colors.js +1 -97
- package/lib/{reanimated2 → src/reanimated2}/Easing.js +5 -0
- package/lib/src/reanimated2/NativeMethods.js +42 -0
- package/lib/{reanimated2 → src/reanimated2}/NativeReanimated/NativeReanimated.js +3 -0
- package/lib/{reanimated2 → src/reanimated2}/NativeReanimated/index.js +2 -2
- package/lib/{reanimated2 → src/reanimated2}/PlatformChecker.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/PropAdapters.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/UpdateProps.js +1 -1
- package/lib/{reanimated2 → src/reanimated2}/ViewDescriptorsSet.js +4 -2
- package/lib/{reanimated2 → src/reanimated2}/WorkletEventHandler.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/__mocks__/MutableValue.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/__mocks__/NativeReanimated.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/__mocks__/NativeReanimated.native.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/commonTypes.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/decay.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/delay.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/repeat.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/sequence.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/spring.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/styleAnimation.js +5 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/timing.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/animation/util.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/commonTypes.js +0 -0
- package/lib/src/reanimated2/component/FlatList.js +30 -0
- package/lib/src/reanimated2/component/WrappedComponents.js +9 -0
- package/lib/src/reanimated2/component/index.js +4 -0
- package/lib/{reanimated2 → src/reanimated2}/core.js +27 -3
- package/lib/{reanimated2 → src/reanimated2}/globals.d.ts +5 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/Hooks.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/commonTypes.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedGestureHandler.js +1 -2
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedReaction.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedRef.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedScrollHandler.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useAnimatedStyle.js +31 -14
- package/lib/{reanimated2 → src/reanimated2}/hook/useDerivedValue.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/useSharedValue.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/hook/utils.js +14 -11
- package/lib/{reanimated2 → src/reanimated2}/index.js +2 -0
- package/lib/src/reanimated2/interpolateColor.js +98 -0
- package/lib/{reanimated2 → src/reanimated2}/interpolation.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/jestUtils.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/JSReanimated.js +4 -1
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/Mapper.js +4 -1
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/MapperRegistry.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/MutableValue.js +0 -0
- package/lib/{reanimated2/layoutReanimation/animationBuilder → src/reanimated2/js-reanimated}/commonTypes.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/js-reanimated/index.js +3 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/LayoutAnimationRepository.js +14 -5
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/Keyframe.js +0 -0
- package/lib/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +1 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/animationBuilder/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Bounce.js +0 -0
- package/lib/src/reanimated2/layoutReanimation/defaultAnimations/Default.js +36 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Fade.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Flip.js +8 -8
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Lightspeed.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Pinwheel.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Roll.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Rotate.js +16 -16
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Slide.js +16 -16
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Stretch.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/Zoom.js +4 -4
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultAnimations/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/CurvedTransition.js +20 -8
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/EntryExitTransition.js +3 -3
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/FadingTransition.js +8 -8
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/JumpingTransition.js +10 -10
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/LinearTransition.js +8 -8
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -8
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/defaultTransitions/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/layoutReanimation/index.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/mock.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/platform-specific/RNRenderer.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/platform-specific/RNRenderer.web.js +0 -0
- package/lib/{reanimated2 → src/reanimated2}/utils.js +0 -0
- package/lib/{setAndForwardRef.js → src/setAndForwardRef.js} +0 -0
- package/mock.js +2 -1
- package/package.json +7 -4
- package/plugin.js +11 -3
- package/react-native-reanimated.d.ts +94 -23
- package/src/Animated.js +11 -5
- package/src/createAnimatedComponent.tsx +86 -43
- package/src/reanimated1/core/Core.test.js +1 -1
- package/src/reanimated2/Colors.ts +6 -150
- package/src/reanimated2/Easing.ts +11 -0
- package/src/reanimated2/NativeMethods.ts +31 -6
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +5 -0
- package/src/reanimated2/NativeReanimated/index.ts +2 -2
- package/src/reanimated2/UpdateProps.ts +1 -1
- package/src/reanimated2/ViewDescriptorsSet.ts +6 -2
- package/src/reanimated2/animation/commonTypes.ts +44 -40
- package/src/reanimated2/animation/decay.ts +1 -1
- package/src/reanimated2/animation/delay.ts +2 -16
- package/src/reanimated2/animation/index.ts +7 -8
- package/src/reanimated2/animation/repeat.ts +2 -12
- package/src/reanimated2/animation/sequence.ts +3 -10
- package/src/reanimated2/animation/spring.ts +1 -1
- package/src/reanimated2/animation/styleAnimation.ts +10 -18
- package/src/reanimated2/animation/timing.ts +1 -1
- package/src/reanimated2/animation/util.ts +12 -9
- package/src/reanimated2/commonTypes.ts +48 -1
- package/src/reanimated2/component/FlatList.tsx +44 -0
- package/src/reanimated2/component/WrappedComponents.ts +11 -0
- package/src/reanimated2/component/index.ts +9 -0
- package/src/reanimated2/core.ts +39 -6
- package/src/reanimated2/globals.d.ts +5 -0
- package/src/reanimated2/hook/commonTypes.ts +5 -0
- package/src/reanimated2/hook/useAnimatedGestureHandler.ts +1 -2
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -5
- package/src/reanimated2/hook/useAnimatedStyle.ts +35 -16
- package/src/reanimated2/hook/utils.ts +18 -17
- package/src/reanimated2/index.ts +2 -0
- package/src/reanimated2/interpolateColor.ts +178 -0
- package/src/reanimated2/js-reanimated/JSReanimated.ts +9 -4
- package/src/reanimated2/js-reanimated/Mapper.ts +4 -2
- package/src/reanimated2/js-reanimated/MapperRegistry.ts +1 -1
- package/src/reanimated2/js-reanimated/commonTypes.ts +51 -0
- package/src/reanimated2/js-reanimated/index.ts +5 -0
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +18 -5
- 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 +49 -34
- 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 +15 -11
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +8 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +20 -14
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +14 -8
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +24 -12
- package/src/reanimated2/utils.ts +1 -1
- package/lib/Animated.js +0 -25
- package/lib/index.js +0 -25
- package/lib/reanimated2/NativeMethods.js +0 -25
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +0 -36
|
@@ -17,18 +17,26 @@ import './reanimated2/layoutReanimation/LayoutAnimationRepository';
|
|
|
17
17
|
import invariant from 'invariant';
|
|
18
18
|
import { adaptViewConfig } from './ConfigHelper';
|
|
19
19
|
import { RNRenderer } from './reanimated2/platform-specific/RNRenderer';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
makeMutable,
|
|
22
|
+
runOnUI,
|
|
23
|
+
enableLayoutAnimations,
|
|
24
|
+
} from './reanimated2/core';
|
|
21
25
|
import {
|
|
22
26
|
DefaultEntering,
|
|
23
27
|
DefaultExiting,
|
|
24
28
|
DefaultLayout,
|
|
25
29
|
} from './reanimated2/layoutReanimation/defaultAnimations/Default';
|
|
26
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
isJest,
|
|
32
|
+
isChromeDebugger,
|
|
33
|
+
shouldBeUseWeb,
|
|
34
|
+
} from './reanimated2/PlatformChecker';
|
|
27
35
|
import { initialUpdaterRun } from './reanimated2/animation';
|
|
28
36
|
import {
|
|
29
37
|
BaseAnimationBuilder,
|
|
30
38
|
EntryExitAnimationFunction,
|
|
31
|
-
|
|
39
|
+
ILayoutAnimationBuilder,
|
|
32
40
|
} from './reanimated2/layoutReanimation';
|
|
33
41
|
import { SharedValue, StyleProps } from './reanimated2/commonTypes';
|
|
34
42
|
import {
|
|
@@ -88,6 +96,21 @@ function flattenArray<T>(array: NestedArray<T>): T[] {
|
|
|
88
96
|
return resultArr;
|
|
89
97
|
}
|
|
90
98
|
|
|
99
|
+
function onlyAnimatedStyles(styles: StyleProps[]) {
|
|
100
|
+
return styles.filter((style) => style?.viewDescriptors);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function isSameAnimatedStyle(
|
|
104
|
+
style1?: StyleProps,
|
|
105
|
+
style2?: StyleProps
|
|
106
|
+
): boolean {
|
|
107
|
+
// We cannot use equality check to compare useAnimatedStyle outputs directly.
|
|
108
|
+
// Instead, we can compare its viewsRefs.
|
|
109
|
+
return style1?.viewsRef === style2?.viewsRef;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const isSameAnimatedProps = isSameAnimatedStyle;
|
|
113
|
+
|
|
91
114
|
const has = <K extends string>(
|
|
92
115
|
key: K,
|
|
93
116
|
x: unknown
|
|
@@ -115,7 +138,7 @@ export type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
|
|
|
115
138
|
animatedStyle?: StyleProps;
|
|
116
139
|
layout?:
|
|
117
140
|
| BaseAnimationBuilder
|
|
118
|
-
|
|
|
141
|
+
| ILayoutAnimationBuilder
|
|
119
142
|
| typeof BaseAnimationBuilder;
|
|
120
143
|
entering?:
|
|
121
144
|
| BaseAnimationBuilder
|
|
@@ -167,6 +190,7 @@ export default function createAnimatedComponent(
|
|
|
167
190
|
> {
|
|
168
191
|
_invokeAnimatedPropsCallbackOnMount = false;
|
|
169
192
|
_styles: StyleProps[] | null = null;
|
|
193
|
+
_animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
|
|
170
194
|
_viewTag = -1;
|
|
171
195
|
_isFirstRender = true;
|
|
172
196
|
animatedStyle: { value: StyleProps } = { value: {} };
|
|
@@ -255,9 +279,7 @@ export default function createAnimatedComponent(
|
|
|
255
279
|
}
|
|
256
280
|
} else if (this._viewTag !== -1 && this._styles !== null) {
|
|
257
281
|
for (const style of this._styles) {
|
|
258
|
-
|
|
259
|
-
style.viewDescriptors.remove(this._viewTag);
|
|
260
|
-
}
|
|
282
|
+
style.viewDescriptors.remove(this._viewTag);
|
|
261
283
|
}
|
|
262
284
|
if (this.props.animatedProps?.viewDescriptors) {
|
|
263
285
|
this.props.animatedProps.viewDescriptors.remove(this._viewTag);
|
|
@@ -387,8 +409,15 @@ export default function createAnimatedComponent(
|
|
|
387
409
|
}
|
|
388
410
|
|
|
389
411
|
_attachAnimatedStyles() {
|
|
390
|
-
const styles =
|
|
412
|
+
const styles = this.props.style
|
|
413
|
+
? onlyAnimatedStyles(flattenArray<StyleProps>(this.props.style))
|
|
414
|
+
: [];
|
|
415
|
+
const prevStyles = this._styles;
|
|
391
416
|
this._styles = styles;
|
|
417
|
+
|
|
418
|
+
const prevAnimatedProps = this._animatedProps;
|
|
419
|
+
this._animatedProps = this.props.animatedProps;
|
|
420
|
+
|
|
392
421
|
let viewTag: number | null;
|
|
393
422
|
let viewName: string | null;
|
|
394
423
|
if (Platform.OS === 'web') {
|
|
@@ -410,34 +439,60 @@ export default function createAnimatedComponent(
|
|
|
410
439
|
*/
|
|
411
440
|
viewName = hostInstance?.viewConfig?.uiViewClassName;
|
|
412
441
|
// update UI props whitelist for this view
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
hostInstance.viewConfig
|
|
417
|
-
) {
|
|
442
|
+
const hasReanimated2Props =
|
|
443
|
+
this.props.animatedProps?.viewDescriptors || styles.length;
|
|
444
|
+
if (hasReanimated2Props && hostInstance?.viewConfig) {
|
|
418
445
|
adaptViewConfig(hostInstance.viewConfig);
|
|
419
446
|
}
|
|
420
447
|
}
|
|
421
448
|
this._viewTag = viewTag as number;
|
|
422
449
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
450
|
+
// remove old styles
|
|
451
|
+
if (prevStyles) {
|
|
452
|
+
// in most of the cases, views have only a single animated style and it remains unchanged
|
|
453
|
+
const hasOneSameStyle =
|
|
454
|
+
styles.length === 1 &&
|
|
455
|
+
prevStyles.length === 1 &&
|
|
456
|
+
isSameAnimatedStyle(styles[0], prevStyles[0]);
|
|
457
|
+
|
|
458
|
+
if (!hasOneSameStyle) {
|
|
459
|
+
// otherwise, remove each style that is not present in new styles
|
|
460
|
+
for (const prevStyle of prevStyles) {
|
|
461
|
+
const isPresent = styles.some((style) =>
|
|
462
|
+
isSameAnimatedStyle(style, prevStyle)
|
|
463
|
+
);
|
|
464
|
+
if (!isPresent) {
|
|
465
|
+
prevStyle.viewDescriptors.remove(viewTag);
|
|
466
|
+
}
|
|
438
467
|
}
|
|
439
468
|
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
styles.forEach((style) => {
|
|
472
|
+
style.viewDescriptors.add({ tag: viewTag, name: viewName });
|
|
473
|
+
if (isJest()) {
|
|
474
|
+
/**
|
|
475
|
+
* We need to connect Jest's TestObject instance whose contains just props object
|
|
476
|
+
* with the updateProps() function where we update the properties of the component.
|
|
477
|
+
* We can't update props object directly because TestObject contains a copy of props - look at render function:
|
|
478
|
+
* const props = this._filterNonAnimatedProps(this.props);
|
|
479
|
+
*/
|
|
480
|
+
this.animatedStyle.value = {
|
|
481
|
+
...this.animatedStyle.value,
|
|
482
|
+
...style.initial.value,
|
|
483
|
+
};
|
|
484
|
+
style.animatedStyle.current = this.animatedStyle;
|
|
485
|
+
}
|
|
440
486
|
});
|
|
487
|
+
|
|
488
|
+
// detach old animatedProps
|
|
489
|
+
if (
|
|
490
|
+
prevAnimatedProps &&
|
|
491
|
+
!isSameAnimatedProps(prevAnimatedProps, this.props.animatedProps)
|
|
492
|
+
) {
|
|
493
|
+
prevAnimatedProps.viewDescriptors!.remove(viewTag as number);
|
|
494
|
+
}
|
|
495
|
+
|
|
441
496
|
// attach animatedProps property
|
|
442
497
|
if (this.props.animatedProps?.viewDescriptors) {
|
|
443
498
|
this.props.animatedProps.viewDescriptors.add({
|
|
@@ -449,21 +504,6 @@ export default function createAnimatedComponent(
|
|
|
449
504
|
}
|
|
450
505
|
}
|
|
451
506
|
|
|
452
|
-
_hasReanimated2Props(flattenStyles: StyleProps[]) {
|
|
453
|
-
if (this.props.animatedProps?.viewDescriptors) {
|
|
454
|
-
return true;
|
|
455
|
-
}
|
|
456
|
-
if (this.props.style) {
|
|
457
|
-
for (const style of flattenStyles) {
|
|
458
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
459
|
-
if (style?.hasOwnProperty('viewDescriptors')) {
|
|
460
|
-
return true;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
return false;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
507
|
_detachPropUpdater() {
|
|
468
508
|
const viewTag = findNodeHandle(this);
|
|
469
509
|
NODE_MAPPING.delete(viewTag);
|
|
@@ -496,6 +536,9 @@ export default function createAnimatedComponent(
|
|
|
496
536
|
(this.props.layout || this.props.entering || this.props.exiting) &&
|
|
497
537
|
tag != null
|
|
498
538
|
) {
|
|
539
|
+
if (!shouldBeUseWeb()) {
|
|
540
|
+
enableLayoutAnimations(true, false);
|
|
541
|
+
}
|
|
499
542
|
let layout = this.props.layout ? this.props.layout : DefaultLayout;
|
|
500
543
|
let entering = this.props.entering
|
|
501
544
|
? this.props.entering
|
|
@@ -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', () => {
|
|
@@ -9,11 +9,8 @@
|
|
|
9
9
|
/* eslint no-bitwise: 0 */
|
|
10
10
|
import { Platform } from 'react-native';
|
|
11
11
|
import { makeRemote, makeShareable, isConfigured } from './core';
|
|
12
|
-
import { interpolate } from './interpolation';
|
|
13
|
-
// @ts-ignore JS file
|
|
14
|
-
import { Extrapolate } from '../reanimated1/derived';
|
|
15
12
|
|
|
16
|
-
interface
|
|
13
|
+
interface RGB {
|
|
17
14
|
r: number;
|
|
18
15
|
g: number;
|
|
19
16
|
b: number;
|
|
@@ -475,9 +472,9 @@ export const rgbaColor = (
|
|
|
475
472
|
* 0 <= r, g, b <= 255
|
|
476
473
|
* returns 0 <= h, s, v <= 1
|
|
477
474
|
*/
|
|
478
|
-
function RGBtoHSV(rgb:
|
|
479
|
-
function RGBtoHSV(r: number, g: number, b: number): HSV;
|
|
480
|
-
function RGBtoHSV(r: any, g?: any, b?: any): HSV {
|
|
475
|
+
export function RGBtoHSV(rgb: RGB): HSV;
|
|
476
|
+
export function RGBtoHSV(r: number, g: number, b: number): HSV;
|
|
477
|
+
export function RGBtoHSV(r: any, g?: any, b?: any): HSV {
|
|
481
478
|
'worklet';
|
|
482
479
|
/* eslint-disable */
|
|
483
480
|
if (arguments.length === 1) {
|
|
@@ -528,8 +525,8 @@ function RGBtoHSV(r: any, g?: any, b?: any): HSV {
|
|
|
528
525
|
* 0 <= h, s, v <= 1
|
|
529
526
|
* returns 0 <= r, g, b <= 255
|
|
530
527
|
*/
|
|
531
|
-
function HSVtoRGB(hsv: HSV):
|
|
532
|
-
function HSVtoRGB(h: number, s: number, v: number):
|
|
528
|
+
function HSVtoRGB(hsv: HSV): RGB;
|
|
529
|
+
function HSVtoRGB(h: number, s: number, v: number): RGB;
|
|
533
530
|
function HSVtoRGB(h: any, s?: any, v?: any) {
|
|
534
531
|
'worklet';
|
|
535
532
|
/* eslint-disable */
|
|
@@ -652,144 +649,3 @@ export function toRGBA(HSVA: ParsedColorArray): string {
|
|
|
652
649
|
const { r, g, b } = HSVtoRGB(HSVA[0], HSVA[1], HSVA[2]);
|
|
653
650
|
return `rgba(${r}, ${g}, ${b}, ${HSVA[3]})`;
|
|
654
651
|
}
|
|
655
|
-
|
|
656
|
-
const interpolateColorsHSV = (
|
|
657
|
-
value: number,
|
|
658
|
-
inputRange: readonly number[],
|
|
659
|
-
colors: InterpolateCacheHSV
|
|
660
|
-
) => {
|
|
661
|
-
'worklet';
|
|
662
|
-
const h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);
|
|
663
|
-
const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);
|
|
664
|
-
const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);
|
|
665
|
-
return hsvToColor(h, s, v);
|
|
666
|
-
};
|
|
667
|
-
|
|
668
|
-
const interpolateColorsRGB = (
|
|
669
|
-
value: number,
|
|
670
|
-
inputRange: readonly number[],
|
|
671
|
-
colors: InterpolateCacheRGBA
|
|
672
|
-
) => {
|
|
673
|
-
'worklet';
|
|
674
|
-
const r = interpolate(value, inputRange, colors.r, Extrapolate.CLAMP);
|
|
675
|
-
const g = interpolate(value, inputRange, colors.g, Extrapolate.CLAMP);
|
|
676
|
-
const b = interpolate(value, inputRange, colors.b, Extrapolate.CLAMP);
|
|
677
|
-
const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);
|
|
678
|
-
return rgbaColor(r, g, b, a);
|
|
679
|
-
};
|
|
680
|
-
|
|
681
|
-
interface InterpolateCacheRGBA {
|
|
682
|
-
r: number[];
|
|
683
|
-
g: number[];
|
|
684
|
-
b: number[];
|
|
685
|
-
a: number[];
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
const BUFFER_SIZE = 200;
|
|
689
|
-
const hashOrderRGBA: any = new ArrayBuffer(BUFFER_SIZE);
|
|
690
|
-
let curentHashIndexRGBA = 0;
|
|
691
|
-
const interpolateCacheRGBA: { [name: string]: InterpolateCacheRGBA } = {};
|
|
692
|
-
|
|
693
|
-
const getInterpolateCacheRGBA = (
|
|
694
|
-
colors: readonly (string | number)[]
|
|
695
|
-
): InterpolateCacheRGBA => {
|
|
696
|
-
'worklet';
|
|
697
|
-
const hash = colors.join('');
|
|
698
|
-
const cache = interpolateCacheRGBA[hash];
|
|
699
|
-
if (cache !== undefined) {
|
|
700
|
-
return cache;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
const r = [];
|
|
704
|
-
const g = [];
|
|
705
|
-
const b = [];
|
|
706
|
-
const a = [];
|
|
707
|
-
for (let i = 0; i < colors.length; ++i) {
|
|
708
|
-
const color = colors[i];
|
|
709
|
-
const proocessedColor = processColor(color);
|
|
710
|
-
// explicit check in case if processedColor is 0
|
|
711
|
-
if (proocessedColor !== null && proocessedColor !== undefined) {
|
|
712
|
-
r.push(red(proocessedColor));
|
|
713
|
-
g.push(green(proocessedColor));
|
|
714
|
-
b.push(blue(proocessedColor));
|
|
715
|
-
a.push(opacity(proocessedColor));
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
const newCache = { r, g, b, a };
|
|
719
|
-
const overrideHash = hashOrderRGBA[curentHashIndexRGBA];
|
|
720
|
-
if (overrideHash) {
|
|
721
|
-
delete interpolateCacheRGBA[overrideHash];
|
|
722
|
-
}
|
|
723
|
-
interpolateCacheRGBA[hash] = newCache;
|
|
724
|
-
hashOrderRGBA[curentHashIndexRGBA] = hash;
|
|
725
|
-
curentHashIndexRGBA = (curentHashIndexRGBA + 1) % BUFFER_SIZE;
|
|
726
|
-
return newCache;
|
|
727
|
-
};
|
|
728
|
-
|
|
729
|
-
interface InterpolateCacheHSV {
|
|
730
|
-
h: number[];
|
|
731
|
-
s: number[];
|
|
732
|
-
v: number[];
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
const hashOrderHSV: any = new ArrayBuffer(BUFFER_SIZE);
|
|
736
|
-
let curentHashIndexHSV = 0;
|
|
737
|
-
const interpolateCacheHSV: { [name: string]: InterpolateCacheHSV } = {};
|
|
738
|
-
|
|
739
|
-
const getInterpolateCacheHSV = (
|
|
740
|
-
colors: readonly (string | number)[]
|
|
741
|
-
): InterpolateCacheHSV => {
|
|
742
|
-
'worklet';
|
|
743
|
-
const hash = colors.join('');
|
|
744
|
-
const cache = interpolateCacheHSV[hash];
|
|
745
|
-
if (cache !== undefined) {
|
|
746
|
-
return cache;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
const h = [];
|
|
750
|
-
const s = [];
|
|
751
|
-
const v = [];
|
|
752
|
-
for (let i = 0; i < colors.length; ++i) {
|
|
753
|
-
const color = colors[i];
|
|
754
|
-
const proocessedColor = RGBtoHSV(processColor(color) as any);
|
|
755
|
-
if (proocessedColor) {
|
|
756
|
-
h.push(proocessedColor.h);
|
|
757
|
-
s.push(proocessedColor.s);
|
|
758
|
-
v.push(proocessedColor.v);
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
const newCache = { h, s, v };
|
|
762
|
-
const overrideHash = hashOrderHSV[curentHashIndexHSV];
|
|
763
|
-
if (overrideHash) {
|
|
764
|
-
delete interpolateCacheHSV[overrideHash];
|
|
765
|
-
}
|
|
766
|
-
interpolateCacheHSV[hash] = newCache;
|
|
767
|
-
hashOrderHSV[curentHashIndexHSV] = hash;
|
|
768
|
-
curentHashIndexHSV = (curentHashIndexHSV + 1) % BUFFER_SIZE;
|
|
769
|
-
return newCache;
|
|
770
|
-
};
|
|
771
|
-
|
|
772
|
-
export const interpolateColor = (
|
|
773
|
-
value: number,
|
|
774
|
-
inputRange: readonly number[],
|
|
775
|
-
outputRange: readonly (string | number)[],
|
|
776
|
-
colorSpace: 'RGB' | 'HSV' = 'RGB'
|
|
777
|
-
): string | number => {
|
|
778
|
-
'worklet';
|
|
779
|
-
if (colorSpace === 'HSV') {
|
|
780
|
-
return interpolateColorsHSV(
|
|
781
|
-
value,
|
|
782
|
-
inputRange,
|
|
783
|
-
getInterpolateCacheHSV(outputRange)
|
|
784
|
-
);
|
|
785
|
-
} else if (colorSpace === 'RGB') {
|
|
786
|
-
return interpolateColorsRGB(
|
|
787
|
-
value,
|
|
788
|
-
inputRange,
|
|
789
|
-
getInterpolateCacheRGBA(outputRange)
|
|
790
|
-
);
|
|
791
|
-
}
|
|
792
|
-
throw new Error(
|
|
793
|
-
`invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV']`
|
|
794
|
-
);
|
|
795
|
-
};
|
|
@@ -221,6 +221,16 @@ function bezier(
|
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
function bezierFn(
|
|
225
|
+
x1: number,
|
|
226
|
+
y1: number,
|
|
227
|
+
x2: number,
|
|
228
|
+
y2: number
|
|
229
|
+
): (x: number) => number {
|
|
230
|
+
'worklet';
|
|
231
|
+
return Bezier(x1, y1, x2, y2);
|
|
232
|
+
}
|
|
233
|
+
|
|
224
234
|
/**
|
|
225
235
|
* Runs an easing function forwards.
|
|
226
236
|
*/
|
|
@@ -269,6 +279,7 @@ const EasingObject = {
|
|
|
269
279
|
back,
|
|
270
280
|
bounce,
|
|
271
281
|
bezier,
|
|
282
|
+
bezierFn,
|
|
272
283
|
in: in_,
|
|
273
284
|
out,
|
|
274
285
|
inOut,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
/* global _WORKLET _measure _scrollTo */
|
|
1
|
+
/* global _WORKLET _measure _scrollTo _setGestureState */
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
|
+
// @ts-nocheck
|
|
2
4
|
import { Component } from 'react';
|
|
3
5
|
import { findNodeHandle } from 'react-native';
|
|
4
|
-
import { RefObjectFunction } from './
|
|
5
|
-
import {
|
|
6
|
+
import { RefObjectFunction } from './commonTypes';
|
|
7
|
+
import { shouldBeUseWeb } from './PlatformChecker';
|
|
6
8
|
|
|
7
9
|
export function getTag(
|
|
8
10
|
view: null | number | React.Component<any, any> | React.ComponentClass<any>
|
|
@@ -19,12 +21,24 @@ export interface MeasuredDimensions {
|
|
|
19
21
|
pageY: number;
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
const isNativeIndefined = shouldBeUseWeb();
|
|
25
|
+
|
|
22
26
|
export function measure(
|
|
23
27
|
animatedRef: RefObjectFunction<Component>
|
|
24
28
|
): MeasuredDimensions {
|
|
25
29
|
'worklet';
|
|
26
|
-
if (!_WORKLET
|
|
27
|
-
|
|
30
|
+
if (!_WORKLET || isNativeIndefined) {
|
|
31
|
+
console.warn(
|
|
32
|
+
'[reanimated.measure] method cannot be used for web or Chrome Debugger'
|
|
33
|
+
);
|
|
34
|
+
return {
|
|
35
|
+
x: NaN,
|
|
36
|
+
y: NaN,
|
|
37
|
+
width: NaN,
|
|
38
|
+
height: NaN,
|
|
39
|
+
pageX: NaN,
|
|
40
|
+
pageY: NaN,
|
|
41
|
+
};
|
|
28
42
|
}
|
|
29
43
|
const viewTag = animatedRef();
|
|
30
44
|
const result = _measure(viewTag);
|
|
@@ -41,9 +55,20 @@ export function scrollTo(
|
|
|
41
55
|
animated: boolean
|
|
42
56
|
): void {
|
|
43
57
|
'worklet';
|
|
44
|
-
if (!_WORKLET
|
|
58
|
+
if (!_WORKLET || isNativeIndefined) {
|
|
45
59
|
return;
|
|
46
60
|
}
|
|
47
61
|
const viewTag = animatedRef();
|
|
48
62
|
_scrollTo(viewTag, x, y, animated);
|
|
49
63
|
}
|
|
64
|
+
|
|
65
|
+
export function setGestureState(handlerTag: number, newState: number): void {
|
|
66
|
+
'worklet';
|
|
67
|
+
if (!_WORKLET || isNativeIndefined) {
|
|
68
|
+
console.warn(
|
|
69
|
+
'[Reanimated] You can not use setGestureState in non-worklet function.'
|
|
70
|
+
);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
_setGestureState(handlerTag, newState);
|
|
74
|
+
}
|
|
@@ -2,6 +2,7 @@ import { SharedValue } from '../commonTypes';
|
|
|
2
2
|
import { Descriptor } from '../hook/commonTypes';
|
|
3
3
|
|
|
4
4
|
const InnerNativeModule = global.__reanimatedModuleProxy;
|
|
5
|
+
|
|
5
6
|
export class NativeReanimated {
|
|
6
7
|
native: boolean;
|
|
7
8
|
useOnlyV1: boolean;
|
|
@@ -65,4 +66,8 @@ export class NativeReanimated {
|
|
|
65
66
|
): Promise<T> {
|
|
66
67
|
return InnerNativeModule.getViewProp(viewTag, propName, callback);
|
|
67
68
|
}
|
|
69
|
+
|
|
70
|
+
enableLayoutAnimations(flag: boolean): void {
|
|
71
|
+
InnerNativeModule.enableLayoutAnimations(flag);
|
|
72
|
+
}
|
|
68
73
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import reanimatedJS from '../js-reanimated';
|
|
2
|
-
import {
|
|
2
|
+
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
3
3
|
import { Platform } from 'react-native';
|
|
4
4
|
import { NativeReanimated } from './NativeReanimated';
|
|
5
5
|
|
|
6
6
|
let exportedModule;
|
|
7
|
-
if (
|
|
7
|
+
if (shouldBeUseWeb()) {
|
|
8
8
|
exportedModule = reanimatedJS;
|
|
9
9
|
} else {
|
|
10
10
|
exportedModule = new NativeReanimated();
|
|
@@ -26,7 +26,7 @@ export const colorProps = [
|
|
|
26
26
|
'overlayColor',
|
|
27
27
|
];
|
|
28
28
|
|
|
29
|
-
const ColorProperties = !isConfigured() ? [] : makeShareable(colorProps);
|
|
29
|
+
export const ColorProperties = !isConfigured() ? [] : makeShareable(colorProps);
|
|
30
30
|
|
|
31
31
|
let updatePropsByPlatform;
|
|
32
32
|
if (shouldBeUseWeb()) {
|
|
@@ -2,6 +2,7 @@ import { useRef } from 'react';
|
|
|
2
2
|
import { makeMutable } from './core';
|
|
3
3
|
import { SharedValue } from './commonTypes';
|
|
4
4
|
import { Descriptor } from './hook/commonTypes';
|
|
5
|
+
import { Platform } from 'react-native';
|
|
5
6
|
|
|
6
7
|
export interface ViewRefSet<T> {
|
|
7
8
|
items: Set<T>;
|
|
@@ -23,6 +24,9 @@ export interface ViewDescriptorsSet {
|
|
|
23
24
|
) => void;
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
const scheduleUpdates =
|
|
28
|
+
Platform.OS === 'web' ? requestAnimationFrame : setImmediate;
|
|
29
|
+
|
|
26
30
|
export function makeViewDescriptorsSet(): ViewDescriptorsSet {
|
|
27
31
|
const ref = useRef<ViewDescriptorsSet | null>(null);
|
|
28
32
|
if (ref.current === null) {
|
|
@@ -44,7 +48,7 @@ export function makeViewDescriptorsSet(): ViewDescriptorsSet {
|
|
|
44
48
|
if (!data.waitForInsertSync) {
|
|
45
49
|
data.waitForInsertSync = true;
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
scheduleUpdates(() => {
|
|
48
52
|
data.sharableViewDescriptors.value = data.items;
|
|
49
53
|
data.waitForInsertSync = false;
|
|
50
54
|
});
|
|
@@ -57,7 +61,7 @@ export function makeViewDescriptorsSet(): ViewDescriptorsSet {
|
|
|
57
61
|
if (!data.waitForRemoveSync) {
|
|
58
62
|
data.waitForRemoveSync = true;
|
|
59
63
|
|
|
60
|
-
|
|
64
|
+
scheduleUpdates(() => {
|
|
61
65
|
const items = [];
|
|
62
66
|
for (const item of data.items) {
|
|
63
67
|
if (data.batchToRemove.has(item.tag)) {
|
|
@@ -1,48 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
AnimatedStyle,
|
|
3
|
+
StyleProps,
|
|
4
|
+
AnimatableValue,
|
|
5
|
+
AnimationObject,
|
|
6
|
+
Animation,
|
|
7
|
+
Timestamp,
|
|
8
|
+
AnimationCallback,
|
|
9
|
+
} from '../commonTypes';
|
|
2
10
|
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
callback: AnimationCallback;
|
|
6
|
-
current?: AnimatableValue;
|
|
7
|
-
toValue?: AnimationObject['current'];
|
|
8
|
-
startValue?: AnimationObject['current'];
|
|
9
|
-
finished?: boolean;
|
|
10
|
-
strippedCurrent?: number;
|
|
11
|
-
cancelled?: boolean;
|
|
12
|
-
|
|
13
|
-
__prefix?: string;
|
|
14
|
-
__suffix?: string;
|
|
15
|
-
onFrame: (animation: any, timestamp: Timestamp) => boolean;
|
|
16
|
-
onStart: (
|
|
17
|
-
nextAnimation: any,
|
|
18
|
-
current: any,
|
|
19
|
-
timestamp: Timestamp,
|
|
20
|
-
previousAnimation: any
|
|
21
|
-
) => void;
|
|
11
|
+
export interface HigherOrderAnimation {
|
|
12
|
+
isHigherOrder?: boolean;
|
|
22
13
|
}
|
|
23
14
|
|
|
24
|
-
export
|
|
25
|
-
onFrame: (animation: T, timestamp: Timestamp) => boolean;
|
|
26
|
-
onStart: (
|
|
27
|
-
nextAnimation: T,
|
|
28
|
-
current: T extends NumericAnimation ? number : AnimatableValue,
|
|
29
|
-
timestamp: Timestamp,
|
|
30
|
-
previousAnimation: T
|
|
31
|
-
) => void;
|
|
32
|
-
}
|
|
15
|
+
export type NextAnimation<T extends AnimationObject> = T | (() => T);
|
|
33
16
|
|
|
34
|
-
export interface
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
export interface DelayAnimation
|
|
18
|
+
extends Animation<DelayAnimation>,
|
|
19
|
+
HigherOrderAnimation {
|
|
20
|
+
startTime: Timestamp;
|
|
21
|
+
started: boolean;
|
|
22
|
+
previousAnimation: DelayAnimation | null;
|
|
23
|
+
current: AnimatableValue;
|
|
39
24
|
}
|
|
40
25
|
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
export interface RepeatAnimation
|
|
27
|
+
extends Animation<RepeatAnimation>,
|
|
28
|
+
HigherOrderAnimation {
|
|
29
|
+
reps: number;
|
|
30
|
+
startValue: AnimatableValue;
|
|
31
|
+
toValue?: AnimatableValue;
|
|
32
|
+
previousAnimation?: RepeatAnimation;
|
|
33
|
+
}
|
|
45
34
|
|
|
46
|
-
export
|
|
35
|
+
export interface SequenceAnimation
|
|
36
|
+
extends Animation<SequenceAnimation>,
|
|
37
|
+
HigherOrderAnimation {
|
|
38
|
+
animationIndex: number;
|
|
39
|
+
}
|
|
47
40
|
|
|
48
|
-
export
|
|
41
|
+
export interface StyleLayoutAnimation extends HigherOrderAnimation {
|
|
42
|
+
current: StyleProps;
|
|
43
|
+
styleAnimations: AnimatedStyle;
|
|
44
|
+
onFrame: (animation: StyleLayoutAnimation, timestamp: Timestamp) => boolean;
|
|
45
|
+
onStart: (
|
|
46
|
+
nextAnimation: StyleLayoutAnimation,
|
|
47
|
+
current: AnimatedStyle,
|
|
48
|
+
timestamp: Timestamp,
|
|
49
|
+
previousAnimation: StyleLayoutAnimation
|
|
50
|
+
) => void;
|
|
51
|
+
callback?: AnimationCallback;
|
|
52
|
+
}
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
import { defineAnimation } from './util';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
NextAnimation,
|
|
5
|
-
Timestamp,
|
|
6
|
-
HigherOrderAnimation,
|
|
7
|
-
AnimatableValue,
|
|
8
|
-
} from './commonTypes';
|
|
9
|
-
|
|
10
|
-
export interface DelayAnimation
|
|
11
|
-
extends Animation<DelayAnimation>,
|
|
12
|
-
HigherOrderAnimation {
|
|
13
|
-
startTime: Timestamp;
|
|
14
|
-
started: boolean;
|
|
15
|
-
previousAnimation: DelayAnimation | null;
|
|
16
|
-
current: AnimatableValue;
|
|
17
|
-
}
|
|
2
|
+
import { Animation, Timestamp, AnimatableValue } from '../commonTypes';
|
|
3
|
+
import { NextAnimation, DelayAnimation } from './commonTypes';
|
|
18
4
|
|
|
19
5
|
export function withDelay(
|
|
20
6
|
delayMs: number,
|