react-native-reanimated 3.4.0 → 3.4.2
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/lib/module/Animated.js +60 -1
- package/lib/module/Animated.js.map +1 -1
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +8 -0
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/UpdateProps.js +2 -2
- package/lib/module/reanimated2/UpdateProps.js.map +1 -1
- package/lib/module/reanimated2/animation/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/animation/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/index.js +1 -1
- package/lib/module/reanimated2/animation/index.js.map +1 -1
- package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +2 -2
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js +6 -0
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +4 -19
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/module/reanimated2/core.js +16 -0
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.js +3 -1
- package/lib/module/reanimated2/fabricUtils.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/helperTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +1 -1
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +2 -27
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +1 -1
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +26 -0
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +0 -1
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js +3 -0
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +0 -1
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/setAndForwardRef.js.map +1 -1
- package/lib/typescript/Animated.d.ts +68 -3
- package/lib/typescript/createAnimatedComponent.d.ts +1 -26
- package/lib/typescript/reanimated2/Easing.d.ts +17 -9
- package/lib/typescript/reanimated2/UpdateProps.d.ts +5 -5
- package/lib/typescript/reanimated2/animation/commonTypes.d.ts +4 -3
- package/lib/typescript/reanimated2/animation/decay.d.ts +2 -4
- package/lib/typescript/reanimated2/animation/index.d.ts +3 -3
- package/lib/typescript/reanimated2/animation/springUtils.d.ts +1 -0
- package/lib/typescript/reanimated2/animation/styleAnimation.d.ts +2 -6
- package/lib/typescript/reanimated2/animation/timing.d.ts +4 -7
- package/lib/typescript/reanimated2/animation/transformationMatrix/matrixUtils.d.ts +1 -1
- package/lib/typescript/reanimated2/animation/util.d.ts +2 -4
- package/lib/typescript/reanimated2/commonTypes.d.ts +0 -4
- package/lib/typescript/reanimated2/component/FlatList.d.ts +2 -1
- package/lib/typescript/reanimated2/component/ScrollView.d.ts +1 -1
- package/lib/typescript/reanimated2/core.d.ts +12 -0
- package/lib/typescript/reanimated2/helperTypes.d.ts +11 -7
- package/lib/typescript/reanimated2/hook/commonTypes.d.ts +2 -2
- package/lib/typescript/reanimated2/hook/index.d.ts +1 -1
- package/lib/typescript/reanimated2/hook/useAnimatedGestureHandler.d.ts +2 -2
- package/lib/typescript/reanimated2/hook/useAnimatedRef.d.ts +4 -4
- package/lib/typescript/reanimated2/hook/useAnimatedStyle.d.ts +4 -5
- package/lib/typescript/reanimated2/hook/utils.d.ts +3 -11
- package/lib/typescript/reanimated2/index.d.ts +3 -1
- package/lib/typescript/reanimated2/interpolateColor.d.ts +2 -3
- package/lib/typescript/reanimated2/js-reanimated/commonTypes.d.ts +1 -43
- package/lib/typescript/reanimated2/js-reanimated/index.d.ts +3 -2
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +4 -4
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/Keyframe.d.ts +0 -11
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +3 -3
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +13 -13
- package/lib/typescript/reanimated2/layoutReanimation/index.d.ts +1 -0
- package/lib/typescript/reanimated2/mappers.d.ts +0 -12
- package/lib/typescript/reanimated2/mock.d.ts +1 -76
- package/lib/typescript/reanimated2/mutables.d.ts +0 -1
- package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
- package/lib/typescript/reanimated2/valueSetter.d.ts +0 -1
- package/lib/typescript/setAndForwardRef.d.ts +1 -1
- package/package.json +3 -1
- package/src/Animated.ts +80 -6
- package/src/createAnimatedComponent.tsx +2 -2
- package/src/reanimated2/Easing.ts +18 -8
- package/src/reanimated2/UpdateProps.ts +13 -17
- package/src/reanimated2/animation/commonTypes.ts +3 -3
- package/src/reanimated2/animation/decay.ts +3 -1
- package/src/reanimated2/animation/index.ts +3 -3
- package/src/reanimated2/animation/springUtils.ts +2 -0
- package/src/reanimated2/animation/styleAnimation.ts +5 -5
- package/src/reanimated2/animation/timing.ts +6 -4
- package/src/reanimated2/animation/transformationMatrix/matrixUtils.tsx +4 -1
- package/src/reanimated2/animation/util.ts +5 -29
- package/src/reanimated2/commonTypes.ts +0 -25
- package/src/reanimated2/component/FlatList.tsx +3 -1
- package/src/reanimated2/component/ScrollView.tsx +1 -1
- package/src/reanimated2/core.ts +16 -0
- package/src/reanimated2/fabricUtils.ts +1 -0
- package/src/reanimated2/globals.d.ts +3 -3
- package/src/reanimated2/helperTypes.ts +17 -7
- package/src/reanimated2/hook/commonTypes.ts +2 -3
- package/src/reanimated2/hook/index.ts +4 -1
- package/src/reanimated2/hook/useAnimatedGestureHandler.ts +2 -2
- package/src/reanimated2/hook/useAnimatedRef.ts +13 -10
- package/src/reanimated2/hook/useAnimatedStyle.ts +27 -26
- package/src/reanimated2/hook/utils.ts +5 -31
- package/src/reanimated2/index.ts +13 -1
- package/src/reanimated2/interpolateColor.ts +2 -2
- package/src/reanimated2/js-reanimated/commonTypes.ts +3 -3
- package/src/reanimated2/js-reanimated/index.ts +4 -3
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +4 -4
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +5 -5
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +3 -3
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +13 -13
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/mappers.ts +2 -2
- package/src/reanimated2/mock.ts +27 -0
- package/src/reanimated2/mutables.ts +0 -1
- package/src/reanimated2/platform-specific/checkCppVersion.ts +2 -0
- package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
- package/src/reanimated2/valueSetter.ts +0 -1
- package/src/setAndForwardRef.ts +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +0 -69
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +0 -1
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js +0 -109
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js.map +0 -1
- package/lib/typescript/reanimated2/js-reanimated/Mapper.d.ts +0 -14
- package/lib/typescript/reanimated2/js-reanimated/MapperRegistry.d.ts +0 -14
- package/src/reanimated2/js-reanimated/Mapper.ts +0 -94
- package/src/reanimated2/js-reanimated/MapperRegistry.ts +0 -133
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
AnimatedStyle,
|
|
3
2
|
StyleProps,
|
|
4
3
|
AnimatableValue,
|
|
5
4
|
AnimationObject,
|
|
@@ -7,6 +6,7 @@ import type {
|
|
|
7
6
|
Timestamp,
|
|
8
7
|
AnimationCallback,
|
|
9
8
|
} from '../commonTypes';
|
|
9
|
+
import type { AnimatedStyle } from '../helperTypes';
|
|
10
10
|
|
|
11
11
|
export interface HigherOrderAnimation {
|
|
12
12
|
isHigherOrder?: boolean;
|
|
@@ -40,11 +40,11 @@ export interface SequenceAnimation
|
|
|
40
40
|
|
|
41
41
|
export interface StyleLayoutAnimation extends HigherOrderAnimation {
|
|
42
42
|
current: StyleProps;
|
|
43
|
-
styleAnimations: AnimatedStyle
|
|
43
|
+
styleAnimations: AnimatedStyle<any>;
|
|
44
44
|
onFrame: (animation: StyleLayoutAnimation, timestamp: Timestamp) => boolean;
|
|
45
45
|
onStart: (
|
|
46
46
|
nextAnimation: StyleLayoutAnimation,
|
|
47
|
-
current: AnimatedStyle
|
|
47
|
+
current: AnimatedStyle<any>,
|
|
48
48
|
timestamp: Timestamp,
|
|
49
49
|
previousAnimation: StyleLayoutAnimation
|
|
50
50
|
) => void;
|
|
@@ -15,6 +15,8 @@ interface DecayConfig {
|
|
|
15
15
|
velocity?: number;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
export type WithDecayConfig = DecayConfig;
|
|
19
|
+
|
|
18
20
|
interface DefaultDecayConfig {
|
|
19
21
|
deceleration: number;
|
|
20
22
|
velocityFactor: number;
|
|
@@ -32,7 +34,7 @@ export interface DecayAnimation extends Animation<DecayAnimation> {
|
|
|
32
34
|
current: AnimatableValue;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
interface InnerDecayAnimation
|
|
36
38
|
extends Omit<DecayAnimation, 'current'>,
|
|
37
39
|
AnimationObject {
|
|
38
40
|
current: number;
|
|
@@ -8,10 +8,10 @@ export type {
|
|
|
8
8
|
} from './commonTypes';
|
|
9
9
|
export { cancelAnimation, defineAnimation, initialUpdaterRun } from './util';
|
|
10
10
|
export { withTiming } from './timing';
|
|
11
|
-
export type { TimingAnimation } from './timing';
|
|
11
|
+
export type { TimingAnimation, WithTimingConfig } from './timing';
|
|
12
12
|
export { withSpring } from './spring';
|
|
13
|
-
export type { SpringAnimation } from './springUtils';
|
|
14
|
-
export { withDecay } from './decay';
|
|
13
|
+
export type { SpringAnimation, WithSpringConfig } from './springUtils';
|
|
14
|
+
export { withDecay, WithDecayConfig } from './decay';
|
|
15
15
|
export type { DecayAnimation } from './decay';
|
|
16
16
|
export { withDelay } from './delay';
|
|
17
17
|
export { withRepeat } from './repeat';
|
|
@@ -4,10 +4,10 @@ import type {
|
|
|
4
4
|
AnimatableValue,
|
|
5
5
|
AnimationObject,
|
|
6
6
|
Animation,
|
|
7
|
-
AnimatedStyle,
|
|
8
7
|
NestedObject,
|
|
9
8
|
NestedObjectValues,
|
|
10
9
|
} from '../commonTypes';
|
|
10
|
+
import type { AnimatedStyle } from '../helperTypes';
|
|
11
11
|
import type { StyleLayoutAnimation } from './commonTypes';
|
|
12
12
|
import { withTiming } from './timing';
|
|
13
13
|
import { ColorProperties } from '../UpdateProps';
|
|
@@ -15,7 +15,7 @@ import { processColor } from '../Colors';
|
|
|
15
15
|
|
|
16
16
|
// resolves path to value for nested objects
|
|
17
17
|
// if path cannot be resolved returns undefined
|
|
18
|
-
|
|
18
|
+
function resolvePath<T>(
|
|
19
19
|
obj: NestedObject<T>,
|
|
20
20
|
path: AnimatableValue[] | AnimatableValue
|
|
21
21
|
): NestedObjectValues<T> | undefined {
|
|
@@ -39,7 +39,7 @@ export function resolvePath<T>(
|
|
|
39
39
|
|
|
40
40
|
// set value at given path
|
|
41
41
|
type Path = Array<string | number> | string | number;
|
|
42
|
-
|
|
42
|
+
function setPath<T>(
|
|
43
43
|
obj: NestedObject<T>,
|
|
44
44
|
path: Path,
|
|
45
45
|
value: NestedObjectValues<T>
|
|
@@ -71,7 +71,7 @@ interface NestedObjectEntry<T> {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export function withStyleAnimation(
|
|
74
|
-
styleAnimations: AnimatedStyle
|
|
74
|
+
styleAnimations: AnimatedStyle<any>
|
|
75
75
|
): StyleLayoutAnimation {
|
|
76
76
|
'worklet';
|
|
77
77
|
return defineAnimation<StyleLayoutAnimation>({}, () => {
|
|
@@ -143,7 +143,7 @@ export function withStyleAnimation(
|
|
|
143
143
|
|
|
144
144
|
const onStart = (
|
|
145
145
|
animation: StyleLayoutAnimation,
|
|
146
|
-
value: AnimatedStyle
|
|
146
|
+
value: AnimatedStyle<any>,
|
|
147
147
|
now: Timestamp,
|
|
148
148
|
previousAnimation: StyleLayoutAnimation
|
|
149
149
|
): void => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EasingFunction, EasingFunctionFactory } from '../Easing';
|
|
2
2
|
import { Easing } from '../Easing';
|
|
3
3
|
import { defineAnimation } from './util';
|
|
4
4
|
import type {
|
|
@@ -10,12 +10,14 @@ import type {
|
|
|
10
10
|
|
|
11
11
|
interface TimingConfig {
|
|
12
12
|
duration?: number;
|
|
13
|
-
easing?:
|
|
13
|
+
easing?: EasingFunction | EasingFunctionFactory;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
export type WithTimingConfig = TimingConfig;
|
|
17
|
+
|
|
16
18
|
export interface TimingAnimation extends Animation<TimingAnimation> {
|
|
17
19
|
type: string;
|
|
18
|
-
easing:
|
|
20
|
+
easing: EasingFunction;
|
|
19
21
|
startValue: AnimatableValue;
|
|
20
22
|
startTime: Timestamp;
|
|
21
23
|
progress: number;
|
|
@@ -23,7 +25,7 @@ export interface TimingAnimation extends Animation<TimingAnimation> {
|
|
|
23
25
|
current: AnimatableValue;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
interface InnerTimingAnimation
|
|
27
29
|
extends Omit<TimingAnimation, 'toValue' | 'current'> {
|
|
28
30
|
toValue: number;
|
|
29
31
|
current: number;
|
|
@@ -11,7 +11,7 @@ export type AffineMatrix = FixedLengthArray<FixedLengthArray<number, 4>, 4>;
|
|
|
11
11
|
|
|
12
12
|
export type AffineMatrixFlat = FixedLengthArray<number, 16>;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
type TransformMatrixDecomposition = Record<
|
|
15
15
|
'translationMatrix' | 'scaleMatrix' | 'rotationMatrix' | 'skewMatrix',
|
|
16
16
|
AffineMatrix
|
|
17
17
|
>;
|
|
@@ -34,6 +34,7 @@ export function isAffineMatrixFlat(x: unknown): x is AffineMatrixFlat {
|
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
// ts-prune-ignore-next This function is exported to be tested
|
|
37
38
|
export function isAffineMatrix(x: unknown): x is AffineMatrix {
|
|
38
39
|
'worklet';
|
|
39
40
|
return (
|
|
@@ -53,6 +54,7 @@ export function flatten(matrix: AffineMatrix): AffineMatrixFlat {
|
|
|
53
54
|
return matrix.flat() as AffineMatrixFlat;
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
// ts-prune-ignore-next This function is exported to be tested
|
|
56
58
|
export function unflatten(m: AffineMatrixFlat): AffineMatrix {
|
|
57
59
|
'worklet';
|
|
58
60
|
return [
|
|
@@ -334,6 +336,7 @@ function gramSchmidtAlgorithm(matrix: AffineMatrix): {
|
|
|
334
336
|
};
|
|
335
337
|
}
|
|
336
338
|
|
|
339
|
+
// ts-prune-ignore-next This function is exported to be tested
|
|
337
340
|
export function decomposeMatrix(
|
|
338
341
|
unknownTypeMatrix: AffineMatrixFlat | AffineMatrix
|
|
339
342
|
): TransformMatrixDecomposition {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
HigherOrderAnimation,
|
|
3
|
-
NextAnimation,
|
|
4
|
-
StyleLayoutAnimation,
|
|
5
|
-
} from './commonTypes';
|
|
1
|
+
import type { HigherOrderAnimation, StyleLayoutAnimation } from './commonTypes';
|
|
6
2
|
import type { ParsedColorArray } from '../Colors';
|
|
7
3
|
import {
|
|
8
4
|
isColor,
|
|
@@ -11,9 +7,7 @@ import {
|
|
|
11
7
|
toGammaSpace,
|
|
12
8
|
toLinearSpace,
|
|
13
9
|
} from '../Colors';
|
|
14
|
-
|
|
15
10
|
import type {
|
|
16
|
-
AnimatedStyle,
|
|
17
11
|
SharedValue,
|
|
18
12
|
AnimatableValue,
|
|
19
13
|
Animation,
|
|
@@ -37,8 +31,6 @@ import {
|
|
|
37
31
|
|
|
38
32
|
let IN_STYLE_UPDATER = false;
|
|
39
33
|
|
|
40
|
-
export type UserUpdater = () => AnimatedStyle;
|
|
41
|
-
|
|
42
34
|
export function initialUpdaterRun<T>(updater: () => T): T {
|
|
43
35
|
IN_STYLE_UPDATER = true;
|
|
44
36
|
const result = updater();
|
|
@@ -203,7 +195,7 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
|
|
|
203
195
|
animation[i].current = RGBACurrent[index];
|
|
204
196
|
const result = animation[i].onFrame(animation[i], timestamp);
|
|
205
197
|
// We really need to assign this value to result, instead of passing it directly - otherwise once "finished" is false, onFrame won't be called
|
|
206
|
-
finished
|
|
198
|
+
finished = finished && result;
|
|
207
199
|
res.push(animation[i].current);
|
|
208
200
|
});
|
|
209
201
|
|
|
@@ -248,7 +240,7 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
|
|
|
248
240
|
let finished = true;
|
|
249
241
|
const result = animation[0].onFrame(animation[0], timestamp);
|
|
250
242
|
// We really need to assign this value to result, instead of passing it directly - otherwise once "finished" is false, onFrame won't be called
|
|
251
|
-
finished
|
|
243
|
+
finished = finished && result;
|
|
252
244
|
|
|
253
245
|
const progress = animation[0].current / 100;
|
|
254
246
|
|
|
@@ -330,7 +322,7 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
|
|
|
330
322
|
(animation.current as Array<number>).forEach((_, i) => {
|
|
331
323
|
const result = animation[i].onFrame(animation[i], timestamp);
|
|
332
324
|
// We really need to assign this value to result, instead of passing it directly - otherwise once "finished" is false, onFrame won't be called
|
|
333
|
-
finished
|
|
325
|
+
finished = finished && result;
|
|
334
326
|
(animation.current as Array<number>)[i] = animation[i].current;
|
|
335
327
|
});
|
|
336
328
|
|
|
@@ -370,7 +362,7 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
|
|
|
370
362
|
for (const key in animation.current as AnimatableValueObject) {
|
|
371
363
|
const result = animation[key].onFrame(animation[key], timestamp);
|
|
372
364
|
// We really need to assign this value to result, instead of passing it directly - otherwise once "finished" is false, onFrame won't be called
|
|
373
|
-
finished
|
|
365
|
+
finished = finished && result;
|
|
374
366
|
newObject[key] = animation[key].current;
|
|
375
367
|
}
|
|
376
368
|
animation.current = newObject;
|
|
@@ -449,19 +441,3 @@ export function cancelAnimation<T>(sharedValue: SharedValue<T>): void {
|
|
|
449
441
|
// setting the current value cancels the animation if one is currently running
|
|
450
442
|
sharedValue.value = sharedValue.value; // eslint-disable-line no-self-assign
|
|
451
443
|
}
|
|
452
|
-
|
|
453
|
-
// TODO it should work only if there was no animation before.
|
|
454
|
-
export function withStartValue(
|
|
455
|
-
startValue: AnimatableValue,
|
|
456
|
-
animation: NextAnimation<AnimationObject>
|
|
457
|
-
): Animation<AnimationObject> {
|
|
458
|
-
'worklet';
|
|
459
|
-
return defineAnimation(startValue, () => {
|
|
460
|
-
'worklet';
|
|
461
|
-
if (!_WORKLET && typeof animation === 'function') {
|
|
462
|
-
animation = animation();
|
|
463
|
-
}
|
|
464
|
-
(animation as Animation<AnimationObject>).current = startValue;
|
|
465
|
-
return animation as Animation<AnimationObject>;
|
|
466
|
-
});
|
|
467
|
-
}
|
|
@@ -37,31 +37,6 @@ export interface StyleProps extends ViewStyle, TextStyle {
|
|
|
37
37
|
[key: string]: any;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export interface AnimatedStyle extends Record<string, AnimationObject> {
|
|
41
|
-
[key: string]: any;
|
|
42
|
-
transform?: Array<
|
|
43
|
-
| Record<'matrix', number[] | AnimationObject>
|
|
44
|
-
| Partial<
|
|
45
|
-
Record<
|
|
46
|
-
| 'perspective'
|
|
47
|
-
| 'scale'
|
|
48
|
-
| 'scaleX'
|
|
49
|
-
| 'scaleY'
|
|
50
|
-
| 'translateX'
|
|
51
|
-
| 'translateY',
|
|
52
|
-
number | AnimationObject
|
|
53
|
-
>
|
|
54
|
-
>
|
|
55
|
-
| Partial<
|
|
56
|
-
Record<
|
|
57
|
-
'rotate' | 'rotateX' | 'rotateY' | 'rotateZ' | 'skewX' | 'skewY',
|
|
58
|
-
string | AnimationObject
|
|
59
|
-
>
|
|
60
|
-
>
|
|
61
|
-
| Record<string, AnimationObject>
|
|
62
|
-
>;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
40
|
export interface SharedValue<T> {
|
|
66
41
|
value: T;
|
|
67
42
|
addListener: (listenerID: number, listener: (value: T) => void) => void;
|
|
@@ -41,6 +41,8 @@ interface ReanimatedFlatListPropsWithLayout<T> extends FlatListProps<T> {
|
|
|
41
41
|
itemLayoutAnimation?: ILayoutAnimationBuilder;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
export type FlatListPropsWithLayout<T> = ReanimatedFlatListPropsWithLayout<T>;
|
|
45
|
+
|
|
44
46
|
// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
|
|
45
47
|
declare class ReanimatedFlatListClass<T> extends Component<
|
|
46
48
|
AnimateProps<ReanimatedFlatListPropsWithLayout<T>>
|
|
@@ -48,7 +50,7 @@ declare class ReanimatedFlatListClass<T> extends Component<
|
|
|
48
50
|
getNode(): FlatList;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
interface ReanimatedFlatListProps<ItemT> extends FlatListProps<ItemT> {
|
|
52
54
|
itemLayoutAnimation?: ILayoutAnimationBuilder;
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -7,7 +7,7 @@ import type { SharedValue } from '../commonTypes';
|
|
|
7
7
|
import type { AnimateProps } from '../helperTypes';
|
|
8
8
|
import { useAnimatedRef, useScrollViewOffset } from '../hook';
|
|
9
9
|
|
|
10
|
-
interface AnimatedScrollViewProps extends ScrollViewProps {
|
|
10
|
+
export interface AnimatedScrollViewProps extends ScrollViewProps {
|
|
11
11
|
scrollViewOffset?: SharedValue<number>;
|
|
12
12
|
}
|
|
13
13
|
|
package/src/reanimated2/core.ts
CHANGED
|
@@ -30,6 +30,22 @@ export type ReanimatedConsole = Pick<
|
|
|
30
30
|
'debug' | 'log' | 'warn' | 'info' | 'error'
|
|
31
31
|
>;
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* @returns `true` in Reanimated 3, doesn't exist in Reanimated 2 or 1
|
|
35
|
+
*/
|
|
36
|
+
export const isReanimated3 = () => true;
|
|
37
|
+
|
|
38
|
+
// Superseded by check in `/src/threads.ts`.
|
|
39
|
+
// Used by `react-navigation` to detect if using Reanimated 2 or 3.
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated This function was superseded by other checks.
|
|
42
|
+
* We keep it here for backward compatibility reasons.
|
|
43
|
+
* If you need to check if you are using Reanimated 3 or Reanimated 2
|
|
44
|
+
* please use `isReanimated3` function instead.
|
|
45
|
+
* @returns `true` in Reanimated 3, doesn't exist in Reanimated 2
|
|
46
|
+
*/
|
|
47
|
+
export const isConfigured = isReanimated3;
|
|
48
|
+
|
|
33
49
|
// this is for web implementation
|
|
34
50
|
global._WORKLET = false;
|
|
35
51
|
global._log = function (s: string) {
|
|
@@ -14,6 +14,7 @@ let findHostInstance_DEPRECATED: (ref: React.Component) => HostInstance;
|
|
|
14
14
|
if (global._IS_FABRIC) {
|
|
15
15
|
try {
|
|
16
16
|
findHostInstance_DEPRECATED =
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
17
18
|
require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
|
|
18
19
|
} catch (e) {
|
|
19
20
|
throw new Error(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
/* eslint-disable no-var */
|
|
3
3
|
import type {
|
|
4
|
-
AnimatedStyle,
|
|
5
4
|
StyleProps,
|
|
6
5
|
MeasuredDimensions,
|
|
7
6
|
MapperRegistry,
|
|
@@ -10,6 +9,7 @@ import type {
|
|
|
10
9
|
ShadowNodeWrapper,
|
|
11
10
|
ComplexWorkletFunction,
|
|
12
11
|
} from './commonTypes';
|
|
12
|
+
import type { AnimatedStyle } from './helperTypes';
|
|
13
13
|
import type { FrameCallbackRegistryUI } from './frameCallback/FrameCallbackRegistryUI';
|
|
14
14
|
import type { NativeReanimatedModule } from './NativeReanimated/NativeReanimated';
|
|
15
15
|
import type { SensorContainer } from './SensorContainer';
|
|
@@ -49,7 +49,7 @@ declare global {
|
|
|
49
49
|
operations: {
|
|
50
50
|
tag: number;
|
|
51
51
|
name: string;
|
|
52
|
-
updates: StyleProps | AnimatedStyle
|
|
52
|
+
updates: StyleProps | AnimatedStyle<any>;
|
|
53
53
|
}[]
|
|
54
54
|
) => void)
|
|
55
55
|
| undefined;
|
|
@@ -57,7 +57,7 @@ declare global {
|
|
|
57
57
|
| ((
|
|
58
58
|
operations: {
|
|
59
59
|
shadowNodeWrapper: ShadowNodeWrapper;
|
|
60
|
-
updates: StyleProps | AnimatedStyle
|
|
60
|
+
updates: StyleProps | AnimatedStyle<any>;
|
|
61
61
|
}[]
|
|
62
62
|
) => void)
|
|
63
63
|
| undefined;
|
|
@@ -23,21 +23,28 @@ import type { ReanimatedKeyframe } from './layoutReanimation/animationBuilder/Ke
|
|
|
23
23
|
import type { SharedTransition } from './layoutReanimation/sharedTransitions';
|
|
24
24
|
import type { DependencyList } from './hook/commonTypes';
|
|
25
25
|
|
|
26
|
-
type Adaptable<T> =
|
|
26
|
+
export type Adaptable<T> =
|
|
27
|
+
| T
|
|
28
|
+
| ReadonlyArray<T | ReadonlyArray<T>>
|
|
29
|
+
| SharedValue<T>;
|
|
27
30
|
|
|
28
|
-
type AdaptTransforms<T> = {
|
|
31
|
+
export type AdaptTransforms<T> = {
|
|
29
32
|
[P in keyof T]: Adaptable<T[P]>;
|
|
30
33
|
};
|
|
31
34
|
|
|
32
35
|
type TransformsStyle = Pick<RNTransformsStyle, 'transform'>;
|
|
33
36
|
|
|
34
|
-
type TransformStyleTypes = TransformsStyle['transform'] extends
|
|
37
|
+
export type TransformStyleTypes = TransformsStyle['transform'] extends
|
|
35
38
|
| readonly (infer T)[]
|
|
39
|
+
| string
|
|
36
40
|
| undefined
|
|
37
41
|
? T
|
|
38
42
|
: never;
|
|
39
|
-
type AnimatedTransform = AdaptTransforms<TransformStyleTypes>[];
|
|
43
|
+
export type AnimatedTransform = AdaptTransforms<TransformStyleTypes>[];
|
|
40
44
|
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Please use `AnimatedStyle` type instead.
|
|
47
|
+
*/
|
|
41
48
|
export type AnimateStyle<S> = {
|
|
42
49
|
[K in keyof S]: K extends 'transform'
|
|
43
50
|
? AnimatedTransform
|
|
@@ -50,13 +57,15 @@ export type AnimateStyle<S> = {
|
|
|
50
57
|
: S[K] | SharedValue<AnimatableValue>;
|
|
51
58
|
};
|
|
52
59
|
|
|
60
|
+
export type AnimatedStyle<S> = AnimateStyle<S>;
|
|
61
|
+
|
|
53
62
|
// provided types can either be their original types (like backgroundColor: pink)
|
|
54
63
|
// or inline shared values/derived values
|
|
55
64
|
type MaybeSharedValue<S> = {
|
|
56
65
|
[K in keyof S]: S[K] | Readonly<SharedValue<Extract<S[K], AnimatableValue>>>;
|
|
57
66
|
};
|
|
58
67
|
|
|
59
|
-
type StylesOrDefault<T> = 'style' extends keyof T
|
|
68
|
+
export type StylesOrDefault<T> = 'style' extends keyof T
|
|
60
69
|
? MaybeSharedValue<T['style']>
|
|
61
70
|
: Record<string, unknown>;
|
|
62
71
|
|
|
@@ -81,12 +90,12 @@ type PickStyleProps<T> = Pick<
|
|
|
81
90
|
|
|
82
91
|
type StyleAnimatedProps<P extends object> = {
|
|
83
92
|
[K in keyof PickStyleProps<P>]: StyleProp<
|
|
84
|
-
|
|
93
|
+
AnimatedStyle<P[K] | MaybeSharedValue<P[K]>>
|
|
85
94
|
>;
|
|
86
95
|
};
|
|
87
96
|
|
|
88
97
|
type JustStyleAnimatedProp<P extends object> = {
|
|
89
|
-
style?: StyleProp<
|
|
98
|
+
style?: StyleProp<AnimatedStyle<StylesOrDefault<P>>>;
|
|
90
99
|
};
|
|
91
100
|
|
|
92
101
|
type NonStyleAnimatedProps<P extends object> = {
|
|
@@ -123,6 +132,7 @@ export type AnimateProps<P extends object> = NonStyleAnimatedProps<P> &
|
|
|
123
132
|
animatedProps?: Partial<AnimatedPropsProp<P>>;
|
|
124
133
|
};
|
|
125
134
|
|
|
135
|
+
// ts-prune-ignore-next This will be used soon
|
|
126
136
|
export type AnimatedProps<P extends object> = AnimateProps<P>;
|
|
127
137
|
|
|
128
138
|
export type AnimatedPropsAdapterFunction = (
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Component } from 'react';
|
|
1
2
|
import type { Context, ShadowNodeWrapper } from '../commonTypes';
|
|
2
3
|
|
|
3
4
|
export type DependencyList = Array<unknown> | undefined;
|
|
@@ -13,12 +14,10 @@ export interface Descriptor {
|
|
|
13
14
|
shadowNodeWrapper: ShadowNodeWrapper;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
export interface
|
|
17
|
+
export interface AnimatedRef<T extends Component> {
|
|
17
18
|
current: T | null;
|
|
18
19
|
(component?: T):
|
|
19
20
|
| number // Paper
|
|
20
21
|
| ShadowNodeWrapper // Fabric
|
|
21
22
|
| HTMLElement; // web
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
export type AnimatedRef<T> = RefObjectFunction<T>;
|
|
@@ -8,7 +8,10 @@ export {
|
|
|
8
8
|
export { useSharedValue } from './useSharedValue';
|
|
9
9
|
export { useReducedMotion } from './useReducedMotion';
|
|
10
10
|
export { useAnimatedStyle } from './useAnimatedStyle';
|
|
11
|
-
export type {
|
|
11
|
+
export type {
|
|
12
|
+
AnimatedStyleResult,
|
|
13
|
+
AnimatedStyleProp,
|
|
14
|
+
} from './useAnimatedStyle';
|
|
12
15
|
export { useAnimatedGestureHandler } from './useAnimatedGestureHandler';
|
|
13
16
|
export type {
|
|
14
17
|
GestureHandlerEvent,
|
|
@@ -16,7 +16,7 @@ export interface GestureHandlers<T, TContext extends Context> {
|
|
|
16
16
|
onFinish?: Handler<T, TContext>;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const EventType = {
|
|
20
20
|
UNDETERMINED: 0,
|
|
21
21
|
FAILED: 1,
|
|
22
22
|
BEGAN: 2,
|
|
@@ -25,7 +25,7 @@ export const EventType = {
|
|
|
25
25
|
END: 5,
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
interface GestureHandlerNativeEvent {
|
|
29
29
|
handlerTag: number;
|
|
30
30
|
numberOfPointers: number;
|
|
31
31
|
state: (typeof EventType)[keyof typeof EventType];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Component } from 'react';
|
|
2
2
|
import { useRef } from 'react';
|
|
3
3
|
import { useSharedValue } from './useSharedValue';
|
|
4
|
-
import type { AnimatedRef
|
|
4
|
+
import type { AnimatedRef } from './commonTypes';
|
|
5
5
|
import type { ShadowNodeWrapper } from '../commonTypes';
|
|
6
6
|
import { getShadowNodeWrapperFromRef } from '../fabricUtils';
|
|
7
7
|
import {
|
|
@@ -9,13 +9,14 @@ import {
|
|
|
9
9
|
registerShareableMapping,
|
|
10
10
|
} from '../shareables';
|
|
11
11
|
import { findNodeHandle } from 'react-native';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
getNativeScrollRef?:
|
|
15
|
-
|
|
12
|
+
interface MaybeScrollableComponent extends Component {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
getNativeScrollRef?: any;
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
getScrollableNode?: any;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
function
|
|
19
|
+
function getComponentOrScrollable(component: MaybeScrollableComponent) {
|
|
19
20
|
if (global._IS_FABRIC && component.getNativeScrollRef) {
|
|
20
21
|
return component.getNativeScrollRef();
|
|
21
22
|
} else if (!global._IS_FABRIC && component.getScrollableNode) {
|
|
@@ -28,15 +29,17 @@ const getTagValueFunction = global._IS_FABRIC
|
|
|
28
29
|
? getShadowNodeWrapperFromRef
|
|
29
30
|
: findNodeHandle;
|
|
30
31
|
|
|
31
|
-
export function useAnimatedRef<
|
|
32
|
+
export function useAnimatedRef<
|
|
33
|
+
T extends MaybeScrollableComponent
|
|
34
|
+
>(): AnimatedRef<T> {
|
|
32
35
|
const tag = useSharedValue<number | ShadowNodeWrapper | null>(-1);
|
|
33
|
-
const ref = useRef<
|
|
36
|
+
const ref = useRef<AnimatedRef<T>>();
|
|
34
37
|
|
|
35
38
|
if (!ref.current) {
|
|
36
|
-
const fun:
|
|
39
|
+
const fun: AnimatedRef<T> = <AnimatedRef<T>>((component) => {
|
|
37
40
|
// enters when ref is set by attaching to a component
|
|
38
41
|
if (component) {
|
|
39
|
-
tag.value = getTagValueFunction(
|
|
42
|
+
tag.value = getTagValueFunction(getComponentOrScrollable(component));
|
|
40
43
|
fun.current = component;
|
|
41
44
|
}
|
|
42
45
|
return tag.value;
|