@tamagui/animations-reanimated 2.7.7 → 3.0.0-beta.643.1
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/dist/cjs/createAnimations.cjs +940 -897
- package/dist/cjs/createAnimations.native.cjs +1196 -0
- package/dist/cjs/createAnimations.native.js +1138 -1115
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/createAnimations.mjs +926 -873
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +1125 -1093
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.native.js +1 -2
- package/package.json +8 -8
- package/src/createAnimations.tsx +264 -89
- package/types/createAnimations.d.ts.map +2 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
|
@@ -1,923 +1,976 @@
|
|
|
1
1
|
import { getEffectiveAnimation, normalizeTransition } from "@tamagui/animation-helpers";
|
|
2
|
-
import { getSplitStyles, hooks, isWeb,
|
|
2
|
+
import { Text, View, createRefComponent, getSplitStyles, hooks, isWeb, useComposedRefs, useEvent, useIsomorphicLayoutEffect, useThemeWithState } from "@tamagui/core";
|
|
3
3
|
import { ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
4
4
|
import normalizeColor from "@react-native/normalize-colors";
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { useMemo, useRef } from "react";
|
|
6
6
|
import Animated_, { cancelAnimation, runOnJS, runOnUI, useAnimatedReaction, useAnimatedStyle, useDerivedValue, useSharedValue, withDelay, withSpring, withTiming } from "react-native-reanimated";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
|
|
9
|
+
const getDefaultExport = (module) => {
|
|
10
|
+
const mod = module;
|
|
11
|
+
if (mod.__esModule || mod[Symbol.toStringTag] === "Module") {
|
|
12
|
+
return mod.default || mod;
|
|
13
|
+
}
|
|
14
|
+
return mod;
|
|
14
15
|
};
|
|
15
16
|
const Animated = getDefaultExport(Animated_);
|
|
16
|
-
const silenceAnimatedComponentDevCheck = style => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
const silenceAnimatedComponentDevCheck = (style) => {
|
|
18
|
+
if (process.env.NODE_ENV !== "development" || isWeb || !style || typeof style !== "object") {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(style, "_requiresAnimatedComponent", {
|
|
22
|
+
configurable: true,
|
|
23
|
+
enumerable: false,
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
25
26
|
};
|
|
26
27
|
const resolveDynamicValue = (value, isDark) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
if (value !== null && typeof value === "object" && "dynamic" in value && typeof value.dynamic === "object") {
|
|
29
|
+
const dynamic = value.dynamic;
|
|
30
|
+
return isDark ? dynamic.dark : dynamic.light;
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
32
33
|
};
|
|
33
34
|
const updateMapperState = isWeb ? (state, emitted) => {
|
|
34
|
-
|
|
35
|
+
state.value.emitted = emitted;
|
|
35
36
|
} : (state, emitted) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, false);
|
|
37
|
+
"worklet";
|
|
38
|
+
if (!globalThis._WORKLET) return;
|
|
39
|
+
state.modify((current) => {
|
|
40
|
+
current.emitted = emitted;
|
|
41
|
+
return current;
|
|
42
|
+
}, false);
|
|
43
43
|
};
|
|
44
|
-
const cloneAnimationValue = value => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
const cloneAnimationValue = (value) => {
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
return value.map(cloneAnimationValue);
|
|
47
|
+
}
|
|
48
|
+
if (value && typeof value === "object") {
|
|
49
|
+
const next = {};
|
|
50
|
+
for (const key in value) {
|
|
51
|
+
next[key] = cloneAnimationValue(value[key]);
|
|
52
|
+
}
|
|
53
|
+
return next;
|
|
54
|
+
}
|
|
55
|
+
return value;
|
|
56
56
|
};
|
|
57
|
-
const cloneStyleRecord = style => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
const cloneStyleRecord = (style) => {
|
|
58
|
+
const next = {};
|
|
59
|
+
for (const key in style) {
|
|
60
|
+
next[key] = cloneAnimationValue(style[key]);
|
|
61
|
+
}
|
|
62
|
+
return next;
|
|
63
63
|
};
|
|
64
|
-
const cloneTransitionConfig = config => {
|
|
65
|
-
|
|
64
|
+
const cloneTransitionConfig = (config) => {
|
|
65
|
+
return cloneAnimationValue(config);
|
|
66
66
|
};
|
|
67
|
-
const getAnimatedTransforms = value => {
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const getAnimatedTransforms = (value) => {
|
|
68
|
+
if (!Array.isArray(value)) return [];
|
|
69
|
+
return value.filter((item) => item !== null && typeof item === "object" && !Array.isArray(item));
|
|
70
70
|
};
|
|
71
71
|
const getRemovedAnimatedKeys = (current, previous) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
const removedKeys = {};
|
|
73
|
+
for (const key of previous) {
|
|
74
|
+
if (!current.has(key)) removedKeys[key] = true;
|
|
75
|
+
}
|
|
76
|
+
return removedKeys;
|
|
77
77
|
};
|
|
78
78
|
const getImplicitDefault = (key, targetValue) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return suffixIndex > 0 ? `${value}${targetValue.slice(suffixIndex)}` : value;
|
|
79
|
+
"worklet";
|
|
80
|
+
const value = key === "opacity" || key === "scale" || key === "scaleX" || key === "scaleY" ? 1 : 0;
|
|
81
|
+
if (typeof targetValue !== "string") return value;
|
|
82
|
+
let suffixIndex = 0;
|
|
83
|
+
while (suffixIndex < targetValue.length) {
|
|
84
|
+
const character = targetValue[suffixIndex];
|
|
85
|
+
const code = character.charCodeAt(0);
|
|
86
|
+
if (code >= 48 && code <= 57 || character === "." || character === "-" || character === "+") {
|
|
87
|
+
suffixIndex++;
|
|
88
|
+
} else {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return suffixIndex > 0 ? `${value}${targetValue.slice(suffixIndex)}` : value;
|
|
94
93
|
};
|
|
95
94
|
const COLOR_STYLE_KEYS = {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
backgroundColor: true,
|
|
96
|
+
borderColor: true,
|
|
97
|
+
borderLeftColor: true,
|
|
98
|
+
borderRightColor: true,
|
|
99
|
+
borderTopColor: true,
|
|
100
|
+
borderBottomColor: true,
|
|
101
|
+
color: true
|
|
103
102
|
};
|
|
104
|
-
const toReanimatedColor = value => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return trimmed;
|
|
103
|
+
const toReanimatedColor = (value) => {
|
|
104
|
+
"worklet";
|
|
105
|
+
if (typeof value === "number") {
|
|
106
|
+
const color = value >>> 0;
|
|
107
|
+
const alpha = (color >>> 24 & 255) / 255;
|
|
108
|
+
const red = color >>> 16 & 255;
|
|
109
|
+
const green = color >>> 8 & 255;
|
|
110
|
+
const blue = color & 255;
|
|
111
|
+
return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
112
|
+
}
|
|
113
|
+
if (typeof value !== "string") return value;
|
|
114
|
+
const trimmed = value.trim();
|
|
115
|
+
if (trimmed === "transparent") return "rgba(0, 0, 0, 0)";
|
|
116
|
+
return trimmed;
|
|
119
117
|
};
|
|
120
|
-
const isReanimatedColorHistory = value => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return typeof normalized === "string" && normalized.startsWith("rgba(");
|
|
118
|
+
const isReanimatedColorHistory = (value) => {
|
|
119
|
+
"worklet";
|
|
120
|
+
const normalized = toReanimatedColor(value);
|
|
121
|
+
return typeof normalized === "string" && normalized.startsWith("rgba(");
|
|
125
122
|
};
|
|
126
|
-
const normalizeAnimationColor = value => {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
123
|
+
const normalizeAnimationColor = (value) => {
|
|
124
|
+
if (typeof value === "number") {
|
|
125
|
+
return toReanimatedColor(value);
|
|
126
|
+
}
|
|
127
|
+
if (typeof value !== "string") return;
|
|
128
|
+
const color = normalizeColor(value);
|
|
129
|
+
if (color == null) return;
|
|
130
|
+
const red = Math.round((color & 4278190080) >>> 24);
|
|
131
|
+
const green = Math.round((color & 16711680) >>> 16);
|
|
132
|
+
const blue = Math.round((color & 65280) >>> 8);
|
|
133
|
+
const alpha = (color & 255) / 255;
|
|
134
|
+
return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
138
135
|
};
|
|
139
136
|
const buildSnapshot = (animated, statics, transforms, previousKeys, lastPainted) => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
137
|
+
const snapshotAnimated = {};
|
|
138
|
+
const snapshotStatics = cloneStyleRecord(statics);
|
|
139
|
+
for (const key in snapshotStatics) {
|
|
140
|
+
if (!COLOR_STYLE_KEYS[key]) continue;
|
|
141
|
+
const normalized = normalizeAnimationColor(snapshotStatics[key]);
|
|
142
|
+
if (normalized !== void 0) snapshotStatics[key] = normalized;
|
|
143
|
+
}
|
|
144
|
+
for (const key in animated) {
|
|
145
|
+
if (key === "transform") continue;
|
|
146
|
+
const value = animated[key];
|
|
147
|
+
if (COLOR_STYLE_KEYS[key]) {
|
|
148
|
+
const normalized = normalizeAnimationColor(value);
|
|
149
|
+
if (normalized === void 0) {
|
|
150
|
+
snapshotStatics[key] = cloneAnimationValue(value);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
snapshotAnimated[key] = normalized;
|
|
154
|
+
} else {
|
|
155
|
+
snapshotAnimated[key] = cloneAnimationValue(value);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const snapshotTransforms = transforms.map(cloneStyleRecord);
|
|
159
|
+
const keys = new Set(Object.keys(snapshotAnimated));
|
|
160
|
+
for (const transform of snapshotTransforms) {
|
|
161
|
+
const key = Object.keys(transform)[0];
|
|
162
|
+
const value = key ? transform[key] : void 0;
|
|
163
|
+
if (key && (typeof value === "number" || typeof value === "string")) {
|
|
164
|
+
keys.add(`transform:${key}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const seeds = {};
|
|
168
|
+
for (const key of keys) {
|
|
169
|
+
let value = lastPainted[key];
|
|
170
|
+
if (typeof value !== "number" && typeof value !== "string") continue;
|
|
171
|
+
if (value === "auto" || typeof value === "string" && value.startsWith("calc")) {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (COLOR_STYLE_KEYS[key]) value = normalizeAnimationColor(value);
|
|
175
|
+
if (value !== void 0) seeds[key] = value;
|
|
176
|
+
}
|
|
177
|
+
const gatedKeys = {};
|
|
178
|
+
for (const key of keys) gatedKeys[key] = true;
|
|
179
|
+
const removedKeys = getRemovedAnimatedKeys(keys, previousKeys);
|
|
180
|
+
const painted = {
|
|
181
|
+
...snapshotStatics,
|
|
182
|
+
...snapshotAnimated
|
|
183
|
+
};
|
|
184
|
+
const staticTransforms = getAnimatedTransforms(snapshotStatics.transform);
|
|
185
|
+
delete painted.transform;
|
|
186
|
+
for (const transform of staticTransforms) {
|
|
187
|
+
const key = Object.keys(transform)[0];
|
|
188
|
+
if (key) painted[`transform:${key}`] = transform[key];
|
|
189
|
+
}
|
|
190
|
+
for (const transform of snapshotTransforms) {
|
|
191
|
+
const key = Object.keys(transform)[0];
|
|
192
|
+
if (key) painted[`transform:${key}`] = transform[key];
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
value: {
|
|
196
|
+
animated: snapshotAnimated,
|
|
197
|
+
statics: snapshotStatics,
|
|
198
|
+
transforms: snapshotTransforms,
|
|
199
|
+
gatedKeys,
|
|
200
|
+
seeds,
|
|
201
|
+
removedKeys,
|
|
202
|
+
removeTransform: Object.keys(removedKeys).some((key) => key.startsWith("transform:")),
|
|
203
|
+
clearValue: isWeb ? "" : null
|
|
204
|
+
},
|
|
205
|
+
painted,
|
|
206
|
+
keys
|
|
207
|
+
};
|
|
211
208
|
};
|
|
212
|
-
const getGatedKeys = snapshot => Object.keys(snapshot.gatedKeys);
|
|
213
|
-
const createReanimatedConfig = config => {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return next;
|
|
209
|
+
const getGatedKeys = (snapshot) => Object.keys(snapshot.gatedKeys);
|
|
210
|
+
const createReanimatedConfig = (config) => {
|
|
211
|
+
"worklet";
|
|
212
|
+
const next = {};
|
|
213
|
+
const source = config;
|
|
214
|
+
for (const key in source) {
|
|
215
|
+
if (key === "type" || key === "delay") continue;
|
|
216
|
+
const value = source[key];
|
|
217
|
+
if (value !== void 0) {
|
|
218
|
+
next[key] = value;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return next;
|
|
226
222
|
};
|
|
227
223
|
const applyAnimation = (targetValue, config, callback, seedValue, validateStartAsColor = false) => {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
224
|
+
"worklet";
|
|
225
|
+
const delay = config.delay;
|
|
226
|
+
const reanimatedConfig = createReanimatedConfig(config);
|
|
227
|
+
let animatedValue;
|
|
228
|
+
if (config.type === "timing") {
|
|
229
|
+
animatedValue = withTiming(targetValue, reanimatedConfig, callback);
|
|
230
|
+
} else {
|
|
231
|
+
animatedValue = withSpring(targetValue, reanimatedConfig, callback);
|
|
232
|
+
const innerOnFrame = animatedValue.onFrame;
|
|
233
|
+
animatedValue.onFrame = (animation, now) => {
|
|
234
|
+
"worklet";
|
|
235
|
+
return innerOnFrame(animation, now < animation.lastTimestamp ? animation.lastTimestamp : now);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
if (seedValue !== void 0 || validateStartAsColor) {
|
|
239
|
+
const innerOnStart = animatedValue.onStart;
|
|
240
|
+
animatedValue.onStart = (animation, value, timestamp, previousAnimation) => {
|
|
241
|
+
"worklet";
|
|
242
|
+
const startValue = validateStartAsColor ? isReanimatedColorHistory(value) ? toReanimatedColor(value) : seedValue ?? targetValue : seedValue;
|
|
243
|
+
innerOnStart(animation, startValue, timestamp, previousAnimation);
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
if (delay && delay > 0) {
|
|
247
|
+
animatedValue = withDelay(delay, animatedValue);
|
|
248
|
+
}
|
|
249
|
+
return animatedValue;
|
|
251
250
|
};
|
|
252
|
-
const animateSnapshotValue = (key, implicitKey, targetValue, config, previouslyEmitted, seedValue, gated, currentlyExiting, exitCycleId,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
251
|
+
const animateSnapshotValue = (key, implicitKey, targetValue, config, previouslyEmitted, seedValue, gated, currentlyExiting, exitCycleId, currentlyCompletingEnter, enterCycleId, currentlyCompletingUpdate, updateCycleId, markExitKeyDone, markEnterKeyDone, markUpdateKeyDone, validateStartAsColor = false) => {
|
|
252
|
+
"worklet";
|
|
253
|
+
const cycleGated = gated && (currentlyExiting || currentlyCompletingEnter || currentlyCompletingUpdate);
|
|
254
|
+
if (!previouslyEmitted && seedValue === void 0 && !cycleGated) {
|
|
255
|
+
return targetValue;
|
|
256
|
+
}
|
|
257
|
+
let callback;
|
|
258
|
+
if (gated && currentlyExiting) {
|
|
259
|
+
callback = (finished) => {
|
|
260
|
+
"worklet";
|
|
261
|
+
runOnJS(markExitKeyDone)(key, exitCycleId, finished ?? false);
|
|
262
|
+
};
|
|
263
|
+
} else if (gated && currentlyCompletingEnter) {
|
|
264
|
+
callback = () => {
|
|
265
|
+
"worklet";
|
|
266
|
+
runOnJS(markEnterKeyDone)(key, enterCycleId);
|
|
267
|
+
};
|
|
268
|
+
} else if (gated && currentlyCompletingUpdate) {
|
|
269
|
+
callback = (finished) => {
|
|
270
|
+
"worklet";
|
|
271
|
+
runOnJS(markUpdateKeyDone)(key, updateCycleId, finished ?? false);
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
return applyAnimation(targetValue, config, callback, previouslyEmitted ? void 0 : seedValue ?? getImplicitDefault(implicitKey, targetValue), validateStartAsColor);
|
|
274
275
|
};
|
|
275
276
|
const ANIMATABLE_PROPERTIES = {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
paddingBottom: true,
|
|
330
|
-
paddingLeft: true,
|
|
331
|
-
paddingRight: true,
|
|
332
|
-
paddingHorizontal: true,
|
|
333
|
-
paddingVertical: true,
|
|
334
|
-
// Flex/Gap
|
|
335
|
-
gap: true,
|
|
336
|
-
rowGap: true,
|
|
337
|
-
columnGap: true,
|
|
338
|
-
flex: true,
|
|
339
|
-
flexGrow: true,
|
|
340
|
-
flexShrink: true
|
|
277
|
+
transform: true,
|
|
278
|
+
opacity: true,
|
|
279
|
+
height: true,
|
|
280
|
+
width: true,
|
|
281
|
+
minWidth: true,
|
|
282
|
+
minHeight: true,
|
|
283
|
+
maxWidth: true,
|
|
284
|
+
maxHeight: true,
|
|
285
|
+
backgroundColor: true,
|
|
286
|
+
borderColor: true,
|
|
287
|
+
borderLeftColor: true,
|
|
288
|
+
borderRightColor: true,
|
|
289
|
+
borderTopColor: true,
|
|
290
|
+
borderBottomColor: true,
|
|
291
|
+
borderRadius: true,
|
|
292
|
+
borderTopLeftRadius: true,
|
|
293
|
+
borderTopRightRadius: true,
|
|
294
|
+
borderBottomLeftRadius: true,
|
|
295
|
+
borderBottomRightRadius: true,
|
|
296
|
+
borderWidth: true,
|
|
297
|
+
borderLeftWidth: true,
|
|
298
|
+
borderRightWidth: true,
|
|
299
|
+
borderTopWidth: true,
|
|
300
|
+
borderBottomWidth: true,
|
|
301
|
+
color: true,
|
|
302
|
+
fontSize: true,
|
|
303
|
+
fontWeight: true,
|
|
304
|
+
lineHeight: true,
|
|
305
|
+
letterSpacing: true,
|
|
306
|
+
left: true,
|
|
307
|
+
right: true,
|
|
308
|
+
top: true,
|
|
309
|
+
bottom: true,
|
|
310
|
+
margin: true,
|
|
311
|
+
marginTop: true,
|
|
312
|
+
marginBottom: true,
|
|
313
|
+
marginLeft: true,
|
|
314
|
+
marginRight: true,
|
|
315
|
+
marginHorizontal: true,
|
|
316
|
+
marginVertical: true,
|
|
317
|
+
padding: true,
|
|
318
|
+
paddingTop: true,
|
|
319
|
+
paddingBottom: true,
|
|
320
|
+
paddingLeft: true,
|
|
321
|
+
paddingRight: true,
|
|
322
|
+
paddingHorizontal: true,
|
|
323
|
+
paddingVertical: true,
|
|
324
|
+
gap: true,
|
|
325
|
+
rowGap: true,
|
|
326
|
+
columnGap: true,
|
|
327
|
+
flex: true,
|
|
328
|
+
flexGrow: true,
|
|
329
|
+
flexShrink: true
|
|
341
330
|
};
|
|
342
331
|
const canAnimateProperty = (key, value, animateOnly) => {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
332
|
+
if (!ANIMATABLE_PROPERTIES[key]) return false;
|
|
333
|
+
if (value === "auto") return false;
|
|
334
|
+
if (typeof value === "string" && value.startsWith("calc")) return false;
|
|
335
|
+
if (animateOnly && !animateOnly.includes(key)) return false;
|
|
336
|
+
return true;
|
|
348
337
|
};
|
|
349
338
|
const splitAnimationStyles = (style, isDark, disableAnimation, animateOnly) => {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
339
|
+
const animated = {};
|
|
340
|
+
const statics = {};
|
|
341
|
+
for (const key in style) {
|
|
342
|
+
const value = resolveDynamicValue(style[key], isDark);
|
|
343
|
+
if (value === void 0) continue;
|
|
344
|
+
if (!disableAnimation && canAnimateProperty(key, value, animateOnly)) {
|
|
345
|
+
animated[key] = cloneAnimationValue(value);
|
|
346
|
+
} else {
|
|
347
|
+
statics[key] = cloneAnimationValue(value);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
animated,
|
|
352
|
+
statics
|
|
353
|
+
};
|
|
365
354
|
};
|
|
366
355
|
function createWebAnimatedComponent(defaultTag) {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
return /* @__PURE__ */jsx(Element, {
|
|
392
|
-
...transformedProps,
|
|
393
|
-
ref: composedRefs
|
|
394
|
-
});
|
|
395
|
-
}));
|
|
396
|
-
Component.acceptRenderProp = true;
|
|
397
|
-
return Component;
|
|
356
|
+
const isText = defaultTag === "span";
|
|
357
|
+
const Component = Animated.createAnimatedComponent(createRefComponent((propsIn, ref) => {
|
|
358
|
+
const { forwardedRef, render = defaultTag, ...rest } = propsIn;
|
|
359
|
+
const hostRef = useRef(null);
|
|
360
|
+
const composedRefs = useComposedRefs(forwardedRef, ref, hostRef);
|
|
361
|
+
const stateRef = useRef({ get host() {
|
|
362
|
+
return hostRef.current;
|
|
363
|
+
} });
|
|
364
|
+
const [, themeState] = useThemeWithState({});
|
|
365
|
+
const result = getSplitStyles(rest, isText ? Text.staticConfig : View.staticConfig, themeState?.theme ?? {}, themeState?.name ?? "", { unmounted: false }, {
|
|
366
|
+
isAnimated: false,
|
|
367
|
+
noClass: true
|
|
368
|
+
});
|
|
369
|
+
const viewProps = result?.viewProps ?? {};
|
|
370
|
+
const Element = render;
|
|
371
|
+
const transformedProps = hooks.usePropsTransform?.(render, viewProps, stateRef, false);
|
|
372
|
+
const { nativeID, ...webProps } = transformedProps ?? viewProps;
|
|
373
|
+
return /* @__PURE__ */ jsx(Element, {
|
|
374
|
+
...webProps,
|
|
375
|
+
ref: composedRefs
|
|
376
|
+
});
|
|
377
|
+
}));
|
|
378
|
+
Component.acceptRenderProp = true;
|
|
379
|
+
return Component;
|
|
398
380
|
}
|
|
399
381
|
const AnimatedView = createWebAnimatedComponent("div");
|
|
400
382
|
const AnimatedText = createWebAnimatedComponent("span");
|
|
401
383
|
function buildTransitionConfig(transition, animations, animationState, styleKeys) {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
return {
|
|
444
|
-
baseConfig: base,
|
|
445
|
-
propertyConfigs
|
|
446
|
-
};
|
|
384
|
+
const normalized = normalizeTransition(transition);
|
|
385
|
+
const effectiveKey = getEffectiveAnimation(normalized, animationState);
|
|
386
|
+
let base = cloneTransitionConfig(effectiveKey ? animations[effectiveKey] ?? { type: "spring" } : { type: "spring" });
|
|
387
|
+
if (normalized.delay) {
|
|
388
|
+
base = cloneTransitionConfig({
|
|
389
|
+
...base,
|
|
390
|
+
delay: normalized.delay
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
if (normalized.config) {
|
|
394
|
+
base = cloneTransitionConfig({
|
|
395
|
+
...base,
|
|
396
|
+
...normalized.config
|
|
397
|
+
});
|
|
398
|
+
if (base.type !== "timing" && normalized.config.duration !== void 0 && normalized.config.damping === void 0 && normalized.config.stiffness === void 0 && normalized.config.mass === void 0) {
|
|
399
|
+
base = cloneTransitionConfig({
|
|
400
|
+
...base,
|
|
401
|
+
type: "timing"
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
const propertyConfigs = {};
|
|
406
|
+
for (const key of styleKeys) {
|
|
407
|
+
const propAnimation = normalized.properties[key];
|
|
408
|
+
if (typeof propAnimation === "string") {
|
|
409
|
+
propertyConfigs[key] = cloneTransitionConfig(animations[propAnimation] ?? base);
|
|
410
|
+
} else if (propAnimation && typeof propAnimation === "object") {
|
|
411
|
+
const configType = propAnimation.type;
|
|
412
|
+
const baseForProp = configType ? animations[configType] ?? base : base;
|
|
413
|
+
propertyConfigs[key] = cloneTransitionConfig({
|
|
414
|
+
...baseForProp,
|
|
415
|
+
...propAnimation
|
|
416
|
+
});
|
|
417
|
+
} else {
|
|
418
|
+
propertyConfigs[key] = cloneTransitionConfig(base);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return {
|
|
422
|
+
baseConfig: base,
|
|
423
|
+
propertyConfigs
|
|
424
|
+
};
|
|
447
425
|
}
|
|
448
426
|
function getStyleKeys(style) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
427
|
+
const keys = new Set(Object.keys(style));
|
|
428
|
+
if (style.transform && Array.isArray(style.transform)) {
|
|
429
|
+
for (const t of style.transform) {
|
|
430
|
+
if (t && typeof t === "object") {
|
|
431
|
+
keys.add(Object.keys(t)[0]);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return keys;
|
|
458
436
|
}
|
|
459
437
|
function createAnimations(animationsConfig) {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
438
|
+
const animations = {};
|
|
439
|
+
for (const key in animationsConfig) {
|
|
440
|
+
animations[key] = cloneTransitionConfig({
|
|
441
|
+
type: "spring",
|
|
442
|
+
...animationsConfig[key]
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
return {
|
|
446
|
+
needsCustomComponent: true,
|
|
447
|
+
View: isWeb ? AnimatedView : Animated.View,
|
|
448
|
+
Text: isWeb ? AnimatedText : Animated.Text,
|
|
449
|
+
isReactNative: true,
|
|
450
|
+
inputStyle: "value",
|
|
451
|
+
outputStyle: "inline",
|
|
452
|
+
avoidReRenders: true,
|
|
453
|
+
animations,
|
|
454
|
+
usePresence,
|
|
455
|
+
ResetPresence,
|
|
456
|
+
useAnimatedNumber(initial) {
|
|
457
|
+
const sharedValue = useSharedValue(initial);
|
|
458
|
+
return useMemo(() => ({
|
|
459
|
+
getInstance() {
|
|
460
|
+
"worklet";
|
|
461
|
+
return sharedValue;
|
|
462
|
+
},
|
|
463
|
+
getValue() {
|
|
464
|
+
"worklet";
|
|
465
|
+
return sharedValue.value;
|
|
466
|
+
},
|
|
467
|
+
setValue(next, config = { type: "spring" }, onFinish) {
|
|
468
|
+
if (config.type === "direct") {
|
|
469
|
+
sharedValue.value = next;
|
|
470
|
+
onFinish?.();
|
|
471
|
+
} else {
|
|
472
|
+
const cb = onFinish ? (finished) => {
|
|
473
|
+
"worklet";
|
|
474
|
+
if (finished !== false) {
|
|
475
|
+
runOnJS(onFinish)();
|
|
476
|
+
}
|
|
477
|
+
} : void 0;
|
|
478
|
+
const animationConfig = cloneTransitionConfig(config);
|
|
479
|
+
if (isWeb) {
|
|
480
|
+
sharedValue.value = applyAnimation(next, animationConfig, cb);
|
|
481
|
+
} else {
|
|
482
|
+
runOnUI((targetValue, animationConfig2) => {
|
|
483
|
+
"worklet";
|
|
484
|
+
sharedValue.value = applyAnimation(targetValue, animationConfig2, cb);
|
|
485
|
+
})(next, animationConfig);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
stop() {
|
|
490
|
+
cancelAnimation(sharedValue);
|
|
491
|
+
}
|
|
492
|
+
}), [sharedValue]);
|
|
493
|
+
},
|
|
494
|
+
useAnimatedNumberReaction({ value }, onValue) {
|
|
495
|
+
const instance = value.getInstance();
|
|
496
|
+
return useAnimatedReaction(() => instance.value, (next, prev) => {
|
|
497
|
+
if (prev !== next) {
|
|
498
|
+
runOnJS(onValue)(next);
|
|
499
|
+
}
|
|
500
|
+
}, [onValue, instance]);
|
|
501
|
+
},
|
|
502
|
+
useAnimatedNumberStyle(val, getStyle) {
|
|
503
|
+
const instance = val.getInstance();
|
|
504
|
+
if (isWeb) {
|
|
505
|
+
return useAnimatedStyle(() => {
|
|
506
|
+
"worklet";
|
|
507
|
+
return getStyle(instance.value);
|
|
508
|
+
}, [instance, getStyle]);
|
|
509
|
+
}
|
|
510
|
+
const styleVal = useDerivedValue(() => {
|
|
511
|
+
"worklet";
|
|
512
|
+
return getStyle(instance.value);
|
|
513
|
+
});
|
|
514
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
515
|
+
"worklet";
|
|
516
|
+
return styleVal.value;
|
|
517
|
+
});
|
|
518
|
+
silenceAnimatedComponentDevCheck(animatedStyle);
|
|
519
|
+
return animatedStyle;
|
|
520
|
+
},
|
|
521
|
+
useAnimatedNumbersStyle(vals, getStyle) {
|
|
522
|
+
const instances = vals.map((v) => v.getInstance());
|
|
523
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
524
|
+
"worklet";
|
|
525
|
+
const currentValues = instances.map((inst) => inst.value);
|
|
526
|
+
return getStyle(...currentValues);
|
|
527
|
+
}, isWeb ? [getStyle, ...instances] : void 0);
|
|
528
|
+
silenceAnimatedComponentDevCheck(animatedStyle);
|
|
529
|
+
return animatedStyle;
|
|
530
|
+
},
|
|
531
|
+
useAnimations(animationProps) {
|
|
532
|
+
const { props, presence, style, componentState, useStyleEmitter, themeName, stateRef, styleState, onTransition } = animationProps;
|
|
533
|
+
const isHydrating = componentState.unmounted === true;
|
|
534
|
+
const isMounting = componentState.unmounted === "should-enter";
|
|
535
|
+
const isEntering = !!componentState.unmounted;
|
|
536
|
+
const isExiting = presence?.[0] === false;
|
|
537
|
+
const wasEnteringRef = useRef(isEntering);
|
|
538
|
+
const justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
539
|
+
React.useEffect(() => {
|
|
540
|
+
wasEnteringRef.current = isEntering;
|
|
541
|
+
});
|
|
542
|
+
const effectiveTransition = styleState?.effectiveTransition ?? props.transition;
|
|
543
|
+
const normalized = normalizeTransition(effectiveTransition);
|
|
544
|
+
const animationState = isExiting ? "exit" : isMounting || justFinishedEntering ? "enter" : "default";
|
|
545
|
+
const animationKey = getEffectiveAnimation(normalized, animationState);
|
|
546
|
+
const disableAnimation = isHydrating || !animationKey;
|
|
547
|
+
const isDark = themeName?.startsWith("dark") || false;
|
|
548
|
+
const sendExitComplete = presence?.[1];
|
|
549
|
+
const onTransitionRef = useRef(onTransition);
|
|
550
|
+
onTransitionRef.current = onTransition;
|
|
551
|
+
const emit = (phase, cause, finished) => {
|
|
552
|
+
onTransitionRef.current?.(phase === "end" ? {
|
|
553
|
+
phase,
|
|
554
|
+
cause,
|
|
555
|
+
finished
|
|
556
|
+
} : {
|
|
557
|
+
phase,
|
|
558
|
+
cause
|
|
559
|
+
});
|
|
560
|
+
};
|
|
561
|
+
const enterStartedRef = useRef(false);
|
|
562
|
+
const exitStartedRef = useRef(false);
|
|
563
|
+
const updateStartedRef = useRef(false);
|
|
564
|
+
const isExitingJSRef = useRef(false);
|
|
565
|
+
isExitingJSRef.current = isExiting;
|
|
566
|
+
const updateCycleIdRef = useRef(0);
|
|
567
|
+
const pendingUpdateKeysRef = useRef(/* @__PURE__ */ new Set());
|
|
568
|
+
const updateCompletedRef = useRef(false);
|
|
569
|
+
const isCompletingUpdateRef = useSharedValue(false);
|
|
570
|
+
const updateCycleIdShared = useSharedValue(0);
|
|
571
|
+
const markUpdateKeyDone = useEvent((key, cycleId, finished) => {
|
|
572
|
+
if (!finished || cycleId !== updateCycleIdRef.current) return;
|
|
573
|
+
if (updateCompletedRef.current) return;
|
|
574
|
+
pendingUpdateKeysRef.current.delete(key);
|
|
575
|
+
if (pendingUpdateKeysRef.current.size === 0) {
|
|
576
|
+
updateCompletedRef.current = true;
|
|
577
|
+
isCompletingUpdateRef.value = false;
|
|
578
|
+
if (updateStartedRef.current) {
|
|
579
|
+
updateStartedRef.current = false;
|
|
580
|
+
emit("end", "update", true);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
const exitCycleIdRef = useRef(0);
|
|
585
|
+
const pendingExitKeysRef = useRef(/* @__PURE__ */ new Set());
|
|
586
|
+
const exitCompletedRef = useRef(false);
|
|
587
|
+
const wasExitingRef = useRef(false);
|
|
588
|
+
const justStartedExiting = isExiting && !wasExitingRef.current;
|
|
589
|
+
const justStoppedExiting = !isExiting && wasExitingRef.current;
|
|
590
|
+
const markExitKeyDone = useEvent((key, cycleId, finished) => {
|
|
591
|
+
if (cycleId !== exitCycleIdRef.current) return;
|
|
592
|
+
if (exitCompletedRef.current) return;
|
|
593
|
+
pendingExitKeysRef.current.delete(key);
|
|
594
|
+
if (pendingExitKeysRef.current.size === 0) {
|
|
595
|
+
exitCompletedRef.current = true;
|
|
596
|
+
if (exitStartedRef.current) {
|
|
597
|
+
exitStartedRef.current = false;
|
|
598
|
+
emit("end", "exit", true);
|
|
599
|
+
}
|
|
600
|
+
sendExitComplete?.();
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
const enterCycleIdRef = useRef(0);
|
|
604
|
+
const pendingEnterKeysRef = useRef(/* @__PURE__ */ new Set());
|
|
605
|
+
const enterCompletedRef = useRef(false);
|
|
606
|
+
const markEnterKeyDone = useEvent((key, cycleId) => {
|
|
607
|
+
if (cycleId !== enterCycleIdRef.current) return;
|
|
608
|
+
if (enterCompletedRef.current) return;
|
|
609
|
+
if (isExitingJSRef.current) return;
|
|
610
|
+
pendingEnterKeysRef.current.delete(key);
|
|
611
|
+
if (pendingEnterKeysRef.current.size === 0) {
|
|
612
|
+
enterCompletedRef.current = true;
|
|
613
|
+
if (enterStartedRef.current) {
|
|
614
|
+
enterStartedRef.current = false;
|
|
615
|
+
emit("end", "enter", true);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
const isExitingRef = useSharedValue(isExiting);
|
|
620
|
+
const exitCycleIdShared = useSharedValue(exitCycleIdRef.current);
|
|
621
|
+
const isCompletingEnterRef = useSharedValue(false);
|
|
622
|
+
const enterCycleIdShared = useSharedValue(enterCycleIdRef.current);
|
|
623
|
+
if (justStartedExiting) {
|
|
624
|
+
exitCycleIdRef.current++;
|
|
625
|
+
exitCompletedRef.current = false;
|
|
626
|
+
pendingExitKeysRef.current.clear();
|
|
627
|
+
enterCycleIdRef.current++;
|
|
628
|
+
pendingEnterKeysRef.current.clear();
|
|
629
|
+
updateCycleIdRef.current++;
|
|
630
|
+
pendingUpdateKeysRef.current.clear();
|
|
631
|
+
updateCompletedRef.current = true;
|
|
632
|
+
}
|
|
633
|
+
if (justStoppedExiting) {
|
|
634
|
+
exitCycleIdRef.current++;
|
|
635
|
+
pendingExitKeysRef.current.clear();
|
|
636
|
+
}
|
|
637
|
+
useIsomorphicLayoutEffect(() => {
|
|
638
|
+
isExitingRef.value = isExiting;
|
|
639
|
+
exitCycleIdShared.value = exitCycleIdRef.current;
|
|
640
|
+
isCompletingEnterRef.value = !isExiting && justFinishedEntering && Boolean(onTransitionRef.current);
|
|
641
|
+
enterCycleIdShared.value = enterCycleIdRef.current;
|
|
642
|
+
if (justStartedExiting) {
|
|
643
|
+
isCompletingUpdateRef.value = false;
|
|
644
|
+
updateCycleIdShared.value = updateCycleIdRef.current;
|
|
645
|
+
}
|
|
646
|
+
}, [
|
|
647
|
+
isExiting,
|
|
648
|
+
justFinishedEntering,
|
|
649
|
+
exitCycleIdRef.current,
|
|
650
|
+
enterCycleIdRef.current,
|
|
651
|
+
justStartedExiting
|
|
652
|
+
]);
|
|
653
|
+
useIsomorphicLayoutEffect(() => {
|
|
654
|
+
if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {
|
|
655
|
+
exitStartedRef.current = false;
|
|
656
|
+
emit("end", "exit", false);
|
|
657
|
+
}
|
|
658
|
+
}, [justStoppedExiting]);
|
|
659
|
+
React.useEffect(() => {
|
|
660
|
+
wasExitingRef.current = isExiting;
|
|
661
|
+
});
|
|
662
|
+
const committedRenderKeysRef = useRef(/* @__PURE__ */ new Set());
|
|
663
|
+
const lastPaintedRef = useRef({});
|
|
664
|
+
const carryRef = useRef({});
|
|
665
|
+
const { animatedStyles, staticStyles, nextCarry } = useMemo(() => {
|
|
666
|
+
const animateOnly = props.animateOnly;
|
|
667
|
+
const { animated, statics } = splitAnimationStyles(style, isDark, disableAnimation, animateOnly);
|
|
668
|
+
const nextCarry2 = cloneStyleRecord(carryRef.current);
|
|
669
|
+
for (const key in nextCarry2) {
|
|
670
|
+
if (!(key in animated)) delete nextCarry2[key];
|
|
671
|
+
}
|
|
672
|
+
for (const key in animated) {
|
|
673
|
+
if (!(key in nextCarry2)) {
|
|
674
|
+
nextCarry2[key] = cloneAnimationValue(animated[key]);
|
|
675
|
+
}
|
|
676
|
+
statics[key] = nextCarry2[key];
|
|
677
|
+
}
|
|
678
|
+
return {
|
|
679
|
+
animatedStyles: animated,
|
|
680
|
+
staticStyles: statics,
|
|
681
|
+
nextCarry: nextCarry2
|
|
682
|
+
};
|
|
683
|
+
}, [
|
|
684
|
+
disableAnimation,
|
|
685
|
+
style,
|
|
686
|
+
isDark,
|
|
687
|
+
props.animateOnly
|
|
688
|
+
]);
|
|
689
|
+
const renderSnapshot = useMemo(() => buildSnapshot(animatedStyles, staticStyles, getAnimatedTransforms(animatedStyles.transform), committedRenderKeysRef.current, lastPaintedRef.current), [animatedStyles, staticStyles]);
|
|
690
|
+
const renderSnapshotRef = useSharedValue({
|
|
691
|
+
animated: {},
|
|
692
|
+
statics: {},
|
|
693
|
+
transforms: [],
|
|
694
|
+
gatedKeys: {},
|
|
695
|
+
seeds: {},
|
|
696
|
+
removedKeys: {},
|
|
697
|
+
removeTransform: false,
|
|
698
|
+
clearValue: isWeb ? "" : null
|
|
699
|
+
});
|
|
700
|
+
const emitterSnapshotRef = useSharedValue(null);
|
|
701
|
+
const emitterKeysRef = useRef(null);
|
|
702
|
+
useIsomorphicLayoutEffect(() => {
|
|
703
|
+
carryRef.current = nextCarry;
|
|
704
|
+
committedRenderKeysRef.current = renderSnapshot.keys;
|
|
705
|
+
lastPaintedRef.current = renderSnapshot.painted;
|
|
706
|
+
}, [nextCarry, renderSnapshot]);
|
|
707
|
+
const pseudoActiveRef = useRef(false);
|
|
708
|
+
const publishedSnapshotRef = useRef(null);
|
|
709
|
+
useIsomorphicLayoutEffect(() => {
|
|
710
|
+
const renderChanged = publishedSnapshotRef.current !== renderSnapshot.value;
|
|
711
|
+
const droppingLatch = (isExiting || !pseudoActiveRef.current && publishedSnapshotRef.current !== null && renderChanged) && emitterSnapshotRef.value !== null;
|
|
712
|
+
const emitterKeys = droppingLatch ? emitterKeysRef.current : null;
|
|
713
|
+
if (droppingLatch || renderChanged) {
|
|
714
|
+
const removedKeys = emitterKeys ? {
|
|
715
|
+
...renderSnapshot.value.removedKeys,
|
|
716
|
+
...getRemovedAnimatedKeys(renderSnapshot.keys, emitterKeys)
|
|
717
|
+
} : renderSnapshot.value.removedKeys;
|
|
718
|
+
renderSnapshotRef.value = {
|
|
719
|
+
...renderSnapshot.value,
|
|
720
|
+
removedKeys,
|
|
721
|
+
removeTransform: Object.keys(removedKeys).some((key) => key.startsWith("transform:"))
|
|
722
|
+
};
|
|
723
|
+
publishedSnapshotRef.current = renderSnapshot.value;
|
|
724
|
+
}
|
|
725
|
+
if (droppingLatch) {
|
|
726
|
+
emitterSnapshotRef.value = null;
|
|
727
|
+
emitterKeysRef.current = null;
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
const { baseConfig, propertyConfigs } = useMemo(() => {
|
|
731
|
+
if (isHydrating) {
|
|
732
|
+
return {
|
|
733
|
+
baseConfig: {
|
|
734
|
+
type: "timing",
|
|
735
|
+
duration: 0
|
|
736
|
+
},
|
|
737
|
+
propertyConfigs: {}
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
return buildTransitionConfig(effectiveTransition, animations, animationState, getStyleKeys(animatedStyles));
|
|
741
|
+
}, [
|
|
742
|
+
isHydrating,
|
|
743
|
+
effectiveTransition,
|
|
744
|
+
animatedStyles,
|
|
745
|
+
animationState
|
|
746
|
+
]);
|
|
747
|
+
const configRef = useSharedValue({
|
|
748
|
+
baseConfig,
|
|
749
|
+
propertyConfigs,
|
|
750
|
+
disableAnimation,
|
|
751
|
+
isHydrating
|
|
752
|
+
});
|
|
753
|
+
useIsomorphicLayoutEffect(() => {
|
|
754
|
+
configRef.value = {
|
|
755
|
+
baseConfig,
|
|
756
|
+
propertyConfigs,
|
|
757
|
+
disableAnimation,
|
|
758
|
+
isHydrating
|
|
759
|
+
};
|
|
760
|
+
}, [
|
|
761
|
+
baseConfig,
|
|
762
|
+
propertyConfigs,
|
|
763
|
+
disableAnimation,
|
|
764
|
+
isHydrating
|
|
765
|
+
]);
|
|
766
|
+
useStyleEmitter?.((nextStyle, effectiveTransition2, pseudoActive) => {
|
|
767
|
+
if (isExitingJSRef.current) return;
|
|
768
|
+
pseudoActiveRef.current = pseudoActive === true;
|
|
769
|
+
const animateOnly = props.animateOnly;
|
|
770
|
+
const transitionToUse = effectiveTransition2 ?? props.transition;
|
|
771
|
+
const { baseConfig: newBase, propertyConfigs: newPropertyConfigs } = buildTransitionConfig(transitionToUse, animations, animationState, getStyleKeys(nextStyle));
|
|
772
|
+
configRef.value = {
|
|
773
|
+
baseConfig: newBase,
|
|
774
|
+
propertyConfigs: newPropertyConfigs,
|
|
775
|
+
disableAnimation: configRef.value.disableAnimation,
|
|
776
|
+
isHydrating: configRef.value.isHydrating
|
|
777
|
+
};
|
|
778
|
+
const previousKeys = emitterKeysRef.current ?? committedRenderKeysRef.current;
|
|
779
|
+
const { animated, statics } = splitAnimationStyles(nextStyle, isDark, configRef.value.disableAnimation, animateOnly);
|
|
780
|
+
const snapshot = buildSnapshot(animated, statics, getAnimatedTransforms(animated.transform), previousKeys, lastPaintedRef.current);
|
|
781
|
+
emitterSnapshotRef.value = snapshot.value;
|
|
782
|
+
emitterKeysRef.current = snapshot.keys;
|
|
783
|
+
lastPaintedRef.current = snapshot.painted;
|
|
784
|
+
if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
|
|
785
|
+
console.info("[animations-reanimated] useStyleEmitter update", {
|
|
786
|
+
animated,
|
|
787
|
+
statics,
|
|
788
|
+
transforms: snapshot.value.transforms
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
const exitKeysRegistered = useRef(false);
|
|
793
|
+
const enterKeysRegistered = useRef(false);
|
|
794
|
+
if (!isExiting && justFinishedEntering && onTransition) {
|
|
795
|
+
const enterKeys = getGatedKeys(renderSnapshot.value);
|
|
796
|
+
enterCycleIdRef.current++;
|
|
797
|
+
enterCompletedRef.current = false;
|
|
798
|
+
pendingEnterKeysRef.current = new Set(enterKeys);
|
|
799
|
+
enterKeysRegistered.current = enterKeys.length > 0;
|
|
800
|
+
}
|
|
801
|
+
if (justStartedExiting && sendExitComplete) {
|
|
802
|
+
const exitKeys = getGatedKeys(renderSnapshot.value);
|
|
803
|
+
pendingExitKeysRef.current = new Set(exitKeys);
|
|
804
|
+
exitKeysRegistered.current = exitKeys.length > 0;
|
|
805
|
+
}
|
|
806
|
+
const previousUpdateStyleRef = useRef(null);
|
|
807
|
+
const updateStyle = onTransition ? JSON.stringify(style) : null;
|
|
808
|
+
const previousUpdateStyle = previousUpdateStyleRef.current;
|
|
809
|
+
const shouldRegisterUpdate = updateStyle !== null && previousUpdateStyle !== null && previousUpdateStyle !== updateStyle && !isExiting && !isEntering && !justFinishedEntering;
|
|
810
|
+
const updateKeys = shouldRegisterUpdate ? getGatedKeys(renderSnapshot.value) : [];
|
|
811
|
+
useIsomorphicLayoutEffect(() => {
|
|
812
|
+
if (updateStyle === null) {
|
|
813
|
+
previousUpdateStyleRef.current = null;
|
|
814
|
+
isCompletingUpdateRef.value = false;
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
const previousStyleStillCurrent = previousUpdateStyleRef.current === previousUpdateStyle;
|
|
818
|
+
previousUpdateStyleRef.current = updateStyle;
|
|
819
|
+
if (!shouldRegisterUpdate || !previousStyleStillCurrent) return;
|
|
820
|
+
const cycleId = ++updateCycleIdRef.current;
|
|
821
|
+
pendingUpdateKeysRef.current = new Set(updateKeys);
|
|
822
|
+
updateCompletedRef.current = updateKeys.length === 0;
|
|
823
|
+
isCompletingUpdateRef.value = updateKeys.length > 0;
|
|
824
|
+
updateCycleIdShared.value = cycleId;
|
|
825
|
+
if (updateStartedRef.current) {
|
|
826
|
+
emit("end", "update", false);
|
|
827
|
+
}
|
|
828
|
+
updateStartedRef.current = true;
|
|
829
|
+
emit("start", "update");
|
|
830
|
+
if (updateKeys.length === 0) {
|
|
831
|
+
updateStartedRef.current = false;
|
|
832
|
+
emit("end", "update", true);
|
|
833
|
+
}
|
|
834
|
+
}, [updateStyle, shouldRegisterUpdate]);
|
|
835
|
+
React.useEffect(() => {
|
|
836
|
+
if (!justStartedExiting || !sendExitComplete) return;
|
|
837
|
+
if (enterStartedRef.current) {
|
|
838
|
+
enterStartedRef.current = false;
|
|
839
|
+
emit("end", "enter", false);
|
|
840
|
+
}
|
|
841
|
+
if (updateStartedRef.current) {
|
|
842
|
+
updateStartedRef.current = false;
|
|
843
|
+
emit("end", "update", false);
|
|
844
|
+
}
|
|
845
|
+
if (onTransitionRef.current && !exitStartedRef.current) {
|
|
846
|
+
exitStartedRef.current = true;
|
|
847
|
+
emit("start", "exit");
|
|
848
|
+
}
|
|
849
|
+
if (!exitKeysRegistered.current && pendingExitKeysRef.current.size === 0) {
|
|
850
|
+
if (!exitCompletedRef.current) {
|
|
851
|
+
exitCompletedRef.current = true;
|
|
852
|
+
if (exitStartedRef.current) {
|
|
853
|
+
exitStartedRef.current = false;
|
|
854
|
+
emit("end", "exit", true);
|
|
855
|
+
}
|
|
856
|
+
sendExitComplete();
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}, [justStartedExiting, sendExitComplete]);
|
|
860
|
+
React.useEffect(() => {
|
|
861
|
+
if (isExiting || !justFinishedEntering || !onTransition) return;
|
|
862
|
+
if (!enterStartedRef.current) {
|
|
863
|
+
enterStartedRef.current = true;
|
|
864
|
+
emit("start", "enter");
|
|
865
|
+
}
|
|
866
|
+
if (!enterKeysRegistered.current && pendingEnterKeysRef.current.size === 0) {
|
|
867
|
+
if (!enterCompletedRef.current) {
|
|
868
|
+
enterCompletedRef.current = true;
|
|
869
|
+
if (enterStartedRef.current) {
|
|
870
|
+
enterStartedRef.current = false;
|
|
871
|
+
emit("end", "enter", true);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
}, [
|
|
876
|
+
isExiting,
|
|
877
|
+
justFinishedEntering,
|
|
878
|
+
onTransition
|
|
879
|
+
]);
|
|
880
|
+
const mapperStateRef = useSharedValue({ emitted: {} });
|
|
881
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
882
|
+
"worklet";
|
|
883
|
+
const mapperState = mapperStateRef.value;
|
|
884
|
+
const config = configRef.value;
|
|
885
|
+
if (config.disableAnimation || config.isHydrating) {
|
|
886
|
+
updateMapperState(mapperStateRef, {});
|
|
887
|
+
return {};
|
|
888
|
+
}
|
|
889
|
+
const previouslyEmitted = mapperState.emitted;
|
|
890
|
+
const emitted = {};
|
|
891
|
+
const result = {};
|
|
892
|
+
const emitterSnapshot = emitterSnapshotRef.value;
|
|
893
|
+
const snapshot = emitterSnapshot ?? renderSnapshotRef.value;
|
|
894
|
+
const animatedValues = snapshot.animated;
|
|
895
|
+
const staticValues = snapshot.statics;
|
|
896
|
+
const currentlyExiting = isExitingRef.value;
|
|
897
|
+
const currentCycleId = exitCycleIdShared.value;
|
|
898
|
+
const currentlyCompletingEnter = isCompletingEnterRef.value;
|
|
899
|
+
const currentEnterCycleId = enterCycleIdShared.value;
|
|
900
|
+
const currentlyCompletingUpdate = isCompletingUpdateRef.value;
|
|
901
|
+
const currentUpdateCycleId = updateCycleIdShared.value;
|
|
902
|
+
for (const key in staticValues) {
|
|
903
|
+
result[key] = staticValues[key];
|
|
904
|
+
}
|
|
905
|
+
for (const key in snapshot.removedKeys) {
|
|
906
|
+
if (!key.startsWith("transform:") && !(key in staticValues)) {
|
|
907
|
+
result[key] = snapshot.clearValue;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
for (const key in animatedValues) {
|
|
911
|
+
if (key === "transform") continue;
|
|
912
|
+
const targetValue = animatedValues[key];
|
|
913
|
+
emitted[key] = true;
|
|
914
|
+
if (typeof targetValue !== "number" && typeof targetValue !== "string") {
|
|
915
|
+
result[key] = targetValue;
|
|
916
|
+
continue;
|
|
917
|
+
}
|
|
918
|
+
result[key] = animateSnapshotValue(key, key, targetValue, config.propertyConfigs[key] ?? config.baseConfig, !!previouslyEmitted[key], snapshot.seeds[key], !!snapshot.gatedKeys[key], currentlyExiting, currentCycleId, currentlyCompletingEnter, currentEnterCycleId, currentlyCompletingUpdate, currentUpdateCycleId, markExitKeyDone, markEnterKeyDone, markUpdateKeyDone, !!COLOR_STYLE_KEYS[key]);
|
|
919
|
+
}
|
|
920
|
+
const transforms = snapshot.transforms;
|
|
921
|
+
if (transforms.length > 0 || snapshot.removeTransform) {
|
|
922
|
+
const validTransforms = [];
|
|
923
|
+
for (const t of transforms) {
|
|
924
|
+
if (!t) continue;
|
|
925
|
+
const keys = Object.keys(t);
|
|
926
|
+
if (keys.length === 0) continue;
|
|
927
|
+
const transformKey = keys[0];
|
|
928
|
+
const value = t[transformKey];
|
|
929
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
930
|
+
const propConfig = config.propertyConfigs[transformKey] ?? config.baseConfig;
|
|
931
|
+
const subKey = `transform:${transformKey}`;
|
|
932
|
+
emitted[subKey] = true;
|
|
933
|
+
validTransforms.push({ [transformKey]: animateSnapshotValue(subKey, transformKey, value, propConfig, !!previouslyEmitted[subKey], snapshot.seeds[subKey], !!snapshot.gatedKeys[subKey], currentlyExiting, currentCycleId, currentlyCompletingEnter, currentEnterCycleId, currentlyCompletingUpdate, currentUpdateCycleId, markExitKeyDone, markEnterKeyDone, markUpdateKeyDone) });
|
|
934
|
+
} else {
|
|
935
|
+
validTransforms.push(t);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
if (validTransforms.length > 0 || !("transform" in staticValues)) {
|
|
939
|
+
result.transform = validTransforms;
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
updateMapperState(mapperStateRef, emitted);
|
|
943
|
+
return result;
|
|
944
|
+
}, isWeb ? [
|
|
945
|
+
renderSnapshotRef,
|
|
946
|
+
emitterSnapshotRef,
|
|
947
|
+
configRef,
|
|
948
|
+
isExitingRef,
|
|
949
|
+
exitCycleIdShared,
|
|
950
|
+
markExitKeyDone,
|
|
951
|
+
isCompletingEnterRef,
|
|
952
|
+
enterCycleIdShared,
|
|
953
|
+
markEnterKeyDone,
|
|
954
|
+
isCompletingUpdateRef,
|
|
955
|
+
updateCycleIdShared,
|
|
956
|
+
markUpdateKeyDone
|
|
957
|
+
] : void 0);
|
|
958
|
+
silenceAnimatedComponentDevCheck(animatedStyle);
|
|
959
|
+
if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
|
|
960
|
+
console.info("[animations-reanimated] useAnimations", {
|
|
961
|
+
animationKey,
|
|
962
|
+
componentState,
|
|
963
|
+
isExiting,
|
|
964
|
+
animatedStyles,
|
|
965
|
+
staticStyles,
|
|
966
|
+
baseConfig,
|
|
967
|
+
propertyConfigs
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
return { style: [staticStyles, animatedStyle] };
|
|
971
|
+
}
|
|
972
|
+
};
|
|
921
973
|
}
|
|
974
|
+
|
|
922
975
|
export { createAnimations };
|
|
923
976
|
//# sourceMappingURL=createAnimations.mjs.map
|