@tamagui/animations-reanimated 2.0.0-1768636514428 → 2.0.0-1768699687560
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 +67 -64
- package/dist/cjs/createAnimations.js +46 -39
- package/dist/cjs/createAnimations.js.map +2 -2
- package/dist/cjs/createAnimations.native.js +107 -115
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/esm/createAnimations.js +47 -39
- package/dist/esm/createAnimations.js.map +2 -2
- package/dist/esm/createAnimations.mjs +67 -64
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +107 -115
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/package.json +5 -5
- package/src/createAnimations.tsx +83 -108
- package/types/createAnimations.d.ts.map +2 -2
|
@@ -35,8 +35,8 @@ __export(createAnimations_exports, {
|
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(createAnimations_exports);
|
|
37
37
|
var import_animation_helpers = require("@tamagui/animation-helpers"),
|
|
38
|
-
import_use_presence = require("@tamagui/use-presence"),
|
|
39
38
|
import_core = require("@tamagui/core"),
|
|
39
|
+
import_use_presence = require("@tamagui/use-presence"),
|
|
40
40
|
import_react = __toESM(require("react"), 1),
|
|
41
41
|
import_react_native_reanimated = __toESM(require("react-native-reanimated"), 1),
|
|
42
42
|
import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -59,20 +59,6 @@ const getDefaultExport = module2 => {
|
|
|
59
59
|
let animatedValue;
|
|
60
60
|
return config.type === "timing" ? animatedValue = (0, import_react_native_reanimated.withTiming)(targetValue, config) : animatedValue = (0, import_react_native_reanimated.withSpring)(targetValue, config), delay && delay > 0 && (animatedValue = (0, import_react_native_reanimated.withDelay)(delay, animatedValue)), animatedValue;
|
|
61
61
|
},
|
|
62
|
-
estimateSpringDuration = config => {
|
|
63
|
-
const stiffness = config.stiffness ?? 100,
|
|
64
|
-
damping = config.damping ?? 10,
|
|
65
|
-
mass = config.mass ?? 1;
|
|
66
|
-
if (mass <= 0 || stiffness <= 0) return 400;
|
|
67
|
-
const omega0 = Math.sqrt(stiffness / mass),
|
|
68
|
-
zeta = damping / (2 * Math.sqrt(stiffness * mass));
|
|
69
|
-
let duration;
|
|
70
|
-
return zeta < 1 && zeta > 0 && omega0 > 0 ? duration = 4 / (zeta * omega0) * 1e3 : omega0 > 0 ? duration = 2 / omega0 * 1e3 : duration = 400, Number.isFinite(duration) ? Math.ceil(Math.min(2e3, Math.max(200, duration)) * 1.15) : 400;
|
|
71
|
-
},
|
|
72
|
-
getAnimationDuration = config => {
|
|
73
|
-
const delay = Math.max(0, config.delay ?? 0);
|
|
74
|
-
return config.type === "timing" ? Math.max(0, config.duration ?? 300) + delay + 50 : estimateSpringDuration(config) + delay;
|
|
75
|
-
},
|
|
76
62
|
ANIMATABLE_PROPERTIES = {
|
|
77
63
|
// Transform
|
|
78
64
|
transform: !0,
|
|
@@ -146,7 +132,7 @@ function createWebAnimatedComponent(defaultTag) {
|
|
|
146
132
|
Component = Animated.createAnimatedComponent((0, import_react.forwardRef)((propsIn, ref) => {
|
|
147
133
|
const {
|
|
148
134
|
forwardedRef,
|
|
149
|
-
|
|
135
|
+
render = defaultTag,
|
|
150
136
|
...rest
|
|
151
137
|
} = propsIn,
|
|
152
138
|
hostRef = (0, import_react.useRef)(null),
|
|
@@ -163,8 +149,8 @@ function createWebAnimatedComponent(defaultTag) {
|
|
|
163
149
|
isAnimated: !1,
|
|
164
150
|
noClass: !0
|
|
165
151
|
})?.viewProps ?? {},
|
|
166
|
-
Element =
|
|
167
|
-
transformedProps = import_core.hooks.usePropsTransform?.(
|
|
152
|
+
Element = render,
|
|
153
|
+
transformedProps = import_core.hooks.usePropsTransform?.(render, viewProps, stateRef, !1);
|
|
168
154
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Element, {
|
|
169
155
|
...transformedProps,
|
|
170
156
|
ref: composedRefs
|
|
@@ -252,16 +238,17 @@ function createAnimations(animationsConfig) {
|
|
|
252
238
|
presence,
|
|
253
239
|
style,
|
|
254
240
|
componentState,
|
|
255
|
-
useStyleEmitter
|
|
241
|
+
useStyleEmitter,
|
|
242
|
+
themeName
|
|
256
243
|
} = animationProps,
|
|
257
|
-
animationKey =
|
|
244
|
+
animationKey = (0, import_animation_helpers.normalizeTransition)(props.transition).default,
|
|
258
245
|
isHydrating = componentState.unmounted === !0,
|
|
259
246
|
isMounting = componentState.unmounted === "should-enter",
|
|
260
247
|
disableAnimation = isHydrating || !animationKey,
|
|
261
|
-
|
|
262
|
-
isDark = themeState?.scheme === "dark" || themeState?.name?.startsWith("dark"),
|
|
248
|
+
isDark = themeName?.startsWith("dark") || !1,
|
|
263
249
|
isExiting = presence?.[0] === !1,
|
|
264
250
|
sendExitComplete = presence?.[1],
|
|
251
|
+
exitProgress = (0, import_react_native_reanimated.useSharedValue)(0),
|
|
265
252
|
animatedTargetsRef = (0, import_react_native_reanimated.useSharedValue)(null),
|
|
266
253
|
staticTargetsRef = (0, import_react_native_reanimated.useSharedValue)(null),
|
|
267
254
|
transformTargetsRef = (0, import_react_native_reanimated.useSharedValue)(null),
|
|
@@ -300,24 +287,27 @@ function createAnimations(animationsConfig) {
|
|
|
300
287
|
},
|
|
301
288
|
propertyConfigs: {}
|
|
302
289
|
};
|
|
303
|
-
const
|
|
304
|
-
let base =
|
|
290
|
+
const normalized2 = (0, import_animation_helpers.normalizeTransition)(props.transition);
|
|
291
|
+
let base = normalized2.default ? animations[normalized2.default] ?? {
|
|
305
292
|
type: "spring"
|
|
306
293
|
} : {
|
|
307
294
|
type: "spring"
|
|
308
295
|
};
|
|
309
|
-
|
|
296
|
+
normalized2.delay && (base = {
|
|
310
297
|
...base,
|
|
311
|
-
delay:
|
|
298
|
+
delay: normalized2.delay
|
|
312
299
|
});
|
|
313
300
|
const overrides = {};
|
|
314
|
-
for (const
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
301
|
+
for (const key in normalized2.properties) {
|
|
302
|
+
const animationNameOrConfig = normalized2.properties[key];
|
|
303
|
+
if (typeof animationNameOrConfig == "string") overrides[key] = animations[animationNameOrConfig] ?? base;else if (animationNameOrConfig && typeof animationNameOrConfig == "object") {
|
|
304
|
+
const configType = animationNameOrConfig.type,
|
|
305
|
+
baseForProp = configType ? animations[configType] ?? base : base;
|
|
306
|
+
overrides[key] = {
|
|
307
|
+
...baseForProp,
|
|
308
|
+
...animationNameOrConfig
|
|
309
|
+
};
|
|
310
|
+
}
|
|
321
311
|
}
|
|
322
312
|
const configs = {},
|
|
323
313
|
allKeys = new Set(Object.keys(animatedStyles));
|
|
@@ -328,18 +318,20 @@ function createAnimations(animationsConfig) {
|
|
|
328
318
|
propertyConfigs: configs
|
|
329
319
|
};
|
|
330
320
|
}, [isHydrating, props.transition, animatedStyles]),
|
|
331
|
-
configRef = (0,
|
|
321
|
+
configRef = (0, import_react_native_reanimated.useSharedValue)({
|
|
332
322
|
baseConfig,
|
|
333
323
|
propertyConfigs,
|
|
334
324
|
disableAnimation,
|
|
335
325
|
isHydrating
|
|
336
326
|
});
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
327
|
+
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
328
|
+
configRef.set({
|
|
329
|
+
baseConfig,
|
|
330
|
+
propertyConfigs,
|
|
331
|
+
disableAnimation,
|
|
332
|
+
isHydrating
|
|
333
|
+
});
|
|
334
|
+
}, [baseConfig, propertyConfigs, disableAnimation, isHydrating]), useStyleEmitter?.(nextStyle => {
|
|
343
335
|
const animateOnly = props.animateOnly,
|
|
344
336
|
animated = {},
|
|
345
337
|
statics = {},
|
|
@@ -347,8 +339,8 @@ function createAnimations(animationsConfig) {
|
|
|
347
339
|
for (const key in nextStyle) {
|
|
348
340
|
const rawValue = nextStyle[key],
|
|
349
341
|
value = resolveDynamicValue(rawValue, isDark);
|
|
350
|
-
if (value
|
|
351
|
-
if (configRef.
|
|
342
|
+
if (value != null) {
|
|
343
|
+
if (configRef.get().disableAnimation) {
|
|
352
344
|
statics[key] = value;
|
|
353
345
|
continue;
|
|
354
346
|
}
|
|
@@ -363,26 +355,36 @@ function createAnimations(animationsConfig) {
|
|
|
363
355
|
canAnimateProperty(key, value, animateOnly) ? animated[key] = value : statics[key] = value;
|
|
364
356
|
}
|
|
365
357
|
}
|
|
366
|
-
animatedTargetsRef.
|
|
358
|
+
animatedTargetsRef.set(animated), staticTargetsRef.set(statics), transformTargetsRef.set(transforms), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-reanimated] useStyleEmitter update", {
|
|
367
359
|
animated,
|
|
368
360
|
statics,
|
|
369
361
|
transforms
|
|
370
362
|
});
|
|
371
363
|
}), import_react.default.useEffect(() => {
|
|
372
364
|
if (!isExiting || !sendExitComplete) return;
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
365
|
+
const config = configRef.get().baseConfig;
|
|
366
|
+
return config.type === "timing" ? exitProgress.set((0, import_react_native_reanimated.withTiming)(1, config, finished => {
|
|
367
|
+
"worklet";
|
|
368
|
+
|
|
369
|
+
finished && (0, import_react_native_reanimated.runOnJS)(sendExitComplete)();
|
|
370
|
+
})) : exitProgress.set((0, import_react_native_reanimated.withSpring)(1, config, finished => {
|
|
371
|
+
"worklet";
|
|
372
|
+
|
|
373
|
+
finished && (0, import_react_native_reanimated.runOnJS)(sendExitComplete)();
|
|
374
|
+
})), () => {
|
|
375
|
+
(0, import_react_native_reanimated.cancelAnimation)(exitProgress);
|
|
376
|
+
};
|
|
377
|
+
}, [isExiting, sendExitComplete]);
|
|
377
378
|
const animatedStyle = (0, import_react_native_reanimated.useAnimatedStyle)(() => {
|
|
378
379
|
"worklet";
|
|
379
380
|
|
|
380
381
|
if (disableAnimation || isHydrating) return {};
|
|
381
382
|
const result = {},
|
|
382
|
-
config = configRef.
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
383
|
+
config = configRef.get(),
|
|
384
|
+
emitterAnimated = animatedTargetsRef.get(),
|
|
385
|
+
hasEmitterUpdates = emitterAnimated !== null,
|
|
386
|
+
animatedValues = hasEmitterUpdates ? emitterAnimated : animatedStyles,
|
|
387
|
+
staticValues = hasEmitterUpdates ? staticTargetsRef.get() : {};
|
|
386
388
|
for (const key in staticValues) result[key] = staticValues[key];
|
|
387
389
|
for (const key in animatedValues) {
|
|
388
390
|
if (key === "transform") continue;
|
|
@@ -390,22 +392,23 @@ function createAnimations(animationsConfig) {
|
|
|
390
392
|
propConfig = config.propertyConfigs[key] ?? config.baseConfig;
|
|
391
393
|
result[key] = applyAnimation(targetValue, propConfig);
|
|
392
394
|
}
|
|
393
|
-
const transforms = hasEmitterUpdates ? transformTargetsRef.
|
|
395
|
+
const transforms = hasEmitterUpdates ? transformTargetsRef.get() : animatedStyles.transform;
|
|
394
396
|
if (transforms && Array.isArray(transforms)) {
|
|
395
|
-
const validTransforms =
|
|
396
|
-
|
|
397
|
+
const validTransforms = [];
|
|
398
|
+
for (const t of transforms) {
|
|
399
|
+
if (!t) continue;
|
|
397
400
|
const keys = Object.keys(t);
|
|
398
|
-
if (keys.length === 0)
|
|
401
|
+
if (keys.length === 0) continue;
|
|
399
402
|
const value = t[keys[0]];
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
}
|
|
408
|
-
}
|
|
403
|
+
if (typeof value == "number" || typeof value == "string") {
|
|
404
|
+
const transformKey = Object.keys(t)[0],
|
|
405
|
+
targetValue = t[transformKey],
|
|
406
|
+
propConfig = config.propertyConfigs[transformKey] ?? config.baseConfig;
|
|
407
|
+
validTransforms.push({
|
|
408
|
+
[transformKey]: applyAnimation(targetValue, propConfig)
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
409
412
|
validTransforms.length > 0 && (result.transform = validTransforms);
|
|
410
413
|
}
|
|
411
414
|
return result;
|
|
@@ -25,7 +25,7 @@ __export(createAnimations_exports, {
|
|
|
25
25
|
createAnimations: () => createAnimations
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(createAnimations_exports);
|
|
28
|
-
var import_animation_helpers = require("@tamagui/animation-helpers"),
|
|
28
|
+
var import_animation_helpers = require("@tamagui/animation-helpers"), import_core = require("@tamagui/core"), import_use_presence = require("@tamagui/use-presence"), import_react = __toESM(require("react"), 1), import_react_native_reanimated = __toESM(require("react-native-reanimated"), 1), import_jsx_runtime = require("react/jsx-runtime");
|
|
29
29
|
const getDefaultExport = (module2) => {
|
|
30
30
|
const mod = module2;
|
|
31
31
|
return (mod.__esModule || mod[Symbol.toStringTag] === "Module") && mod.default || mod;
|
|
@@ -40,16 +40,6 @@ const getDefaultExport = (module2) => {
|
|
|
40
40
|
const delay = config.delay;
|
|
41
41
|
let animatedValue;
|
|
42
42
|
return config.type === "timing" ? animatedValue = (0, import_react_native_reanimated.withTiming)(targetValue, config) : animatedValue = (0, import_react_native_reanimated.withSpring)(targetValue, config), delay && delay > 0 && (animatedValue = (0, import_react_native_reanimated.withDelay)(delay, animatedValue)), animatedValue;
|
|
43
|
-
}, estimateSpringDuration = (config) => {
|
|
44
|
-
const stiffness = config.stiffness ?? 100, damping = config.damping ?? 10, mass = config.mass ?? 1;
|
|
45
|
-
if (mass <= 0 || stiffness <= 0)
|
|
46
|
-
return 400;
|
|
47
|
-
const omega0 = Math.sqrt(stiffness / mass), zeta = damping / (2 * Math.sqrt(stiffness * mass));
|
|
48
|
-
let duration;
|
|
49
|
-
return zeta < 1 && zeta > 0 && omega0 > 0 ? duration = 4 / (zeta * omega0) * 1e3 : omega0 > 0 ? duration = 2 / omega0 * 1e3 : duration = 400, Number.isFinite(duration) ? Math.ceil(Math.min(2e3, Math.max(200, duration)) * 1.15) : 400;
|
|
50
|
-
}, getAnimationDuration = (config) => {
|
|
51
|
-
const delay = Math.max(0, config.delay ?? 0);
|
|
52
|
-
return config.type === "timing" ? Math.max(0, config.duration ?? 300) + delay + 50 : estimateSpringDuration(config) + delay;
|
|
53
43
|
}, ANIMATABLE_PROPERTIES = {
|
|
54
44
|
// Transform
|
|
55
45
|
transform: !0,
|
|
@@ -120,7 +110,7 @@ const getDefaultExport = (module2) => {
|
|
|
120
110
|
function createWebAnimatedComponent(defaultTag) {
|
|
121
111
|
const isText = defaultTag === "span", Component = Animated.createAnimatedComponent(
|
|
122
112
|
(0, import_react.forwardRef)((propsIn, ref) => {
|
|
123
|
-
const { forwardedRef,
|
|
113
|
+
const { forwardedRef, render = defaultTag, ...rest } = propsIn, hostRef = (0, import_react.useRef)(null), composedRefs = (0, import_core.useComposedRefs)(forwardedRef, ref, hostRef), stateRef = (0, import_react.useRef)({
|
|
124
114
|
get host() {
|
|
125
115
|
return hostRef.current;
|
|
126
116
|
}
|
|
@@ -131,8 +121,8 @@ function createWebAnimatedComponent(defaultTag) {
|
|
|
131
121
|
themeState?.name ?? "",
|
|
132
122
|
{ unmounted: !1 },
|
|
133
123
|
{ isAnimated: !1, noClass: !0 }
|
|
134
|
-
)?.viewProps ?? {}, Element =
|
|
135
|
-
|
|
124
|
+
)?.viewProps ?? {}, Element = render, transformedProps = import_core.hooks.usePropsTransform?.(
|
|
125
|
+
render,
|
|
136
126
|
viewProps,
|
|
137
127
|
stateRef,
|
|
138
128
|
!1
|
|
@@ -225,7 +215,7 @@ function createAnimations(animationsConfig) {
|
|
|
225
215
|
// useAnimations - Main animation hook for components
|
|
226
216
|
// =========================================================================
|
|
227
217
|
useAnimations(animationProps) {
|
|
228
|
-
const { props, presence, style, componentState, useStyleEmitter } = animationProps, animationKey =
|
|
218
|
+
const { props, presence, style, componentState, useStyleEmitter, themeName } = animationProps, animationKey = (0, import_animation_helpers.normalizeTransition)(props.transition).default, isHydrating = componentState.unmounted === !0, isMounting = componentState.unmounted === "should-enter", disableAnimation = isHydrating || !animationKey, isDark = themeName?.startsWith("dark") || !1, isExiting = presence?.[0] === !1, sendExitComplete = presence?.[1], exitProgress = (0, import_react_native_reanimated.useSharedValue)(0), animatedTargetsRef = (0, import_react_native_reanimated.useSharedValue)(null), staticTargetsRef = (0, import_react_native_reanimated.useSharedValue)(null), transformTargetsRef = (0, import_react_native_reanimated.useSharedValue)(
|
|
229
219
|
null
|
|
230
220
|
), { animatedStyles, staticStyles } = (0, import_react.useMemo)(() => {
|
|
231
221
|
const animated = {}, staticStyles2 = {}, animateOnly = props.animateOnly;
|
|
@@ -249,13 +239,12 @@ function createAnimations(animationsConfig) {
|
|
|
249
239
|
baseConfig: { type: "timing", duration: 0 },
|
|
250
240
|
propertyConfigs: {}
|
|
251
241
|
};
|
|
252
|
-
const
|
|
253
|
-
let base =
|
|
254
|
-
|
|
242
|
+
const normalized2 = (0, import_animation_helpers.normalizeTransition)(props.transition);
|
|
243
|
+
let base = normalized2.default ? animations[normalized2.default] ?? { type: "spring" } : { type: "spring" };
|
|
244
|
+
normalized2.delay && (base = { ...base, delay: normalized2.delay });
|
|
255
245
|
const overrides = {};
|
|
256
|
-
for (const
|
|
257
|
-
|
|
258
|
-
))
|
|
246
|
+
for (const key in normalized2.properties) {
|
|
247
|
+
const animationNameOrConfig = normalized2.properties[key];
|
|
259
248
|
if (typeof animationNameOrConfig == "string")
|
|
260
249
|
overrides[key] = animations[animationNameOrConfig] ?? base;
|
|
261
250
|
else if (animationNameOrConfig && typeof animationNameOrConfig == "object") {
|
|
@@ -265,6 +254,7 @@ function createAnimations(animationsConfig) {
|
|
|
265
254
|
...animationNameOrConfig
|
|
266
255
|
};
|
|
267
256
|
}
|
|
257
|
+
}
|
|
268
258
|
const configs = {}, allKeys = new Set(Object.keys(animatedStyles));
|
|
269
259
|
if (animatedStyles.transform && Array.isArray(animatedStyles.transform))
|
|
270
260
|
for (const t of animatedStyles.transform)
|
|
@@ -272,18 +262,20 @@ function createAnimations(animationsConfig) {
|
|
|
272
262
|
for (const key of allKeys)
|
|
273
263
|
configs[key] = overrides[key] ?? base;
|
|
274
264
|
return { baseConfig: base, propertyConfigs: configs };
|
|
275
|
-
}, [isHydrating, props.transition, animatedStyles]), configRef = (0,
|
|
265
|
+
}, [isHydrating, props.transition, animatedStyles]), configRef = (0, import_react_native_reanimated.useSharedValue)({
|
|
276
266
|
baseConfig,
|
|
277
267
|
propertyConfigs,
|
|
278
268
|
disableAnimation,
|
|
279
269
|
isHydrating
|
|
280
270
|
});
|
|
281
|
-
|
|
271
|
+
(0, import_core.useIsomorphicLayoutEffect)(() => {
|
|
272
|
+
configRef.set({ baseConfig, propertyConfigs, disableAnimation, isHydrating });
|
|
273
|
+
}, [baseConfig, propertyConfigs, disableAnimation, isHydrating]), useStyleEmitter?.((nextStyle) => {
|
|
282
274
|
const animateOnly = props.animateOnly, animated = {}, statics = {}, transforms = [];
|
|
283
275
|
for (const key in nextStyle) {
|
|
284
276
|
const rawValue = nextStyle[key], value = resolveDynamicValue(rawValue, isDark);
|
|
285
|
-
if (value
|
|
286
|
-
if (configRef.
|
|
277
|
+
if (value != null) {
|
|
278
|
+
if (configRef.get().disableAnimation) {
|
|
287
279
|
statics[key] = value;
|
|
288
280
|
continue;
|
|
289
281
|
}
|
|
@@ -298,21 +290,33 @@ function createAnimations(animationsConfig) {
|
|
|
298
290
|
canAnimateProperty(key, value, animateOnly) ? animated[key] = value : statics[key] = value;
|
|
299
291
|
}
|
|
300
292
|
}
|
|
301
|
-
animatedTargetsRef.
|
|
293
|
+
animatedTargetsRef.set(animated), staticTargetsRef.set(statics), transformTargetsRef.set(transforms), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-reanimated] useStyleEmitter update", {
|
|
302
294
|
animated,
|
|
303
295
|
statics,
|
|
304
296
|
transforms
|
|
305
297
|
});
|
|
306
298
|
}), import_react.default.useEffect(() => {
|
|
307
299
|
if (!isExiting || !sendExitComplete) return;
|
|
308
|
-
const
|
|
309
|
-
return
|
|
310
|
-
|
|
300
|
+
const config = configRef.get().baseConfig;
|
|
301
|
+
return config.type === "timing" ? exitProgress.set(
|
|
302
|
+
(0, import_react_native_reanimated.withTiming)(1, config, (finished) => {
|
|
303
|
+
"worklet";
|
|
304
|
+
finished && (0, import_react_native_reanimated.runOnJS)(sendExitComplete)();
|
|
305
|
+
})
|
|
306
|
+
) : exitProgress.set(
|
|
307
|
+
(0, import_react_native_reanimated.withSpring)(1, config, (finished) => {
|
|
308
|
+
"worklet";
|
|
309
|
+
finished && (0, import_react_native_reanimated.runOnJS)(sendExitComplete)();
|
|
310
|
+
})
|
|
311
|
+
), () => {
|
|
312
|
+
(0, import_react_native_reanimated.cancelAnimation)(exitProgress);
|
|
313
|
+
};
|
|
314
|
+
}, [isExiting, sendExitComplete]);
|
|
311
315
|
const animatedStyle = (0, import_react_native_reanimated.useAnimatedStyle)(() => {
|
|
312
316
|
"worklet";
|
|
313
317
|
if (disableAnimation || isHydrating)
|
|
314
318
|
return {};
|
|
315
|
-
const result = {}, config = configRef.
|
|
319
|
+
const result = {}, config = configRef.get(), emitterAnimated = animatedTargetsRef.get(), hasEmitterUpdates = emitterAnimated !== null, animatedValues = hasEmitterUpdates ? emitterAnimated : animatedStyles, staticValues = hasEmitterUpdates ? staticTargetsRef.get() : {};
|
|
316
320
|
for (const key in staticValues)
|
|
317
321
|
result[key] = staticValues[key];
|
|
318
322
|
for (const key in animatedValues) {
|
|
@@ -320,18 +324,21 @@ function createAnimations(animationsConfig) {
|
|
|
320
324
|
const targetValue = animatedValues[key], propConfig = config.propertyConfigs[key] ?? config.baseConfig;
|
|
321
325
|
result[key] = applyAnimation(targetValue, propConfig);
|
|
322
326
|
}
|
|
323
|
-
const transforms = hasEmitterUpdates ? transformTargetsRef.
|
|
327
|
+
const transforms = hasEmitterUpdates ? transformTargetsRef.get() : animatedStyles.transform;
|
|
324
328
|
if (transforms && Array.isArray(transforms)) {
|
|
325
|
-
const validTransforms =
|
|
326
|
-
|
|
329
|
+
const validTransforms = [];
|
|
330
|
+
for (const t of transforms) {
|
|
331
|
+
if (!t) continue;
|
|
327
332
|
const keys = Object.keys(t);
|
|
328
|
-
if (keys.length === 0)
|
|
333
|
+
if (keys.length === 0) continue;
|
|
329
334
|
const value = t[keys[0]];
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
+
if (typeof value == "number" || typeof value == "string") {
|
|
336
|
+
const transformKey = Object.keys(t)[0], targetValue = t[transformKey], propConfig = config.propertyConfigs[transformKey] ?? config.baseConfig;
|
|
337
|
+
validTransforms.push({
|
|
338
|
+
[transformKey]: applyAnimation(targetValue, propConfig)
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
335
342
|
validTransforms.length > 0 && (result.transform = validTransforms);
|
|
336
343
|
}
|
|
337
344
|
return result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createAnimations.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAoC,uCACpC,sBAA2C,kCAC3C,
|
|
5
|
-
"names": ["module", "Animated_", "staticStyles", "React"]
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAoC,uCACpC,cAWO,0BACP,sBAA2C,kCAC3C,eAAmD,8BAEnD,iCAYO,gDAuNM;AA7Mb,MAAM,mBAAmB,CAAKA,YAAkC;AAC9D,QAAM,MAAMA;AACZ,UAAI,IAAI,cAAc,IAAI,OAAO,WAAW,MAAM,aACzC,IAAI,WAAW;AAG1B,GAEM,WAAW,iBAAiB,+BAAAC,OAAS,GA8BrC,sBAAsB,CAAC,OAAgB,WAA6B;AACxE,MACE,UAAU,QACV,OAAO,SAAU,YACjB,aAAa,SACb,OAAQ,MAAc,WAAY,UAClC;AACA,UAAM,UAAW,MAAc;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