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