react-native-reanimated 3.19.3 → 3.19.5
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/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp +34 -8
- package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +26 -2
- package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +1 -1
- package/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.cpp +25 -5
- package/Common/cpp/reanimated/RuntimeDecorators/RNRuntimeDecorator.h +7 -0
- package/Common/cpp/reanimated/Tools/ReanimatedSystraceSection.h +1 -1
- package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +5 -0
- package/android/CMakeLists.txt +12 -9
- package/apple/reanimated/apple/LayoutReanimation/REASharedTransitionManager.m +1 -2
- package/apple/reanimated/apple/LayoutReanimation/REASwizzledUIManager.mm +10 -9
- package/lib/module/ReanimatedModule/NativeReanimated.js.map +1 -1
- package/lib/module/ReanimatedModule/js-reanimated/index.js.map +1 -1
- package/lib/module/commonTypes.js.map +1 -1
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js +14 -6
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
- package/lib/module/fabricUtils.js +5 -28
- package/lib/module/fabricUtils.js.map +1 -1
- package/lib/module/hook/useAnimatedRef.js +7 -6
- package/lib/module/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/layoutReanimation/web/animationsManager.js +2 -2
- package/lib/module/layoutReanimation/web/animationsManager.js.map +1 -1
- package/lib/module/layoutReanimation/web/componentUtils.js +46 -5
- package/lib/module/layoutReanimation/web/componentUtils.js.map +1 -1
- package/lib/module/layoutReanimation/web/createAnimation.js +45 -36
- package/lib/module/layoutReanimation/web/createAnimation.js.map +1 -1
- package/lib/module/layoutReanimation/web/domUtils.js +1 -1
- package/lib/module/layoutReanimation/web/domUtils.js.map +1 -1
- package/lib/module/layoutReanimation/web/transition/Curved.web.js +1 -1
- package/lib/module/layoutReanimation/web/transition/Curved.web.js.map +1 -1
- package/lib/module/mock.js +1 -1
- package/lib/module/mock.js.map +1 -1
- package/lib/module/platform-specific/findHostInstance.js.map +1 -1
- package/lib/module/platform-specific/jsVersion.js +1 -1
- package/lib/typescript/ReanimatedModule/js-reanimated/index.d.ts +2 -1
- package/lib/typescript/ReanimatedModule/js-reanimated/index.d.ts.map +1 -1
- package/lib/typescript/commonTypes.d.ts +7 -2
- package/lib/typescript/commonTypes.d.ts.map +1 -1
- package/lib/typescript/fabricUtils.d.ts +2 -2
- package/lib/typescript/fabricUtils.d.ts.map +1 -1
- package/lib/typescript/hook/useAnimatedRef.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/animationsManager.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/componentUtils.d.ts +1 -1
- package/lib/typescript/layoutReanimation/web/componentUtils.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/createAnimation.d.ts +3 -2
- package/lib/typescript/layoutReanimation/web/createAnimation.d.ts.map +1 -1
- package/lib/typescript/platform-specific/findHostInstance.d.ts +2 -2
- package/lib/typescript/platform-specific/findHostInstance.d.ts.map +1 -1
- package/lib/typescript/platform-specific/jsVersion.d.ts +1 -1
- package/package.json +2 -2
- package/src/ReanimatedModule/NativeReanimated.ts +1 -3
- package/src/ReanimatedModule/js-reanimated/index.ts +2 -1
- package/src/commonTypes.ts +14 -1
- package/src/createAnimatedComponent/createAnimatedComponent.tsx +15 -7
- package/src/fabricUtils.ts +11 -38
- package/src/hook/useAnimatedRef.ts +7 -6
- package/src/layoutReanimation/web/animationsManager.ts +4 -2
- package/src/layoutReanimation/web/componentUtils.ts +60 -6
- package/src/layoutReanimation/web/createAnimation.ts +60 -38
- package/src/layoutReanimation/web/domUtils.ts +1 -1
- package/src/layoutReanimation/web/transition/Curved.web.ts +1 -1
- package/src/mock.ts +1 -1
- package/src/platform-specific/findHostInstance.ts +2 -1
- package/src/platform-specific/jsVersion.ts +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import type { TransformsStyle } from 'react-native';
|
|
4
4
|
|
|
5
|
+
import { LayoutAnimationType } from '../../commonTypes';
|
|
5
6
|
import type {
|
|
6
7
|
AnimationData,
|
|
7
8
|
ReanimatedWebTransformProperties,
|
|
@@ -19,6 +20,26 @@ import { LinearTransition } from './transition/Linear.web';
|
|
|
19
20
|
import { SequencedTransition } from './transition/Sequenced.web';
|
|
20
21
|
|
|
21
22
|
type TransformType = NonNullable<TransformsStyle['transform']>;
|
|
23
|
+
type TransformValue = string | number;
|
|
24
|
+
|
|
25
|
+
function maybeAddPx(value: string | number) {
|
|
26
|
+
return typeof value === 'number' ? `${value}px` : value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function assignTransformRules(
|
|
30
|
+
map: Map<string, TransformValue>,
|
|
31
|
+
transform?: ReanimatedWebTransformProperties[]
|
|
32
|
+
) {
|
|
33
|
+
if (!transform) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const rule of transform) {
|
|
38
|
+
for (const [property, value] of Object.entries(rule)) {
|
|
39
|
+
map.set(property, value as TransformValue);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
22
43
|
|
|
23
44
|
// Translate values are passed as numbers. However, if `translate` property receives number, it will not automatically
|
|
24
45
|
// convert it to `px`. Therefore if we want to keep transform we have to add 'px' suffix to each of translate values
|
|
@@ -52,7 +73,8 @@ function addPxToTransform(transform: TransformType) {
|
|
|
52
73
|
}
|
|
53
74
|
|
|
54
75
|
export function createCustomKeyFrameAnimation(
|
|
55
|
-
keyframeDefinitions: KeyframeDefinitions
|
|
76
|
+
keyframeDefinitions: KeyframeDefinitions,
|
|
77
|
+
animationType: LayoutAnimationType
|
|
56
78
|
) {
|
|
57
79
|
for (const value of Object.values(keyframeDefinitions)) {
|
|
58
80
|
if (value.transform) {
|
|
@@ -66,7 +88,7 @@ export function createCustomKeyFrameAnimation(
|
|
|
66
88
|
duration: -1,
|
|
67
89
|
};
|
|
68
90
|
|
|
69
|
-
animationData.name = generateNextCustomKeyframeName();
|
|
91
|
+
animationData.name = generateNextCustomKeyframeName(animationType);
|
|
70
92
|
|
|
71
93
|
// Move keyframe easings one keyframe up (our LA Keyframe definition is different
|
|
72
94
|
// from the CSS keyframes and expects easing to be present in the keyframe to which
|
|
@@ -92,46 +114,36 @@ export function createCustomKeyFrameAnimation(
|
|
|
92
114
|
|
|
93
115
|
export function createAnimationWithInitialValues(
|
|
94
116
|
animationName: string,
|
|
95
|
-
initialValues: InitialValuesStyleProps
|
|
117
|
+
initialValues: InitialValuesStyleProps,
|
|
118
|
+
animationType: LayoutAnimationType
|
|
96
119
|
) {
|
|
97
120
|
const animationStyle = structuredClone(AnimationsData[animationName].style);
|
|
98
121
|
const firstAnimationStep = animationStyle['0'];
|
|
99
122
|
|
|
100
|
-
const { transform, ...rest } = initialValues;
|
|
123
|
+
const { transform, originX, originY, ...rest } = initialValues;
|
|
124
|
+
|
|
125
|
+
const transformStyle = new Map<string, TransformValue>();
|
|
126
|
+
assignTransformRules(transformStyle, firstAnimationStep.transform);
|
|
101
127
|
|
|
102
128
|
if (transform) {
|
|
103
129
|
const transformWithPx = addPxToTransform(transform as TransformType);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
firstAnimationStep.transform = transformWithPx;
|
|
107
|
-
} else {
|
|
108
|
-
// Othwerwise we have to merge predefined transform with the one provided in `initialValues`.
|
|
109
|
-
// To do that, we create `Map` that will contain final transform.
|
|
110
|
-
const transformStyle = new Map<string, any>();
|
|
111
|
-
|
|
112
|
-
// First we assign all of the predefined rules
|
|
113
|
-
for (const rule of firstAnimationStep.transform) {
|
|
114
|
-
// In most cases there will be just one iteration
|
|
115
|
-
for (const [property, value] of Object.entries(rule)) {
|
|
116
|
-
transformStyle.set(property, value);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
130
|
+
assignTransformRules(transformStyle, transformWithPx);
|
|
131
|
+
}
|
|
119
132
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
transformStyle.set(property, value);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
133
|
+
if (originX !== undefined) {
|
|
134
|
+
transformStyle.set('translateX', maybeAddPx(originX));
|
|
135
|
+
}
|
|
126
136
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
if (originY !== undefined) {
|
|
138
|
+
transformStyle.set('translateY', maybeAddPx(originY));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const mergedTransform = Array.from(transformStyle, ([property, value]) => ({
|
|
142
|
+
[property]: value,
|
|
143
|
+
}));
|
|
144
|
+
|
|
145
|
+
if (transformStyle.size) {
|
|
146
|
+
firstAnimationStep.transform = mergedTransform;
|
|
135
147
|
}
|
|
136
148
|
|
|
137
149
|
animationStyle['0'] = {
|
|
@@ -140,7 +152,7 @@ export function createAnimationWithInitialValues(
|
|
|
140
152
|
};
|
|
141
153
|
|
|
142
154
|
// TODO: Maybe we can extract the logic below into separate function
|
|
143
|
-
const keyframeName = generateNextCustomKeyframeName();
|
|
155
|
+
const keyframeName = generateNextCustomKeyframeName(animationType);
|
|
144
156
|
|
|
145
157
|
const animationObject: AnimationData = {
|
|
146
158
|
name: keyframeName,
|
|
@@ -157,8 +169,14 @@ export function createAnimationWithInitialValues(
|
|
|
157
169
|
|
|
158
170
|
let customKeyframeCounter = 0;
|
|
159
171
|
|
|
160
|
-
|
|
161
|
-
|
|
172
|
+
const ANIMATION_TYPE_STRINGS: Partial<Record<LayoutAnimationType, string>> = {
|
|
173
|
+
[LayoutAnimationType.ENTERING]: 'ENTERING',
|
|
174
|
+
[LayoutAnimationType.EXITING]: 'EXITING',
|
|
175
|
+
[LayoutAnimationType.LAYOUT]: 'LAYOUT',
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
function generateNextCustomKeyframeName(animationType: LayoutAnimationType) {
|
|
179
|
+
return `REA-${ANIMATION_TYPE_STRINGS[animationType] ?? ''}-${customKeyframeCounter++}`;
|
|
162
180
|
}
|
|
163
181
|
|
|
164
182
|
/**
|
|
@@ -174,7 +192,9 @@ export function TransitionGenerator(
|
|
|
174
192
|
transitionType: TransitionType,
|
|
175
193
|
transitionData: TransitionData
|
|
176
194
|
) {
|
|
177
|
-
const transitionKeyframeName = generateNextCustomKeyframeName(
|
|
195
|
+
const transitionKeyframeName = generateNextCustomKeyframeName(
|
|
196
|
+
LayoutAnimationType.LAYOUT
|
|
197
|
+
);
|
|
178
198
|
let dummyTransitionKeyframeName;
|
|
179
199
|
|
|
180
200
|
let transitionObject;
|
|
@@ -207,7 +227,9 @@ export function TransitionGenerator(
|
|
|
207
227
|
|
|
208
228
|
// Here code block with {} is necessary because of eslint
|
|
209
229
|
case TransitionType.CURVED: {
|
|
210
|
-
dummyTransitionKeyframeName = generateNextCustomKeyframeName(
|
|
230
|
+
dummyTransitionKeyframeName = generateNextCustomKeyframeName(
|
|
231
|
+
LayoutAnimationType.LAYOUT
|
|
232
|
+
);
|
|
211
233
|
|
|
212
234
|
const { firstKeyframeObj, secondKeyframeObj } = CurvedTransition(
|
|
213
235
|
transitionKeyframeName,
|
|
@@ -176,7 +176,7 @@ function findDescendantWithExitingAnimation(
|
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
if (node.
|
|
179
|
+
if (node.isDummy && node.removedAfterAnimation === undefined) {
|
|
180
180
|
reattachElementToAncestor(node, root);
|
|
181
181
|
}
|
|
182
182
|
|
package/src/mock.ts
CHANGED
|
@@ -321,7 +321,7 @@ const core = {
|
|
|
321
321
|
const layoutReanimation = {
|
|
322
322
|
BaseAnimationBuilder: new BaseAnimationMock(),
|
|
323
323
|
ComplexAnimationBuilder: new BaseAnimationMock(),
|
|
324
|
-
Keyframe:
|
|
324
|
+
Keyframe: BaseAnimationMock,
|
|
325
325
|
// Flip
|
|
326
326
|
FlipInXUp: new BaseAnimationMock(),
|
|
327
327
|
FlipInYLeft: new BaseAnimationMock(),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable camelcase */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
import type { InternalHostInstance } from '../commonTypes';
|
|
4
5
|
import type { IAnimatedComponentInternal } from '../createAnimatedComponent/commonTypes';
|
|
5
6
|
import { ReanimatedError } from '../errors';
|
|
6
7
|
import { isFabric } from '../PlatformChecker';
|
|
@@ -68,7 +69,7 @@ function resolveFindHostInstance_DEPRECATED() {
|
|
|
68
69
|
|
|
69
70
|
let findHostInstance_DEPRECATED: (ref: unknown) => HostInstance;
|
|
70
71
|
export function findHostInstance(
|
|
71
|
-
component: IAnimatedComponentInternal |
|
|
72
|
+
component: IAnimatedComponentInternal | InternalHostInstance
|
|
72
73
|
): HostInstance {
|
|
73
74
|
// Fast path for native refs
|
|
74
75
|
const hostInstance = findHostInstanceFastPath(
|