react-native-reanimated 2.3.0-alpha.3 → 2.3.0-beta.4
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/LayoutAnimations/LayoutAnimationsProxy.cpp +15 -8
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +176 -154
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +49 -33
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +14 -7
- package/Common/cpp/Registries/MapperRegistry.cpp +24 -20
- package/Common/cpp/Registries/WorkletsCache.cpp +19 -9
- package/Common/cpp/SharedItems/FrozenObject.cpp +17 -8
- package/Common/cpp/SharedItems/MutableValue.cpp +38 -25
- package/Common/cpp/SharedItems/MutableValueSetterProxy.cpp +11 -7
- package/Common/cpp/SharedItems/RemoteObject.cpp +9 -5
- package/Common/cpp/SharedItems/ShareableValue.cpp +211 -160
- package/Common/cpp/Tools/FeaturesConfig.cpp +5 -0
- package/Common/cpp/Tools/JSIStoreValueUser.cpp +25 -6
- package/Common/cpp/Tools/Mapper.cpp +30 -30
- package/Common/cpp/Tools/RuntimeDecorator.cpp +124 -86
- package/Common/cpp/Tools/Scheduler.cpp +6 -5
- package/Common/cpp/Tools/WorkletEventHandler.cpp +4 -2
- package/Common/cpp/headers/LayoutAnimations/LayoutAnimationsProxy.h +12 -11
- package/Common/cpp/headers/NativeModules/NativeReanimatedModule.h +50 -31
- package/Common/cpp/headers/NativeModules/NativeReanimatedModuleSpec.h +34 -16
- package/Common/cpp/headers/Registries/EventHandlerRegistry.h +15 -8
- package/Common/cpp/headers/Registries/MapperRegistry.h +5 -4
- package/Common/cpp/headers/Registries/WorkletsCache.h +9 -7
- package/Common/cpp/headers/SharedItems/FrozenObject.h +19 -11
- package/Common/cpp/headers/SharedItems/HostFunctionHandler.h +8 -4
- package/Common/cpp/headers/SharedItems/MutableValue.h +23 -12
- package/Common/cpp/headers/SharedItems/MutableValueSetterProxy.h +12 -7
- package/Common/cpp/headers/SharedItems/RemoteObject.h +19 -8
- package/Common/cpp/headers/SharedItems/RuntimeManager.h +26 -25
- package/Common/cpp/headers/SharedItems/ShareableValue.h +32 -27
- package/Common/cpp/headers/SharedItems/SharedParent.h +10 -7
- package/Common/cpp/headers/SharedItems/ValueWrapper.h +95 -72
- package/Common/cpp/headers/SpecTools/ErrorHandler.h +18 -19
- package/Common/cpp/headers/Tools/FeaturesConfig.h +19 -0
- package/Common/cpp/headers/Tools/JSIStoreValueUser.h +13 -16
- package/Common/cpp/headers/Tools/Mapper.h +19 -16
- package/Common/cpp/headers/Tools/PlatformDepMethodsHolder.h +17 -7
- package/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h +7 -11
- package/Common/cpp/headers/Tools/RuntimeDecorator.h +36 -27
- package/Common/cpp/headers/Tools/Scheduler.h +30 -35
- package/Common/cpp/headers/Tools/WorkletEventHandler.h +11 -8
- package/Common/cpp/hidden_headers/Logger.h +14 -14
- package/Common/cpp/hidden_headers/LoggerInterface.h +8 -9
- package/Common/cpp/hidden_headers/SpeedChecker.h +7 -8
- package/README.md +1 -1
- package/RNReanimated.podspec +24 -6
- package/android/build.gradle +38 -29
- 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/ios/LayoutReanimation/REAAnimationsManager.h +10 -8
- package/ios/LayoutReanimation/REAAnimationsManager.m +91 -87
- package/ios/LayoutReanimation/REASnapshot.h +2 -2
- package/ios/LayoutReanimation/REASnapshot.m +8 -7
- package/ios/LayoutReanimation/REAUIManager.h +4 -4
- package/ios/LayoutReanimation/REAUIManager.mm +116 -70
- package/ios/Nodes/REAAlwaysNode.m +14 -15
- package/ios/Nodes/REABezierNode.m +8 -7
- package/ios/Nodes/REABlockNode.m +1 -1
- package/ios/Nodes/REACallFuncNode.h +0 -1
- package/ios/Nodes/REACallFuncNode.m +10 -8
- package/ios/Nodes/REAClockNodes.m +22 -20
- package/ios/Nodes/REAConcatNode.h +0 -1
- package/ios/Nodes/REAConcatNode.m +2 -2
- package/ios/Nodes/REACondNode.m +7 -5
- package/ios/Nodes/READebugNode.m +5 -4
- package/ios/Nodes/REAEventNode.m +1 -1
- package/ios/Nodes/REAFunctionNode.h +0 -1
- package/ios/Nodes/REAFunctionNode.m +2 -2
- package/ios/Nodes/REAJSCallNode.m +4 -5
- package/ios/Nodes/REANode.h +3 -4
- package/ios/Nodes/REANode.m +9 -11
- package/ios/Nodes/REAOperatorNode.m +68 -67
- package/ios/Nodes/REAParamNode.h +1 -3
- package/ios/Nodes/REAParamNode.m +15 -17
- package/ios/Nodes/REAPropsNode.h +1 -3
- package/ios/Nodes/REAPropsNode.m +19 -22
- package/ios/Nodes/REASetNode.h +0 -1
- package/ios/Nodes/REASetNode.m +7 -5
- package/ios/Nodes/REAStyleNode.h +0 -1
- package/ios/Nodes/REAStyleNode.m +2 -4
- package/ios/Nodes/REATransformNode.h +0 -1
- package/ios/Nodes/REATransformNode.m +3 -5
- package/ios/Nodes/REAValueNode.m +5 -7
- package/ios/REAEventDispatcher.m +4 -4
- package/ios/REAModule.h +0 -2
- package/ios/REAModule.m +29 -38
- package/ios/REANodesManager.h +11 -19
- package/ios/REANodesManager.m +106 -130
- package/ios/REAUtils.h +5 -3
- package/ios/RNGestureHandlerStateManager.h +5 -0
- package/ios/Transitioning/RCTConvert+REATransition.m +45 -29
- package/ios/Transitioning/REAAllTransitions.h +2 -2
- package/ios/Transitioning/REAAllTransitions.m +14 -25
- package/ios/Transitioning/REATransition.h +8 -7
- package/ios/Transitioning/REATransition.m +19 -16
- package/ios/Transitioning/REATransitionAnimation.h +1 -1
- package/ios/Transitioning/REATransitionAnimation.m +2 -3
- package/ios/Transitioning/REATransitionManager.m +3 -3
- package/ios/native/NativeMethods.h +20 -5
- package/ios/native/NativeMethods.mm +14 -6
- package/ios/native/NativeProxy.h +4 -2
- package/ios/native/NativeProxy.mm +84 -63
- package/ios/native/REAIOSErrorHandler.h +13 -10
- package/ios/native/REAIOSErrorHandler.mm +19 -15
- package/ios/native/REAIOSLogger.h +8 -8
- package/ios/native/REAIOSLogger.mm +10 -6
- package/ios/native/REAIOSScheduler.h +5 -5
- package/ios/native/REAIOSScheduler.mm +17 -10
- package/ios/native/REAInitializer.h +5 -7
- package/ios/native/REAInitializer.mm +43 -31
- package/ios/native/UIResponder+Reanimated.mm +2 -2
- package/lib/Animated.js +9 -1
- package/lib/ConfigHelper.js +121 -138
- package/lib/ReanimatedEventEmitter.js +0 -1
- package/lib/ReanimatedModule.js +0 -1
- package/lib/ReanimatedModule.macos.js +0 -1
- package/lib/ReanimatedModule.native.js +5 -6
- package/lib/ReanimatedModule.windows.js +0 -1
- package/lib/ReanimatedModuleCompat.js +64 -35
- package/lib/createAnimatedComponent.js +468 -487
- package/lib/index.js +9 -1
- package/lib/reanimated2/NativeMethods.js +7 -12
- package/lib/reanimated2/NativeReanimated/NativeReanimated.js +37 -0
- package/lib/reanimated2/NativeReanimated/index.js +15 -0
- package/lib/reanimated2/PropAdapters.js +0 -1
- package/lib/reanimated2/UpdateProps.js +6 -7
- package/lib/reanimated2/ViewDescriptorsSet.js +4 -4
- package/lib/reanimated2/WorkletEventHandler.js +15 -13
- package/lib/reanimated2/animation/delay.js +8 -2
- package/lib/reanimated2/animation/spring.js +2 -0
- package/lib/reanimated2/animation/styleAnimation.js +7 -3
- package/lib/reanimated2/animation/util.js +25 -2
- package/lib/reanimated2/core.js +41 -17
- package/lib/reanimated2/globals.d.ts +21 -1
- package/lib/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/reanimated2/hook/useAnimatedStyle.js +3 -3
- package/lib/reanimated2/index.js +1 -0
- package/lib/reanimated2/interpolation.js +95 -87
- package/lib/reanimated2/js-reanimated/JSReanimated.js +13 -10
- package/lib/reanimated2/js-reanimated/Mapper.js +4 -3
- package/lib/reanimated2/js-reanimated/MapperRegistry.js +3 -6
- package/lib/reanimated2/js-reanimated/MutableValue.js +0 -2
- package/lib/reanimated2/js-reanimated/index.js +10 -8
- package/lib/reanimated2/layoutReanimation/LayoutAnimationRepository.js +33 -2
- package/lib/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +27 -124
- package/lib/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +125 -0
- package/lib/reanimated2/layoutReanimation/animationBuilder/index.js +1 -2
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +115 -45
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Default.js +7 -2
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Fade.js +21 -21
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Flip.js +25 -25
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +19 -17
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +5 -5
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Roll.js +9 -9
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +17 -17
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Slide.js +19 -19
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +9 -9
- package/lib/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +33 -33
- package/lib/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +78 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +128 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +37 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +41 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +34 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +46 -0
- package/lib/reanimated2/layoutReanimation/defaultTransitions/index.js +6 -0
- package/lib/reanimated2/layoutReanimation/index.js +1 -0
- package/lib/reanimated2/mock.js +3 -1
- package/lib/reanimated2/utils.js +9 -0
- package/lib/setAndForwardRef.js +14 -48
- 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/mock.js +1 -1
- package/package.json +28 -17
- package/plugin.js +220 -39
- package/react-native-reanimated.d.ts +542 -547
- package/src/Animated.js +9 -1
- package/src/{ConfigHelper.js → ConfigHelper.ts} +15 -7
- package/src/{ReanimatedEventEmitter.js → ReanimatedEventEmitter.ts} +0 -0
- package/src/{ReanimatedModule.js → ReanimatedModule.macos.ts} +0 -0
- package/src/{ReanimatedModule.native.js → ReanimatedModule.native.ts} +0 -0
- package/src/{ReanimatedModule.macos.js → ReanimatedModule.ts} +0 -0
- package/src/{ReanimatedModule.windows.js → ReanimatedModule.windows.ts} +0 -0
- package/src/ReanimatedModuleCompat.ts +51 -0
- package/src/{createAnimatedComponent.js → createAnimatedComponent.tsx} +285 -126
- package/src/reanimated2/NativeMethods.ts +34 -13
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +72 -0
- package/src/reanimated2/NativeReanimated/index.ts +18 -0
- package/src/reanimated2/PropAdapters.ts +0 -1
- package/src/reanimated2/UpdateProps.ts +31 -15
- package/src/reanimated2/ViewDescriptorsSet.ts +15 -12
- package/src/reanimated2/WorkletEventHandler.ts +41 -23
- package/src/reanimated2/animation/commonTypes.ts +4 -4
- package/src/reanimated2/animation/decay.ts +2 -2
- package/src/reanimated2/animation/delay.ts +11 -5
- package/src/reanimated2/animation/index.ts +7 -7
- package/src/reanimated2/animation/repeat.ts +4 -4
- package/src/reanimated2/animation/sequence.ts +2 -2
- package/src/reanimated2/animation/spring.ts +6 -5
- package/src/reanimated2/animation/styleAnimation.ts +27 -15
- package/src/reanimated2/animation/timing.ts +5 -5
- package/src/reanimated2/animation/util.ts +47 -8
- package/src/reanimated2/commonTypes.ts +3 -0
- package/src/reanimated2/core.ts +80 -34
- package/src/reanimated2/globals.d.ts +21 -1
- package/src/reanimated2/hook/useAnimatedGestureHandler.ts +1 -1
- package/src/reanimated2/hook/useAnimatedRef.ts +13 -15
- package/src/reanimated2/hook/useAnimatedScrollHandler.ts +3 -3
- package/src/reanimated2/hook/useAnimatedStyle.ts +7 -7
- package/src/reanimated2/hook/utils.ts +4 -3
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/interpolation.ts +170 -103
- package/src/reanimated2/js-reanimated/JSReanimated.ts +37 -23
- package/src/reanimated2/js-reanimated/Mapper.ts +22 -9
- package/src/reanimated2/js-reanimated/MapperRegistry.ts +22 -19
- package/src/reanimated2/js-reanimated/MutableValue.ts +11 -11
- package/src/reanimated2/js-reanimated/index.ts +31 -14
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.ts +75 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts +29 -159
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +169 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +2 -2
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +3 -9
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -5
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +162 -82
- package/src/reanimated2/layoutReanimation/defaultAnimations/Default.ts +7 -2
- package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +32 -32
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +38 -38
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +34 -32
- package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +8 -8
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +14 -14
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +26 -26
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +28 -28
- package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +14 -14
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +50 -50
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +104 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +213 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +60 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +58 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +41 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +78 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/index.ts +6 -0
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/mock.ts +3 -1
- package/src/reanimated2/utils.ts +21 -0
- package/src/{setAndForwardRef.js → setAndForwardRef.ts} +12 -2
- package/android/react-native-reanimated-62-hermes.aar +0 -0
- package/android/react-native-reanimated-62-jsc.aar +0 -0
- package/lib/reanimated2/NativeReanimated.js +0 -48
- package/lib/reanimated2/layoutReanimation/animationBuilder/BaseBounceAnimationBuilder.js +0 -55
- package/lib/reanimated2/layoutReanimation/animationBuilder/LayoutAnimationBuilder.js +0 -165
- package/src/ReanimatedModuleCompat.js +0 -37
- package/src/reanimated2/NativeReanimated.ts +0 -70
- package/src/reanimated2/layoutReanimation/LayoutAnimationRepository.tsx +0 -41
- package/src/reanimated2/layoutReanimation/animationBuilder/BaseBounceAnimationBuilder.ts +0 -82
- package/src/reanimated2/layoutReanimation/animationBuilder/LayoutAnimationBuilder.ts +0 -217
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
/* global _WORKLET _measure _scrollTo */
|
|
1
|
+
/* global _WORKLET _measure _scrollTo _setGestureState */
|
|
2
2
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
3
|
// @ts-nocheck
|
|
4
|
+
import { Component } from 'react';
|
|
4
5
|
import { findNodeHandle } from 'react-native';
|
|
6
|
+
import { RefObjectFunction } from './hook/useAnimatedRef';
|
|
5
7
|
import { isChromeDebugger } from './PlatformChecker';
|
|
6
8
|
|
|
7
|
-
export function getTag(
|
|
9
|
+
export function getTag(
|
|
10
|
+
view: null | number | React.Component<any, any> | React.ComponentClass<any>
|
|
11
|
+
): null | number {
|
|
8
12
|
return findNodeHandle(view);
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export function measure(
|
|
15
|
+
export interface MeasuredDimensions {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
pageX: number;
|
|
21
|
+
pageY: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function measure(
|
|
25
|
+
animatedRef: RefObjectFunction<Component>
|
|
26
|
+
): MeasuredDimensions {
|
|
21
27
|
'worklet';
|
|
22
28
|
if (!_WORKLET && !isChromeDebugger()) {
|
|
23
29
|
throw new Error('(measure) method cannot be used on RN side!');
|
|
@@ -30,7 +36,12 @@ export function measure(animatedRef) {
|
|
|
30
36
|
return result;
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
export function scrollTo(
|
|
39
|
+
export function scrollTo(
|
|
40
|
+
animatedRef: RefObjectFunction<Component>,
|
|
41
|
+
x: number,
|
|
42
|
+
y: number,
|
|
43
|
+
animated: boolean
|
|
44
|
+
): void {
|
|
34
45
|
'worklet';
|
|
35
46
|
if (!_WORKLET && !isChromeDebugger()) {
|
|
36
47
|
return;
|
|
@@ -38,3 +49,13 @@ export function scrollTo(animatedRef, x, y, animated) {
|
|
|
38
49
|
const viewTag = animatedRef();
|
|
39
50
|
_scrollTo(viewTag, x, y, animated);
|
|
40
51
|
}
|
|
52
|
+
|
|
53
|
+
export function setGestureState(handlerTag: number, newState: number): void {
|
|
54
|
+
'worklet';
|
|
55
|
+
if (!_WORKLET && !isChromeDebugger()) {
|
|
56
|
+
console.warn(
|
|
57
|
+
'[Reanimated] You can not use setGestureState in non-worklet function.'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
_setGestureState(handlerTag, newState);
|
|
61
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SharedValue } from '../commonTypes';
|
|
2
|
+
import { Descriptor } from '../hook/commonTypes';
|
|
3
|
+
|
|
4
|
+
const InnerNativeModule = global.__reanimatedModuleProxy;
|
|
5
|
+
export class NativeReanimated {
|
|
6
|
+
native: boolean;
|
|
7
|
+
useOnlyV1: boolean;
|
|
8
|
+
|
|
9
|
+
constructor(native = true) {
|
|
10
|
+
this.native = native;
|
|
11
|
+
this.useOnlyV1 = InnerNativeModule === null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
installCoreFunctions(valueSetter: <T>(value: T) => void): void {
|
|
15
|
+
return InnerNativeModule.installCoreFunctions(valueSetter);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
makeShareable<T>(value: T): T {
|
|
19
|
+
return InnerNativeModule.makeShareable(value);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
makeMutable<T>(value: T): SharedValue<T> {
|
|
23
|
+
return InnerNativeModule.makeMutable(value);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
makeRemote<T>(object = {}): T {
|
|
27
|
+
return InnerNativeModule.makeRemote(object);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
startMapper(
|
|
31
|
+
mapper: () => void,
|
|
32
|
+
inputs: any[] = [],
|
|
33
|
+
outputs: any[] = [],
|
|
34
|
+
updater: () => void,
|
|
35
|
+
viewDescriptors: Descriptor[] | SharedValue<Descriptor[]>
|
|
36
|
+
): number {
|
|
37
|
+
return InnerNativeModule.startMapper(
|
|
38
|
+
mapper,
|
|
39
|
+
inputs,
|
|
40
|
+
outputs,
|
|
41
|
+
updater,
|
|
42
|
+
viewDescriptors
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
stopMapper(mapperId: number): void {
|
|
47
|
+
return InnerNativeModule.stopMapper(mapperId);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
registerEventHandler<T>(
|
|
51
|
+
eventHash: string,
|
|
52
|
+
eventHandler: (event: T) => void
|
|
53
|
+
): string {
|
|
54
|
+
return InnerNativeModule.registerEventHandler(eventHash, eventHandler);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
unregisterEventHandler(id: string): void {
|
|
58
|
+
return InnerNativeModule.unregisterEventHandler(id);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
getViewProp<T>(
|
|
62
|
+
viewTag: string,
|
|
63
|
+
propName: string,
|
|
64
|
+
callback?: (result: T) => void
|
|
65
|
+
): Promise<T> {
|
|
66
|
+
return InnerNativeModule.getViewProp(viewTag, propName, callback);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
enableLayoutAnimations(flag: boolean): void {
|
|
70
|
+
InnerNativeModule.enableLayoutAnimations(flag);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import reanimatedJS from '../js-reanimated';
|
|
2
|
+
import { nativeShouldBeMock } from '../PlatformChecker';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import { NativeReanimated } from './NativeReanimated';
|
|
5
|
+
|
|
6
|
+
let exportedModule;
|
|
7
|
+
if (nativeShouldBeMock()) {
|
|
8
|
+
exportedModule = reanimatedJS;
|
|
9
|
+
} else {
|
|
10
|
+
exportedModule = new NativeReanimated();
|
|
11
|
+
if (exportedModule.useOnlyV1 && Platform.OS === 'android') {
|
|
12
|
+
console.warn(
|
|
13
|
+
`If you want to use Reanimated 2 then go through our installation steps https://docs.swmansion.com/react-native-reanimated/docs/installation`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default exportedModule as NativeReanimated;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/* global _updateProps */
|
|
2
|
-
|
|
3
|
-
// @ts-nocheck
|
|
2
|
+
import { MutableRefObject } from 'react';
|
|
4
3
|
import { processColor } from './Colors';
|
|
4
|
+
import { AnimatedStyle, SharedValue, StyleProps } from './commonTypes';
|
|
5
5
|
import { makeShareable, isConfigured } from './core';
|
|
6
|
+
import { Descriptor } from './hook/commonTypes';
|
|
6
7
|
import { _updatePropsJS } from './js-reanimated';
|
|
7
8
|
import { shouldBeUseWeb } from './PlatformChecker';
|
|
9
|
+
import { ViewRefSet } from './ViewDescriptorsSet';
|
|
8
10
|
|
|
9
11
|
// copied from react-native/Libraries/Components/View/ReactNativeStyleAttributes
|
|
10
12
|
export const colorProps = [
|
|
@@ -24,18 +26,28 @@ export const colorProps = [
|
|
|
24
26
|
'overlayColor',
|
|
25
27
|
];
|
|
26
28
|
|
|
27
|
-
const ColorProperties = !isConfigured() ? [] : makeShareable(colorProps);
|
|
29
|
+
export const ColorProperties = !isConfigured() ? [] : makeShareable(colorProps);
|
|
28
30
|
|
|
29
31
|
let updatePropsByPlatform;
|
|
30
32
|
if (shouldBeUseWeb()) {
|
|
31
|
-
updatePropsByPlatform = (
|
|
33
|
+
updatePropsByPlatform = (
|
|
34
|
+
_: SharedValue<Descriptor[]>,
|
|
35
|
+
updates: StyleProps | AnimatedStyle,
|
|
36
|
+
maybeViewRef: ViewRefSet<any> | undefined
|
|
37
|
+
): void => {
|
|
32
38
|
'worklet';
|
|
33
|
-
maybeViewRef
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
if (maybeViewRef) {
|
|
40
|
+
maybeViewRef.items.forEach((item, _) => {
|
|
41
|
+
_updatePropsJS(updates, item);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
36
44
|
};
|
|
37
45
|
} else {
|
|
38
|
-
updatePropsByPlatform = (
|
|
46
|
+
updatePropsByPlatform = (
|
|
47
|
+
viewDescriptors: SharedValue<Descriptor[]>,
|
|
48
|
+
updates: StyleProps | AnimatedStyle,
|
|
49
|
+
_: ViewRefSet<any> | undefined
|
|
50
|
+
): void => {
|
|
39
51
|
'worklet';
|
|
40
52
|
|
|
41
53
|
for (const key in updates) {
|
|
@@ -54,15 +66,19 @@ if (shouldBeUseWeb()) {
|
|
|
54
66
|
};
|
|
55
67
|
}
|
|
56
68
|
|
|
57
|
-
export const updateProps
|
|
69
|
+
export const updateProps: (
|
|
70
|
+
viewDescriptor: SharedValue<Descriptor[]>,
|
|
71
|
+
updates: StyleProps | AnimatedStyle,
|
|
72
|
+
maybeViewRef: ViewRefSet<any> | undefined
|
|
73
|
+
) => void = updatePropsByPlatform;
|
|
58
74
|
|
|
59
75
|
export const updatePropsJestWrapper = (
|
|
60
|
-
viewDescriptors
|
|
61
|
-
updates,
|
|
62
|
-
maybeViewRef,
|
|
63
|
-
animatedStyle
|
|
64
|
-
adapters
|
|
65
|
-
) => {
|
|
76
|
+
viewDescriptors: SharedValue<Descriptor[]>,
|
|
77
|
+
updates: AnimatedStyle,
|
|
78
|
+
maybeViewRef: ViewRefSet<any> | undefined,
|
|
79
|
+
animatedStyle: MutableRefObject<AnimatedStyle>,
|
|
80
|
+
adapters: ((updates: AnimatedStyle) => void)[]
|
|
81
|
+
): void => {
|
|
66
82
|
adapters.forEach((adapter) => {
|
|
67
83
|
adapter(updates);
|
|
68
84
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
-
// @ts-nocheck
|
|
3
1
|
import { useRef } from 'react';
|
|
4
2
|
import { makeMutable } from './core';
|
|
5
|
-
import { SharedValue } from './
|
|
3
|
+
import { SharedValue } from './commonTypes';
|
|
4
|
+
import { Descriptor } from './hook/commonTypes';
|
|
5
|
+
import { Platform } from 'react-native';
|
|
6
6
|
|
|
7
7
|
export interface ViewRefSet<T> {
|
|
8
8
|
items: Set<T>;
|
|
@@ -24,10 +24,13 @@ export interface ViewDescriptorsSet {
|
|
|
24
24
|
) => void;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const scheduleUpdates =
|
|
28
|
+
Platform.OS === 'web' ? requestAnimationFrame : setImmediate;
|
|
29
|
+
|
|
27
30
|
export function makeViewDescriptorsSet(): ViewDescriptorsSet {
|
|
28
|
-
const ref = useRef(null);
|
|
31
|
+
const ref = useRef<ViewDescriptorsSet | null>(null);
|
|
29
32
|
if (ref.current === null) {
|
|
30
|
-
const data = {
|
|
33
|
+
const data: ViewDescriptorsSet = {
|
|
31
34
|
batchToRemove: new Set(),
|
|
32
35
|
tags: new Set(),
|
|
33
36
|
waitForInsertSync: false,
|
|
@@ -45,7 +48,7 @@ export function makeViewDescriptorsSet(): ViewDescriptorsSet {
|
|
|
45
48
|
if (!data.waitForInsertSync) {
|
|
46
49
|
data.waitForInsertSync = true;
|
|
47
50
|
|
|
48
|
-
|
|
51
|
+
scheduleUpdates(() => {
|
|
49
52
|
data.sharableViewDescriptors.value = data.items;
|
|
50
53
|
data.waitForInsertSync = false;
|
|
51
54
|
});
|
|
@@ -58,7 +61,7 @@ export function makeViewDescriptorsSet(): ViewDescriptorsSet {
|
|
|
58
61
|
if (!data.waitForRemoveSync) {
|
|
59
62
|
data.waitForRemoveSync = true;
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
scheduleUpdates(() => {
|
|
62
65
|
const items = [];
|
|
63
66
|
for (const item of data.items) {
|
|
64
67
|
if (data.batchToRemove.has(item.tag)) {
|
|
@@ -87,18 +90,18 @@ export function makeViewDescriptorsSet(): ViewDescriptorsSet {
|
|
|
87
90
|
return ref.current;
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
export function makeViewsRefSet(): ViewRefSet {
|
|
91
|
-
const ref = useRef(null);
|
|
93
|
+
export function makeViewsRefSet<T>(): ViewRefSet<T> {
|
|
94
|
+
const ref = useRef<ViewRefSet<T> | null>(null);
|
|
92
95
|
if (ref.current === null) {
|
|
93
|
-
const data = {
|
|
96
|
+
const data: ViewRefSet<T> = {
|
|
94
97
|
items: new Set(),
|
|
95
98
|
|
|
96
|
-
add: (item) => {
|
|
99
|
+
add: (item: T) => {
|
|
97
100
|
if (data.items.has(item)) return;
|
|
98
101
|
data.items.add(item);
|
|
99
102
|
},
|
|
100
103
|
|
|
101
|
-
remove: (item) => {
|
|
104
|
+
remove: (item: T) => {
|
|
102
105
|
data.items.delete(item);
|
|
103
106
|
},
|
|
104
107
|
};
|
|
@@ -1,38 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import NativeModule from './NativeReanimated';
|
|
1
|
+
import { NativeEvent } from './commonTypes';
|
|
2
|
+
import NativeReanimatedModule from './NativeReanimated';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
function jsListener<T extends NativeEvent<T>>(
|
|
5
|
+
eventName: string,
|
|
6
|
+
handler: (event: T) => void
|
|
7
|
+
) {
|
|
8
|
+
return (evt: T) => {
|
|
9
|
+
handler({ ...evt.nativeEvent, eventName });
|
|
10
|
+
};
|
|
11
|
+
}
|
|
8
12
|
|
|
9
|
-
export default class WorkletEventHandler {
|
|
10
|
-
|
|
13
|
+
export default class WorkletEventHandler<T extends NativeEvent<T>> {
|
|
14
|
+
worklet: (event: T) => void;
|
|
15
|
+
eventNames: string[];
|
|
16
|
+
reattachNeeded: boolean;
|
|
17
|
+
listeners: Record<string, (event: T) => void>;
|
|
18
|
+
viewTag: number | undefined;
|
|
19
|
+
registrations: string[];
|
|
20
|
+
constructor(worklet: (event: T) => void, eventNames: string[] = []) {
|
|
11
21
|
this.worklet = worklet;
|
|
12
22
|
this.eventNames = eventNames;
|
|
13
23
|
this.reattachNeeded = false;
|
|
24
|
+
this.listeners = {};
|
|
25
|
+
this.viewTag = undefined;
|
|
26
|
+
this.registrations = [];
|
|
14
27
|
|
|
15
|
-
if (!
|
|
16
|
-
this.listeners = eventNames.reduce(
|
|
17
|
-
acc
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
if (!NativeReanimatedModule.native) {
|
|
29
|
+
this.listeners = eventNames.reduce(
|
|
30
|
+
(acc: Record<string, (event: T) => void>, eventName: string) => {
|
|
31
|
+
acc[eventName] = jsListener(eventName, worklet);
|
|
32
|
+
return acc;
|
|
33
|
+
},
|
|
34
|
+
{}
|
|
35
|
+
);
|
|
20
36
|
}
|
|
21
37
|
}
|
|
22
38
|
|
|
23
|
-
updateWorklet(newWorklet) {
|
|
39
|
+
updateWorklet(newWorklet: (event: T) => void): void {
|
|
24
40
|
this.worklet = newWorklet;
|
|
25
41
|
this.reattachNeeded = true;
|
|
26
42
|
}
|
|
27
43
|
|
|
28
|
-
registerForEvents(viewTag, fallbackEventName
|
|
44
|
+
registerForEvents(viewTag: number, fallbackEventName?: string): void {
|
|
29
45
|
this.viewTag = viewTag;
|
|
30
46
|
this.registrations = this.eventNames.map((eventName) =>
|
|
31
|
-
|
|
47
|
+
NativeReanimatedModule.registerEventHandler(
|
|
48
|
+
viewTag + eventName,
|
|
49
|
+
this.worklet
|
|
50
|
+
)
|
|
32
51
|
);
|
|
33
52
|
if (this.registrations.length === 0 && fallbackEventName) {
|
|
34
53
|
this.registrations.push(
|
|
35
|
-
|
|
54
|
+
NativeReanimatedModule.registerEventHandler(
|
|
36
55
|
viewTag + fallbackEventName,
|
|
37
56
|
this.worklet
|
|
38
57
|
)
|
|
@@ -40,11 +59,10 @@ export default class WorkletEventHandler {
|
|
|
40
59
|
}
|
|
41
60
|
}
|
|
42
61
|
|
|
43
|
-
unregisterFromEvents() {
|
|
44
|
-
this.registrations
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this.registrations = undefined;
|
|
62
|
+
unregisterFromEvents(): void {
|
|
63
|
+
this.registrations.forEach((id) =>
|
|
64
|
+
NativeReanimatedModule.unregisterEventHandler(id)
|
|
65
|
+
);
|
|
66
|
+
this.registrations = [];
|
|
49
67
|
}
|
|
50
68
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type AnimatableValue = number | string | Array<number>;
|
|
2
2
|
|
|
3
3
|
export interface AnimationObject {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
callback: AnimationCallback;
|
|
6
|
-
current?:
|
|
6
|
+
current?: AnimatableValue;
|
|
7
7
|
toValue?: AnimationObject['current'];
|
|
8
8
|
startValue?: AnimationObject['current'];
|
|
9
9
|
finished?: boolean;
|
|
@@ -25,7 +25,7 @@ export interface Animation<T extends AnimationObject> extends AnimationObject {
|
|
|
25
25
|
onFrame: (animation: T, timestamp: Timestamp) => boolean;
|
|
26
26
|
onStart: (
|
|
27
27
|
nextAnimation: T,
|
|
28
|
-
current: T extends NumericAnimation ? number :
|
|
28
|
+
current: T extends NumericAnimation ? number : AnimatableValue,
|
|
29
29
|
timestamp: Timestamp,
|
|
30
30
|
previousAnimation: T
|
|
31
31
|
) => void;
|
|
@@ -40,7 +40,7 @@ export interface HigherOrderAnimation {
|
|
|
40
40
|
|
|
41
41
|
export type AnimationCallback = (
|
|
42
42
|
finished?: boolean,
|
|
43
|
-
current?:
|
|
43
|
+
current?: AnimatableValue
|
|
44
44
|
) => void;
|
|
45
45
|
|
|
46
46
|
export type NextAnimation<T extends AnimationObject> = T | (() => T);
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Animation,
|
|
4
4
|
AnimationCallback,
|
|
5
5
|
AnimationObject,
|
|
6
|
-
|
|
6
|
+
AnimatableValue,
|
|
7
7
|
Timestamp,
|
|
8
8
|
} from './commonTypes';
|
|
9
9
|
import { Platform } from 'react-native';
|
|
@@ -27,7 +27,7 @@ export interface DecayAnimation extends Animation<DecayAnimation> {
|
|
|
27
27
|
startTimestamp: Timestamp;
|
|
28
28
|
initialVelocity: number;
|
|
29
29
|
velocity: number;
|
|
30
|
-
current:
|
|
30
|
+
current: AnimatableValue;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export interface InnerDecayAnimation
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
NextAnimation,
|
|
5
5
|
Timestamp,
|
|
6
6
|
HigherOrderAnimation,
|
|
7
|
-
|
|
7
|
+
AnimatableValue,
|
|
8
8
|
} from './commonTypes';
|
|
9
9
|
|
|
10
10
|
export interface DelayAnimation
|
|
@@ -13,7 +13,7 @@ export interface DelayAnimation
|
|
|
13
13
|
startTime: Timestamp;
|
|
14
14
|
started: boolean;
|
|
15
15
|
previousAnimation: DelayAnimation | null;
|
|
16
|
-
current:
|
|
16
|
+
current: AnimatableValue;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export function withDelay(
|
|
@@ -44,7 +44,9 @@ export function withDelay(
|
|
|
44
44
|
animation.current = nextAnimation.current;
|
|
45
45
|
return finished;
|
|
46
46
|
} else if (previousAnimation) {
|
|
47
|
-
const finished =
|
|
47
|
+
const finished =
|
|
48
|
+
previousAnimation.finished ||
|
|
49
|
+
previousAnimation.onFrame(previousAnimation, now);
|
|
48
50
|
animation.current = previousAnimation.current;
|
|
49
51
|
if (finished) {
|
|
50
52
|
animation.previousAnimation = null;
|
|
@@ -55,14 +57,18 @@ export function withDelay(
|
|
|
55
57
|
|
|
56
58
|
function onStart(
|
|
57
59
|
animation: DelayAnimation,
|
|
58
|
-
value:
|
|
60
|
+
value: AnimatableValue,
|
|
59
61
|
now: Timestamp,
|
|
60
62
|
previousAnimation: DelayAnimation
|
|
61
63
|
): void {
|
|
62
64
|
animation.startTime = now;
|
|
63
65
|
animation.started = false;
|
|
64
66
|
animation.current = value;
|
|
65
|
-
|
|
67
|
+
if (previousAnimation === animation) {
|
|
68
|
+
animation.previousAnimation = previousAnimation.previousAnimation;
|
|
69
|
+
} else {
|
|
70
|
+
animation.previousAnimation = previousAnimation;
|
|
71
|
+
}
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
const callback = (finished?: boolean): void => {
|
|
@@ -7,10 +7,10 @@ export {
|
|
|
7
7
|
Timestamp,
|
|
8
8
|
} from './commonTypes';
|
|
9
9
|
export { cancelAnimation, defineAnimation, initialUpdaterRun } from './util';
|
|
10
|
-
export { withTiming } from './timing';
|
|
11
|
-
export { withSpring } from './spring';
|
|
12
|
-
export { withDecay } from './decay';
|
|
13
|
-
export { withDelay } from './delay';
|
|
14
|
-
export { withRepeat } from './repeat';
|
|
15
|
-
export { withSequence } from './sequence';
|
|
16
|
-
export { withStyleAnimation } from './styleAnimation';
|
|
10
|
+
export { withTiming, TimingAnimation } from './timing';
|
|
11
|
+
export { withSpring, SpringAnimation } from './spring';
|
|
12
|
+
export { withDecay, DecayAnimation } from './decay';
|
|
13
|
+
export { withDelay, DelayAnimation } from './delay';
|
|
14
|
+
export { withRepeat, RepeatAnimation } from './repeat';
|
|
15
|
+
export { withSequence, SequenceAnimation } from './sequence';
|
|
16
|
+
export { withStyleAnimation, StyleLayoutAnimation } from './styleAnimation';
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Animation,
|
|
4
4
|
AnimationCallback,
|
|
5
5
|
NextAnimation,
|
|
6
|
-
|
|
6
|
+
AnimatableValue,
|
|
7
7
|
Timestamp,
|
|
8
8
|
HigherOrderAnimation,
|
|
9
9
|
} from './commonTypes';
|
|
@@ -12,8 +12,8 @@ export interface RepeatAnimation
|
|
|
12
12
|
extends Animation<RepeatAnimation>,
|
|
13
13
|
HigherOrderAnimation {
|
|
14
14
|
reps: number;
|
|
15
|
-
startValue:
|
|
16
|
-
toValue?:
|
|
15
|
+
startValue: AnimatableValue;
|
|
16
|
+
toValue?: AnimatableValue;
|
|
17
17
|
previousAnimation?: RepeatAnimation;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -81,7 +81,7 @@ export function withRepeat(
|
|
|
81
81
|
|
|
82
82
|
function onStart(
|
|
83
83
|
animation: RepeatAnimation,
|
|
84
|
-
value:
|
|
84
|
+
value: AnimatableValue,
|
|
85
85
|
now: Timestamp,
|
|
86
86
|
previousAnimation: RepeatAnimation
|
|
87
87
|
): void {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Animation,
|
|
4
4
|
Timestamp,
|
|
5
5
|
NextAnimation,
|
|
6
|
-
|
|
6
|
+
AnimatableValue,
|
|
7
7
|
HigherOrderAnimation,
|
|
8
8
|
AnimationObject,
|
|
9
9
|
} from './commonTypes';
|
|
@@ -66,7 +66,7 @@ export function withSequence(
|
|
|
66
66
|
|
|
67
67
|
function onStart(
|
|
68
68
|
animation: SequenceAnimation,
|
|
69
|
-
value:
|
|
69
|
+
value: AnimatableValue,
|
|
70
70
|
now: Timestamp,
|
|
71
71
|
previousAnimation: SequenceAnimation
|
|
72
72
|
): void {
|
|
@@ -2,12 +2,11 @@ import { defineAnimation } from './util';
|
|
|
2
2
|
import {
|
|
3
3
|
Animation,
|
|
4
4
|
AnimationCallback,
|
|
5
|
-
|
|
5
|
+
AnimatableValue,
|
|
6
6
|
Timestamp,
|
|
7
7
|
} from './commonTypes';
|
|
8
8
|
|
|
9
9
|
interface SpringConfig {
|
|
10
|
-
// [key: string]: any;
|
|
11
10
|
mass?: number;
|
|
12
11
|
stiffness?: number;
|
|
13
12
|
overshootClamping?: boolean;
|
|
@@ -18,8 +17,8 @@ interface SpringConfig {
|
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
export interface SpringAnimation extends Animation<SpringAnimation> {
|
|
21
|
-
current:
|
|
22
|
-
toValue:
|
|
20
|
+
current: AnimatableValue;
|
|
21
|
+
toValue: AnimatableValue;
|
|
23
22
|
velocity: number;
|
|
24
23
|
lastTimestamp: Timestamp;
|
|
25
24
|
}
|
|
@@ -31,7 +30,7 @@ export interface InnerSpringAnimation
|
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
export function withSpring(
|
|
34
|
-
toValue:
|
|
33
|
+
toValue: AnimatableValue,
|
|
35
34
|
userConfig?: SpringConfig,
|
|
36
35
|
callback?: AnimationCallback
|
|
37
36
|
): Animation<SpringAnimation> {
|
|
@@ -131,6 +130,8 @@ export function withSpring(
|
|
|
131
130
|
animation.velocity = 0;
|
|
132
131
|
animation.current = toValue;
|
|
133
132
|
}
|
|
133
|
+
// clear lastTimestamp to avoid using stale value by the next spring animation that starts after this one
|
|
134
|
+
animation.lastTimestamp = 0;
|
|
134
135
|
return true;
|
|
135
136
|
}
|
|
136
137
|
return false;
|