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
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
export {
|
|
2
|
-
AnimationObject,
|
|
3
|
-
Animation,
|
|
4
2
|
HigherOrderAnimation,
|
|
5
|
-
AnimationCallback,
|
|
6
3
|
NextAnimation,
|
|
7
|
-
|
|
4
|
+
RepeatAnimation,
|
|
5
|
+
SequenceAnimation,
|
|
6
|
+
StyleLayoutAnimation,
|
|
8
7
|
} from './commonTypes';
|
|
9
8
|
export { cancelAnimation, defineAnimation, initialUpdaterRun } from './util';
|
|
10
9
|
export { withTiming, TimingAnimation } from './timing';
|
|
11
10
|
export { withSpring, SpringAnimation } from './spring';
|
|
12
11
|
export { withDecay, DecayAnimation } from './decay';
|
|
13
|
-
export { withDelay
|
|
14
|
-
export { withRepeat
|
|
15
|
-
export { withSequence
|
|
16
|
-
export { withStyleAnimation
|
|
12
|
+
export { withDelay } from './delay';
|
|
13
|
+
export { withRepeat } from './repeat';
|
|
14
|
+
export { withSequence } from './sequence';
|
|
15
|
+
export { withStyleAnimation } from './styleAnimation';
|
|
@@ -2,20 +2,10 @@ import { defineAnimation } from './util';
|
|
|
2
2
|
import {
|
|
3
3
|
Animation,
|
|
4
4
|
AnimationCallback,
|
|
5
|
-
NextAnimation,
|
|
6
5
|
AnimatableValue,
|
|
7
6
|
Timestamp,
|
|
8
|
-
|
|
9
|
-
} from './commonTypes';
|
|
10
|
-
|
|
11
|
-
export interface RepeatAnimation
|
|
12
|
-
extends Animation<RepeatAnimation>,
|
|
13
|
-
HigherOrderAnimation {
|
|
14
|
-
reps: number;
|
|
15
|
-
startValue: AnimatableValue;
|
|
16
|
-
toValue?: AnimatableValue;
|
|
17
|
-
previousAnimation?: RepeatAnimation;
|
|
18
|
-
}
|
|
7
|
+
} from '../commonTypes';
|
|
8
|
+
import { NextAnimation, RepeatAnimation } from './commonTypes';
|
|
19
9
|
|
|
20
10
|
export interface InnerRepeatAnimation
|
|
21
11
|
extends Omit<RepeatAnimation, 'toValue' | 'startValue'> {
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import { defineAnimation } from './util';
|
|
2
|
+
import { NextAnimation, SequenceAnimation } from './commonTypes';
|
|
2
3
|
import {
|
|
3
4
|
Animation,
|
|
4
|
-
Timestamp,
|
|
5
|
-
NextAnimation,
|
|
6
5
|
AnimatableValue,
|
|
7
|
-
HigherOrderAnimation,
|
|
8
6
|
AnimationObject,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export interface SequenceAnimation
|
|
12
|
-
extends Animation<SequenceAnimation>,
|
|
13
|
-
HigherOrderAnimation {
|
|
14
|
-
animationIndex: number;
|
|
15
|
-
}
|
|
7
|
+
Timestamp,
|
|
8
|
+
} from '../commonTypes';
|
|
16
9
|
|
|
17
10
|
export function withSequence(
|
|
18
11
|
..._animations: NextAnimation<AnimationObject>[]
|
|
@@ -1,32 +1,17 @@
|
|
|
1
1
|
import { defineAnimation } from './util';
|
|
2
2
|
import {
|
|
3
3
|
Timestamp,
|
|
4
|
-
HigherOrderAnimation,
|
|
5
|
-
AnimationCallback,
|
|
6
4
|
AnimatableValue,
|
|
7
5
|
AnimationObject,
|
|
8
6
|
Animation,
|
|
9
|
-
} from './commonTypes';
|
|
10
|
-
import {
|
|
11
7
|
AnimatedStyle,
|
|
12
8
|
NestedObject,
|
|
13
9
|
NestedObjectValues,
|
|
14
|
-
StyleProps,
|
|
15
10
|
} from '../commonTypes';
|
|
11
|
+
import { StyleLayoutAnimation } from './commonTypes';
|
|
16
12
|
import { withTiming } from './timing';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
current: StyleProps;
|
|
20
|
-
styleAnimations: AnimatedStyle;
|
|
21
|
-
onFrame: (animation: StyleLayoutAnimation, timestamp: Timestamp) => boolean;
|
|
22
|
-
onStart: (
|
|
23
|
-
nextAnimation: StyleLayoutAnimation,
|
|
24
|
-
current: AnimatedStyle,
|
|
25
|
-
timestamp: Timestamp,
|
|
26
|
-
previousAnimation: StyleLayoutAnimation
|
|
27
|
-
) => void;
|
|
28
|
-
callback?: AnimationCallback;
|
|
29
|
-
}
|
|
13
|
+
import { ColorProperties } from '../UpdateProps';
|
|
14
|
+
import { processColor } from '../Colors';
|
|
30
15
|
|
|
31
16
|
// resolves path to value for nested objects
|
|
32
17
|
// if path cannot be resolved returns undefined
|
|
@@ -134,6 +119,13 @@ export function withStyleAnimation(
|
|
|
134
119
|
} else {
|
|
135
120
|
stillGoing = true;
|
|
136
121
|
}
|
|
122
|
+
|
|
123
|
+
if (ColorProperties.includes(currentEntry.path[0] as string)) {
|
|
124
|
+
currentStyleAnimation.current = processColor(
|
|
125
|
+
currentStyleAnimation.current
|
|
126
|
+
) as number;
|
|
127
|
+
}
|
|
128
|
+
|
|
137
129
|
setPath(
|
|
138
130
|
animation.current,
|
|
139
131
|
currentEntry.path,
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Animation,
|
|
3
|
-
AnimationObject,
|
|
4
2
|
HigherOrderAnimation,
|
|
5
3
|
NextAnimation,
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
DelayAnimation,
|
|
5
|
+
RepeatAnimation,
|
|
6
|
+
SequenceAnimation,
|
|
7
|
+
StyleLayoutAnimation,
|
|
8
8
|
} from './commonTypes';
|
|
9
9
|
/* global _WORKLET */
|
|
10
10
|
import { ParsedColorArray, convertToHSVA, isColor, toRGBA } from '../Colors';
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
|
|
12
|
+
import {
|
|
13
|
+
AnimatedStyle,
|
|
14
|
+
SharedValue,
|
|
15
|
+
AnimatableValue,
|
|
16
|
+
Animation,
|
|
17
|
+
AnimationObject,
|
|
18
|
+
Timestamp,
|
|
19
|
+
} from '../commonTypes';
|
|
14
20
|
import NativeReanimatedModule from '../NativeReanimated';
|
|
15
|
-
import { RepeatAnimation } from './repeat';
|
|
16
|
-
import { SequenceAnimation } from './sequence';
|
|
17
|
-
import { StyleLayoutAnimation } from './styleAnimation';
|
|
18
21
|
|
|
19
22
|
let IN_STYLE_UPDATER = false;
|
|
20
23
|
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
ViewStyle,
|
|
16
16
|
TextStyle,
|
|
17
17
|
} from 'react-native';
|
|
18
|
-
import { Animation, AnimationObject } from './animation/commonTypes';
|
|
19
18
|
import { Context } from './hook/commonTypes';
|
|
20
19
|
|
|
21
20
|
export type TransformProperty =
|
|
@@ -59,6 +58,10 @@ export interface BasicWorkletFunction<T> extends WorkletFunction {
|
|
|
59
58
|
(): T;
|
|
60
59
|
}
|
|
61
60
|
|
|
61
|
+
export interface BasicWorkletFunctionOptional<T> extends WorkletFunction {
|
|
62
|
+
(): Partial<T>;
|
|
63
|
+
}
|
|
64
|
+
|
|
62
65
|
export interface NativeEvent<T> {
|
|
63
66
|
nativeEvent: T;
|
|
64
67
|
}
|
|
@@ -79,3 +82,47 @@ export type NestedObjectValues<T> =
|
|
|
79
82
|
export interface AdapterWorkletFunction extends WorkletFunction {
|
|
80
83
|
(value: NestedObject<string | number | AnimationObject>): void;
|
|
81
84
|
}
|
|
85
|
+
|
|
86
|
+
export type AnimatableValue = number | string | Array<number>;
|
|
87
|
+
|
|
88
|
+
export interface AnimationObject {
|
|
89
|
+
[key: string]: any;
|
|
90
|
+
callback: AnimationCallback;
|
|
91
|
+
current?: AnimatableValue;
|
|
92
|
+
toValue?: AnimationObject['current'];
|
|
93
|
+
startValue?: AnimationObject['current'];
|
|
94
|
+
finished?: boolean;
|
|
95
|
+
strippedCurrent?: number;
|
|
96
|
+
cancelled?: boolean;
|
|
97
|
+
|
|
98
|
+
__prefix?: string;
|
|
99
|
+
__suffix?: string;
|
|
100
|
+
onFrame: (animation: any, timestamp: Timestamp) => boolean;
|
|
101
|
+
onStart: (
|
|
102
|
+
nextAnimation: any,
|
|
103
|
+
current: any,
|
|
104
|
+
timestamp: Timestamp,
|
|
105
|
+
previousAnimation: any
|
|
106
|
+
) => void;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface Animation<T extends AnimationObject> extends AnimationObject {
|
|
110
|
+
onFrame: (animation: T, timestamp: Timestamp) => boolean;
|
|
111
|
+
onStart: (
|
|
112
|
+
nextAnimation: T,
|
|
113
|
+
current: T extends NumericAnimation ? number : AnimatableValue,
|
|
114
|
+
timestamp: Timestamp,
|
|
115
|
+
previousAnimation: T
|
|
116
|
+
) => void;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface NumericAnimation {
|
|
120
|
+
current?: number;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export type AnimationCallback = (
|
|
124
|
+
finished?: boolean,
|
|
125
|
+
current?: AnimatableValue
|
|
126
|
+
) => void;
|
|
127
|
+
|
|
128
|
+
export type Timestamp = number;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlatList, FlatListProps, LayoutChangeEvent } from 'react-native';
|
|
3
|
+
import WrappedComponents from './WrappedComponents';
|
|
4
|
+
import createAnimatedComponent from '../../createAnimatedComponent';
|
|
5
|
+
import { ILayoutAnimationBuilder } from '../layoutReanimation/animationBuilder/commonTypes';
|
|
6
|
+
|
|
7
|
+
const AnimatedFlatList = createAnimatedComponent(FlatList as any) as any;
|
|
8
|
+
|
|
9
|
+
const createCellRenderer = (itemLayoutAnimation?: ILayoutAnimationBuilder) => {
|
|
10
|
+
const cellRenderer: React.FC<{
|
|
11
|
+
onLayout: (event: LayoutChangeEvent) => void;
|
|
12
|
+
}> = (props) => {
|
|
13
|
+
return (
|
|
14
|
+
<WrappedComponents.View
|
|
15
|
+
layout={itemLayoutAnimation}
|
|
16
|
+
onLayout={props.onLayout}>
|
|
17
|
+
{props.children}
|
|
18
|
+
</WrappedComponents.View>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return cellRenderer;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
interface ReanimatedFlatlistProps<ItemT> extends FlatListProps<ItemT> {
|
|
26
|
+
itemLayoutAnimation?: ILayoutAnimationBuilder;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type ReanimatedFlatListFC<T = any> = React.FC<ReanimatedFlatlistProps<T>>;
|
|
30
|
+
|
|
31
|
+
const ReanimatedFlatlist: ReanimatedFlatListFC = ({
|
|
32
|
+
itemLayoutAnimation,
|
|
33
|
+
...restProps
|
|
34
|
+
}) => {
|
|
35
|
+
const cellRenderer = React.useMemo(
|
|
36
|
+
() => createCellRenderer(itemLayoutAnimation),
|
|
37
|
+
[]
|
|
38
|
+
);
|
|
39
|
+
return (
|
|
40
|
+
<AnimatedFlatList {...restProps} CellRendererComponent={cellRenderer} />
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default ReanimatedFlatlist;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Image, ScrollView, Text, View } from 'react-native';
|
|
2
|
+
import createAnimatedComponent from '../../createAnimatedComponent';
|
|
3
|
+
|
|
4
|
+
const WrappedComponents = {
|
|
5
|
+
View: createAnimatedComponent(View),
|
|
6
|
+
Text: createAnimatedComponent(Text as any),
|
|
7
|
+
Image: createAnimatedComponent(Image as any),
|
|
8
|
+
ScrollView: createAnimatedComponent(ScrollView),
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default WrappedComponents;
|
package/src/reanimated2/core.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/* global _WORKLET _getCurrentTime _frameTimestamp _eventTimestamp, _setGlobalConsole */
|
|
2
2
|
import NativeReanimatedModule from './NativeReanimated';
|
|
3
3
|
import { Platform } from 'react-native';
|
|
4
|
-
import { nativeShouldBeMock, shouldBeUseWeb } from './PlatformChecker';
|
|
4
|
+
import { nativeShouldBeMock, shouldBeUseWeb, isWeb } from './PlatformChecker';
|
|
5
5
|
import {
|
|
6
6
|
BasicWorkletFunction,
|
|
7
7
|
WorkletFunction,
|
|
8
8
|
ComplexWorkletFunction,
|
|
9
9
|
SharedValue,
|
|
10
|
-
} from './commonTypes';
|
|
11
|
-
import {
|
|
12
10
|
AnimationObject,
|
|
13
11
|
AnimatableValue,
|
|
14
12
|
Timestamp,
|
|
15
|
-
} from './
|
|
13
|
+
} from './commonTypes';
|
|
16
14
|
import { Descriptor } from './hook/commonTypes';
|
|
17
15
|
import JSReanimated from './js-reanimated/JSReanimated';
|
|
18
16
|
|
|
@@ -371,8 +369,8 @@ if (!NativeReanimatedModule.useOnlyV1) {
|
|
|
371
369
|
: (workletValueSetterJS as <T>(value: T) => void)
|
|
372
370
|
);
|
|
373
371
|
|
|
374
|
-
|
|
375
|
-
|
|
372
|
+
if (!isWeb() && isConfigured()) {
|
|
373
|
+
const capturableConsole = console;
|
|
376
374
|
runOnUI(() => {
|
|
377
375
|
'worklet';
|
|
378
376
|
const console = {
|
|
@@ -383,5 +381,40 @@ if (!NativeReanimatedModule.useOnlyV1) {
|
|
|
383
381
|
info: runOnJS(capturableConsole.info),
|
|
384
382
|
};
|
|
385
383
|
_setGlobalConsole(console);
|
|
384
|
+
if (global.performance == null) {
|
|
385
|
+
global.performance = {
|
|
386
|
+
now: global._chronoNow,
|
|
387
|
+
};
|
|
388
|
+
}
|
|
386
389
|
})();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
type FeaturesConfig = {
|
|
394
|
+
enableLayoutAnimations: boolean;
|
|
395
|
+
setByUser: boolean;
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
let featuresConfig: FeaturesConfig = {
|
|
399
|
+
enableLayoutAnimations: false,
|
|
400
|
+
setByUser: false,
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
export function enableLayoutAnimations(
|
|
404
|
+
flag: boolean,
|
|
405
|
+
isCallByUser = true
|
|
406
|
+
): void {
|
|
407
|
+
if (isCallByUser) {
|
|
408
|
+
featuresConfig = {
|
|
409
|
+
enableLayoutAnimations: flag,
|
|
410
|
+
setByUser: true,
|
|
411
|
+
};
|
|
412
|
+
NativeReanimatedModule.enableLayoutAnimations(flag);
|
|
413
|
+
} else if (
|
|
414
|
+
!featuresConfig.setByUser &&
|
|
415
|
+
featuresConfig.enableLayoutAnimations !== flag
|
|
416
|
+
) {
|
|
417
|
+
featuresConfig.enableLayoutAnimations = flag;
|
|
418
|
+
NativeReanimatedModule.enableLayoutAnimations(flag);
|
|
419
|
+
}
|
|
387
420
|
}
|
|
@@ -13,6 +13,7 @@ declare global {
|
|
|
13
13
|
tag: number,
|
|
14
14
|
flag: { value: boolean; _value: boolean }
|
|
15
15
|
) => void;
|
|
16
|
+
const _setGestureState: (handlerTag: number, newState: number) => void;
|
|
16
17
|
const _updateProps: (
|
|
17
18
|
tag: number,
|
|
18
19
|
name: string,
|
|
@@ -25,16 +26,20 @@ declare global {
|
|
|
25
26
|
y: number,
|
|
26
27
|
animated: boolean
|
|
27
28
|
) => void;
|
|
29
|
+
const _chronoNow: () => number;
|
|
28
30
|
namespace NodeJS {
|
|
29
31
|
interface Global {
|
|
30
32
|
__reanimatedWorkletInit: (worklet: WorkletFunction) => void;
|
|
31
33
|
_setGlobalConsole: (console?: ReanimatedConsole) => void;
|
|
32
34
|
_log: (s: string) => void;
|
|
35
|
+
_setGestureState: () => void;
|
|
33
36
|
_WORKLET: boolean;
|
|
34
37
|
__reanimatedModuleProxy: NativeReanimated;
|
|
35
38
|
_frameTimestamp: number | null;
|
|
36
39
|
_measure: () => MeasuredDimensions;
|
|
37
40
|
_scrollTo: () => void;
|
|
41
|
+
_chronoNow: () => number;
|
|
42
|
+
performance: { now: () => number };
|
|
38
43
|
LayoutAnimationRepository: {
|
|
39
44
|
configs: Record<string, unknown>;
|
|
40
45
|
registerConfig(tag: number, config: Record<string, unknown>): void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MutableRefObject } from 'react';
|
|
2
2
|
import { WorkletFunction } from '../commonTypes';
|
|
3
|
-
import { isWeb } from '../PlatformChecker';
|
|
4
3
|
import WorkletEventHandler from '../WorkletEventHandler';
|
|
5
4
|
import { Context, DependencyList } from './commonTypes';
|
|
6
5
|
import { useEvent, useHandler } from './Hooks';
|
|
@@ -98,7 +97,7 @@ export function useAnimatedGestureHandler<
|
|
|
98
97
|
}
|
|
99
98
|
};
|
|
100
99
|
|
|
101
|
-
if (
|
|
100
|
+
if (useWeb) {
|
|
102
101
|
return handler;
|
|
103
102
|
}
|
|
104
103
|
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { Component, useRef } from 'react';
|
|
2
2
|
import { getTag } from '../NativeMethods';
|
|
3
3
|
import { useSharedValue } from './useSharedValue';
|
|
4
|
-
|
|
5
|
-
export interface RefObjectFunction<T> {
|
|
6
|
-
current: T | null;
|
|
7
|
-
(component?: T): number;
|
|
8
|
-
}
|
|
4
|
+
import { RefObjectFunction } from './commonTypes';
|
|
9
5
|
|
|
10
6
|
export function useAnimatedRef<T extends Component>(): RefObjectFunction<T> {
|
|
11
7
|
const tag = useSharedValue<number | null>(-1);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
makeMutable,
|
|
11
11
|
} from '../core';
|
|
12
12
|
import updateProps, { updatePropsJestWrapper } from '../UpdateProps';
|
|
13
|
-
import { initialUpdaterRun
|
|
13
|
+
import { initialUpdaterRun } from '../animation';
|
|
14
14
|
import NativeReanimatedModule from '../NativeReanimated';
|
|
15
15
|
import { useSharedValue } from './useSharedValue';
|
|
16
16
|
import {
|
|
@@ -31,11 +31,13 @@ import {
|
|
|
31
31
|
ViewRefSet,
|
|
32
32
|
} from '../ViewDescriptorsSet';
|
|
33
33
|
import { isJest, shouldBeUseWeb } from '../PlatformChecker';
|
|
34
|
-
import { AnimationObject } from '../animation/commonTypes';
|
|
35
34
|
import {
|
|
35
|
+
AnimationObject,
|
|
36
|
+
Timestamp,
|
|
36
37
|
AdapterWorkletFunction,
|
|
37
38
|
AnimatedStyle,
|
|
38
39
|
BasicWorkletFunction,
|
|
40
|
+
BasicWorkletFunctionOptional,
|
|
39
41
|
NestedObjectValues,
|
|
40
42
|
SharedValue,
|
|
41
43
|
} from '../commonTypes';
|
|
@@ -259,7 +261,12 @@ function styleUpdater(
|
|
|
259
261
|
} else {
|
|
260
262
|
state.isAnimationCancelled = true;
|
|
261
263
|
state.animations = [];
|
|
262
|
-
|
|
264
|
+
|
|
265
|
+
const diff = styleDiff(oldValues, newValues);
|
|
266
|
+
state.last = Object.assign({}, oldValues, newValues);
|
|
267
|
+
if (diff) {
|
|
268
|
+
updateProps(viewDescriptors, newValues, maybeViewRef);
|
|
269
|
+
}
|
|
263
270
|
}
|
|
264
271
|
}
|
|
265
272
|
|
|
@@ -446,10 +453,10 @@ export function useAnimatedStyle<T extends AnimatedStyle>(
|
|
|
446
453
|
|
|
447
454
|
useEffect(() => {
|
|
448
455
|
let fun;
|
|
449
|
-
let
|
|
456
|
+
let updaterFn = updater as BasicWorkletFunctionOptional<T>;
|
|
450
457
|
let optimalization = updater.__optimalization;
|
|
451
458
|
if (adapters) {
|
|
452
|
-
|
|
459
|
+
updaterFn = () => {
|
|
453
460
|
'worklet';
|
|
454
461
|
const newValues = updater();
|
|
455
462
|
adaptersArray.forEach((adapter) => {
|
|
@@ -459,26 +466,38 @@ export function useAnimatedStyle<T extends AnimatedStyle>(
|
|
|
459
466
|
};
|
|
460
467
|
}
|
|
461
468
|
|
|
462
|
-
if (canApplyOptimalisation(
|
|
463
|
-
if (hasColorProps(
|
|
464
|
-
|
|
469
|
+
if (canApplyOptimalisation(updaterFn) && !shouldBeUseWeb()) {
|
|
470
|
+
if (hasColorProps(updaterFn())) {
|
|
471
|
+
updaterFn = () => {
|
|
472
|
+
'worklet';
|
|
473
|
+
const newValues = updaterFn();
|
|
474
|
+
const oldValues = remoteState.last;
|
|
475
|
+
const diff = styleDiff<T>(oldValues, newValues);
|
|
476
|
+
remoteState.last = Object.assign({}, oldValues, newValues);
|
|
477
|
+
parseColors(diff);
|
|
478
|
+
return diff;
|
|
479
|
+
};
|
|
480
|
+
} else {
|
|
481
|
+
updaterFn = () => {
|
|
465
482
|
'worklet';
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
|
|
483
|
+
const newValues = updaterFn();
|
|
484
|
+
const oldValues = remoteState.last;
|
|
485
|
+
const diff = styleDiff<T>(oldValues, newValues);
|
|
486
|
+
remoteState.last = Object.assign({}, oldValues, newValues);
|
|
487
|
+
return diff;
|
|
469
488
|
};
|
|
470
489
|
}
|
|
471
490
|
} else if (!shouldBeUseWeb()) {
|
|
472
491
|
optimalization = 0;
|
|
473
|
-
|
|
492
|
+
updaterFn = () => {
|
|
474
493
|
'worklet';
|
|
475
|
-
const style =
|
|
494
|
+
const style = updaterFn();
|
|
476
495
|
parseColors(style);
|
|
477
496
|
return style;
|
|
478
497
|
};
|
|
479
498
|
}
|
|
480
499
|
if (typeof updater.__optimalization !== undefined) {
|
|
481
|
-
|
|
500
|
+
updaterFn.__optimalization = optimalization;
|
|
482
501
|
}
|
|
483
502
|
|
|
484
503
|
if (isJest()) {
|
|
@@ -499,7 +518,7 @@ export function useAnimatedStyle<T extends AnimatedStyle>(
|
|
|
499
518
|
'worklet';
|
|
500
519
|
styleUpdater(
|
|
501
520
|
sharableViewDescriptors,
|
|
502
|
-
|
|
521
|
+
updaterFn,
|
|
503
522
|
remoteState,
|
|
504
523
|
maybeViewRef,
|
|
505
524
|
animationsActive
|
|
@@ -510,7 +529,7 @@ export function useAnimatedStyle<T extends AnimatedStyle>(
|
|
|
510
529
|
fun,
|
|
511
530
|
inputs,
|
|
512
531
|
[],
|
|
513
|
-
|
|
532
|
+
updaterFn,
|
|
514
533
|
// TODO fix this
|
|
515
534
|
sharableViewDescriptors
|
|
516
535
|
);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { MutableRefObject, useEffect, useRef } from 'react';
|
|
2
|
-
import { AnimationObject } from '../animation';
|
|
3
2
|
import { processColor } from '../Colors';
|
|
4
3
|
import {
|
|
5
4
|
AnimatedStyle,
|
|
@@ -7,9 +6,10 @@ import {
|
|
|
7
6
|
NestedObjectValues,
|
|
8
7
|
StyleProps,
|
|
9
8
|
WorkletFunction,
|
|
9
|
+
AnimationObject,
|
|
10
10
|
} from '../commonTypes';
|
|
11
11
|
import { makeRemote } from '../core';
|
|
12
|
-
import { isWeb } from '../PlatformChecker';
|
|
12
|
+
import { isWeb, isJest } from '../PlatformChecker';
|
|
13
13
|
import { colorProps } from '../UpdateProps';
|
|
14
14
|
import WorkletEventHandler from '../WorkletEventHandler';
|
|
15
15
|
import {
|
|
@@ -80,7 +80,7 @@ export function useHandler<T, TContext extends Context>(
|
|
|
80
80
|
savedDependencies
|
|
81
81
|
);
|
|
82
82
|
initRef.current.savedDependencies = dependencies;
|
|
83
|
-
const useWeb = isWeb();
|
|
83
|
+
const useWeb = isWeb() || isJest();
|
|
84
84
|
|
|
85
85
|
return { context, doDependenciesDiffer, useWeb };
|
|
86
86
|
}
|
|
@@ -163,7 +163,12 @@ export function parseColors(updates: AnimatedStyle): void {
|
|
|
163
163
|
'worklet';
|
|
164
164
|
for (const key in updates) {
|
|
165
165
|
if (colorProps.indexOf(key) !== -1) {
|
|
166
|
-
|
|
166
|
+
// value could be an animation in which case processColor will recognize it and will return undefined
|
|
167
|
+
// -> in such a case we don't want to override style of that key
|
|
168
|
+
const processedColor = processColor(updates[key]);
|
|
169
|
+
if (processedColor !== undefined) {
|
|
170
|
+
updates[key] = processedColor;
|
|
171
|
+
}
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
}
|
|
@@ -201,33 +206,29 @@ export function isAnimated(prop: NestedObjectValues<AnimationObject>): boolean {
|
|
|
201
206
|
return false;
|
|
202
207
|
}
|
|
203
208
|
|
|
204
|
-
export function styleDiff(
|
|
209
|
+
export function styleDiff<T extends AnimatedStyle>(
|
|
205
210
|
oldStyle: AnimatedStyle,
|
|
206
211
|
newStyle: AnimatedStyle
|
|
207
|
-
):
|
|
212
|
+
): Partial<T> {
|
|
208
213
|
'worklet';
|
|
209
|
-
const diff:
|
|
210
|
-
|
|
214
|
+
const diff: any = {};
|
|
215
|
+
for (const key in oldStyle) {
|
|
211
216
|
if (newStyle[key] === undefined) {
|
|
212
217
|
diff[key] = null;
|
|
213
218
|
}
|
|
214
|
-
}
|
|
215
|
-
|
|
219
|
+
}
|
|
220
|
+
for (const key in newStyle) {
|
|
216
221
|
const value = newStyle[key];
|
|
217
222
|
const oldValue = oldStyle[key];
|
|
218
223
|
|
|
219
224
|
if (isAnimated(value)) {
|
|
220
225
|
// do nothing
|
|
221
|
-
|
|
226
|
+
continue;
|
|
222
227
|
}
|
|
223
|
-
if (
|
|
224
|
-
oldValue !== value &&
|
|
225
|
-
JSON.stringify(oldValue) !== JSON.stringify(value)
|
|
226
|
-
) {
|
|
227
|
-
// I'd use deep equal here but that'd take additional work and this was easier
|
|
228
|
+
if (oldValue !== value) {
|
|
228
229
|
diff[key] = value;
|
|
229
230
|
}
|
|
230
|
-
}
|
|
231
|
+
}
|
|
231
232
|
return diff;
|
|
232
233
|
}
|
|
233
234
|
|
package/src/reanimated2/index.ts
CHANGED
|
@@ -2,9 +2,11 @@ export * from './core';
|
|
|
2
2
|
export * from './hook';
|
|
3
3
|
export * from './animation';
|
|
4
4
|
export * from './interpolation';
|
|
5
|
+
export * from './interpolateColor';
|
|
5
6
|
export * from './Easing';
|
|
6
7
|
export * from './NativeMethods';
|
|
7
8
|
export * from './Colors';
|
|
8
9
|
export * from './PropAdapters';
|
|
9
10
|
export * from './layoutReanimation';
|
|
10
11
|
export * from './utils';
|
|
12
|
+
export * from './commonTypes';
|