@tamagui/animations-react-native 2.0.0-rc.35 → 2.0.0-rc.36-1775243248161

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.
@@ -4,53 +4,63 @@ import { ResetPresence, usePresence } from "@tamagui/use-presence";
4
4
  import { useEvent, useThemeWithState } from "@tamagui/web";
5
5
  import React from "react";
6
6
  import { Animated } from "react-native-web";
7
- const isFabric = !isWeb && typeof global < "u" && !!global.__nativeFabricUIManager,
8
- resolveDynamicValue = (value, isDark) => value && typeof value == "object" && "dynamic" in value ? isDark ? value.dynamic.dark : value.dynamic.light : value,
9
- animatedStyleKey = {
10
- transform: !0,
11
- opacity: !0
12
- },
13
- colorStyleKey = {
14
- backgroundColor: !0,
15
- color: !0,
16
- borderColor: !0,
17
- borderLeftColor: !0,
18
- borderRightColor: !0,
19
- borderTopColor: !0,
20
- borderBottomColor: !0
21
- },
22
- costlyToAnimateStyleKey = {
23
- borderRadius: !0,
24
- borderTopLeftRadius: !0,
25
- borderTopRightRadius: !0,
26
- borderBottomLeftRadius: !0,
27
- borderBottomRightRadius: !0,
28
- borderWidth: !0,
29
- borderLeftWidth: !0,
30
- borderRightWidth: !0,
31
- borderTopWidth: !0,
32
- borderBottomWidth: !0,
33
- ...colorStyleKey
34
- },
35
- AnimatedView = Animated.View,
36
- AnimatedText = Animated.Text;
7
+ const isFabric = !isWeb && typeof global !== "undefined" && !!global.__nativeFabricUIManager;
8
+ const resolveDynamicValue = (value, isDark) => {
9
+ if (value && typeof value === "object" && "dynamic" in value) {
10
+ const dynamicValue = isDark ? value.dynamic.dark : value.dynamic.light;
11
+ return dynamicValue;
12
+ }
13
+ return value;
14
+ };
15
+ const animatedStyleKey = {
16
+ transform: true,
17
+ opacity: true
18
+ };
19
+ const colorStyleKey = {
20
+ backgroundColor: true,
21
+ color: true,
22
+ borderColor: true,
23
+ borderLeftColor: true,
24
+ borderRightColor: true,
25
+ borderTopColor: true,
26
+ borderBottomColor: true
27
+ };
28
+ const costlyToAnimateStyleKey = {
29
+ borderRadius: true,
30
+ borderTopLeftRadius: true,
31
+ borderTopRightRadius: true,
32
+ borderBottomLeftRadius: true,
33
+ borderBottomRightRadius: true,
34
+ borderWidth: true,
35
+ borderLeftWidth: true,
36
+ borderRightWidth: true,
37
+ borderTopWidth: true,
38
+ borderBottomWidth: true,
39
+ ...colorStyleKey
40
+ };
41
+ const AnimatedView = Animated.View;
42
+ const AnimatedText = Animated.Text;
37
43
  function useAnimatedNumber(initial) {
38
44
  const state = React.useRef(null);
39
- return state.current || (state.current = {
40
- composite: null,
41
- val: new Animated.Value(initial),
42
- strategy: {
43
- type: "spring"
44
- }
45
- }), {
45
+ if (!state.current) {
46
+ state.current = {
47
+ composite: null,
48
+ val: new Animated.Value(initial),
49
+ strategy: {
50
+ type: "spring"
51
+ }
52
+ };
53
+ }
54
+ return {
46
55
  getInstance() {
47
56
  return state.current.val;
48
57
  },
49
58
  getValue() {
50
- return state.current.val._value;
59
+ return state.current.val["_value"];
51
60
  },
52
61
  stop() {
53
- state.current.composite?.stop(), state.current.composite = null;
62
+ state.current.composite?.stop();
63
+ state.current.composite = null;
54
64
  },
55
65
  setValue(next, {
56
66
  type,
@@ -58,18 +68,21 @@ function useAnimatedNumber(initial) {
58
68
  } = {
59
69
  type: "spring"
60
70
  }, onFinish) {
61
- const val = state.current.val,
62
- handleFinish = onFinish ? ({
63
- finished
64
- }) => finished ? onFinish() : null : void 0;
65
- if (type === "direct") val.setValue(next);else if (type === "spring") {
71
+ const val = state.current.val;
72
+ const handleFinish = onFinish ? ({
73
+ finished
74
+ }) => finished ? onFinish() : null : void 0;
75
+ if (type === "direct") {
76
+ val.setValue(next);
77
+ } else if (type === "spring") {
66
78
  state.current.composite?.stop();
67
79
  const composite = Animated.spring(val, {
68
80
  ...config,
69
81
  toValue: next,
70
82
  useNativeDriver: isFabric
71
83
  });
72
- composite.start(handleFinish), state.current.composite = composite;
84
+ composite.start(handleFinish);
85
+ state.current.composite = composite;
73
86
  } else {
74
87
  state.current.composite?.stop();
75
88
  const composite = Animated.timing(val, {
@@ -77,35 +90,40 @@ function useAnimatedNumber(initial) {
77
90
  toValue: next,
78
91
  useNativeDriver: isFabric
79
92
  });
80
- composite.start(handleFinish), state.current.composite = composite;
93
+ composite.start(handleFinish);
94
+ state.current.composite = composite;
81
95
  }
82
96
  }
83
97
  };
84
98
  }
85
99
  const useAnimatedNumberReaction = ({
86
- value
87
- }, onValue) => {
88
- const onChange = useEvent(current => {
89
- onValue(current.value);
90
- });
91
- React.useEffect(() => {
92
- const id = value.getInstance().addListener(onChange);
93
- return () => {
94
- value.getInstance().removeListener(id);
95
- };
96
- }, [value, onChange]);
97
- },
98
- useAnimatedNumberStyle = (value, getStyle) => getStyle(value.getInstance()),
99
- useAnimatedNumbersStyle = (vals, getStyle) => getStyle(...vals.map(v => v.getInstance()));
100
+ value
101
+ }, onValue) => {
102
+ const onChange = useEvent(current => {
103
+ onValue(current.value);
104
+ });
105
+ React.useEffect(() => {
106
+ const id = value.getInstance().addListener(onChange);
107
+ return () => {
108
+ value.getInstance().removeListener(id);
109
+ };
110
+ }, [value, onChange]);
111
+ };
112
+ const useAnimatedNumberStyle = (value, getStyle) => {
113
+ return getStyle(value.getInstance());
114
+ };
115
+ const useAnimatedNumbersStyle = (vals, getStyle) => {
116
+ return getStyle(...vals.map(v => v.getInstance()));
117
+ };
100
118
  function createAnimations(animations, options) {
101
119
  const nativeDriver = options?.useNativeDriver ?? isFabric;
102
120
  return {
103
- isReactNative: !0,
121
+ isReactNative: true,
104
122
  inputStyle: "value",
105
123
  outputStyle: "inline",
106
- avoidReRenders: !0,
124
+ avoidReRenders: true,
107
125
  animations,
108
- needsCustomComponent: !0,
126
+ needsCustomComponent: true,
109
127
  View: AnimatedView,
110
128
  Text: AnimatedText,
111
129
  useAnimatedNumber,
@@ -122,170 +140,221 @@ function createAnimations(animations, options) {
122
140
  presence,
123
141
  useStyleEmitter
124
142
  }) => {
125
- const isDisabled = isWeb && componentState.unmounted === !0,
126
- isExiting = presence?.[0] === !1,
127
- sendExitComplete = presence?.[1],
128
- [, themeState] = useThemeWithState({}),
129
- isDark = themeState?.scheme === "dark" || themeState?.name?.startsWith("dark"),
130
- animateStyles = React.useRef({}),
131
- animatedTranforms = React.useRef([]),
132
- animationsState = React.useRef(/* @__PURE__ */new WeakMap()),
133
- exitCycleIdRef = React.useRef(0),
134
- exitCompletedRef = React.useRef(!1),
135
- wasExitingRef = React.useRef(!1),
136
- justStartedExiting = isExiting && !wasExitingRef.current,
137
- justStoppedExiting = !isExiting && wasExitingRef.current;
138
- justStartedExiting && (exitCycleIdRef.current++, exitCompletedRef.current = !1), justStoppedExiting && exitCycleIdRef.current++;
139
- const animateOnly = props.animateOnly || [],
140
- hasTransitionOnly = !!props.animateOnly,
141
- isEntering = !!componentState.unmounted,
142
- wasEnteringRef = React.useRef(isEntering),
143
- justFinishedEntering = wasEnteringRef.current && !isEntering;
143
+ const isDisabled = isWeb && componentState.unmounted === true;
144
+ const isExiting = presence?.[0] === false;
145
+ const sendExitComplete = presence?.[1];
146
+ const [, themeState] = useThemeWithState({});
147
+ const isDark = themeState?.scheme === "dark" || themeState?.name?.startsWith("dark");
148
+ const animateStyles = React.useRef({});
149
+ const animatedTranforms = React.useRef([]);
150
+ const animationsState = React.useRef(/* @__PURE__ */new WeakMap());
151
+ const exitCycleIdRef = React.useRef(0);
152
+ const exitCompletedRef = React.useRef(false);
153
+ const wasExitingRef = React.useRef(false);
154
+ const justStartedExiting = isExiting && !wasExitingRef.current;
155
+ const justStoppedExiting = !isExiting && wasExitingRef.current;
156
+ if (justStartedExiting) {
157
+ exitCycleIdRef.current++;
158
+ exitCompletedRef.current = false;
159
+ }
160
+ if (justStoppedExiting) {
161
+ exitCycleIdRef.current++;
162
+ }
163
+ const animateOnly = props.animateOnly || [];
164
+ const hasTransitionOnly = !!props.animateOnly;
165
+ const isEntering = !!componentState.unmounted;
166
+ const wasEnteringRef = React.useRef(isEntering);
167
+ const justFinishedEntering = wasEnteringRef.current && !isEntering;
144
168
  React.useEffect(() => {
145
169
  wasEnteringRef.current = isEntering;
146
170
  });
147
- const args = [JSON.stringify(style), componentState, isExiting, !!onDidAnimate, isDark, justFinishedEntering, hasTransitionOnly],
148
- res = React.useMemo(() => {
149
- const runners = [],
150
- completions = [],
151
- animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default",
152
- nonAnimatedStyle = {};
153
- for (const key in style) {
154
- const rawVal = style[key],
155
- val = resolveDynamicValue(rawVal, isDark);
156
- if (val !== void 0 && !isDisabled) {
157
- if (animatedStyleKey[key] == null && !costlyToAnimateStyleKey[key]) {
158
- nonAnimatedStyle[key] = val;
159
- continue;
160
- }
161
- if (hasTransitionOnly && !animateOnly.includes(key)) {
162
- nonAnimatedStyle[key] = val;
163
- continue;
164
- }
165
- if (key !== "transform") {
166
- animateStyles.current[key] = update(key, animateStyles.current[key], val);
167
- continue;
168
- }
169
- if (val) {
170
- if (typeof val == "string") {
171
- console.warn("Warning: Tamagui can't animate string transforms yet!");
172
- continue;
173
- }
174
- for (const [index, transform] of val.entries()) {
175
- if (!transform) continue;
176
- const tkey = Object.keys(transform)[0],
177
- currentTransform = animatedTranforms.current[index]?.[tkey];
178
- animatedTranforms.current[index] = {
179
- [tkey]: update(tkey, currentTransform, transform[tkey])
180
- }, animatedTranforms.current = [...animatedTranforms.current];
181
- }
182
- }
183
- }
171
+ const args = [JSON.stringify(style), componentState, isExiting, !!onDidAnimate, isDark, justFinishedEntering, hasTransitionOnly];
172
+ const res = React.useMemo(() => {
173
+ const runners = [];
174
+ const completions = [];
175
+ const animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
176
+ const nonAnimatedStyle = {};
177
+ for (const key in style) {
178
+ const rawVal = style[key];
179
+ const val = resolveDynamicValue(rawVal, isDark);
180
+ if (val === void 0) continue;
181
+ if (isDisabled) {
182
+ continue;
183
+ }
184
+ if (animatedStyleKey[key] == null && !costlyToAnimateStyleKey[key]) {
185
+ nonAnimatedStyle[key] = val;
186
+ continue;
187
+ }
188
+ if (hasTransitionOnly && !animateOnly.includes(key)) {
189
+ nonAnimatedStyle[key] = val;
190
+ continue;
184
191
  }
185
- const animatedTransformStyle = animatedTranforms.current.length > 0 ? {
186
- transform: animatedTranforms.current.map(r => {
187
- const key = Object.keys(r)[0],
188
- val = animationsState.current.get(r[key])?.interpolation || r[key];
189
- return {
190
- [key]: val
191
- };
192
- })
193
- } : {},
194
- animatedStyle = {
195
- ...Object.fromEntries(Object.entries(animateStyles.current).map(([k, v]) => [k, animationsState.current.get(v)?.interpolation || v])),
196
- ...animatedTransformStyle
192
+ if (key !== "transform") {
193
+ animateStyles.current[key] = update(key, animateStyles.current[key], val);
194
+ continue;
195
+ }
196
+ if (!val) continue;
197
+ if (typeof val === "string") {
198
+ console.warn(`Warning: Tamagui can't animate string transforms yet!`);
199
+ continue;
200
+ }
201
+ for (const [index, transform] of val.entries()) {
202
+ if (!transform) continue;
203
+ const tkey = Object.keys(transform)[0];
204
+ const currentTransform = animatedTranforms.current[index]?.[tkey];
205
+ animatedTranforms.current[index] = {
206
+ [tkey]: update(tkey, currentTransform, transform[tkey])
207
+ };
208
+ animatedTranforms.current = [...animatedTranforms.current];
209
+ }
210
+ }
211
+ const animatedTransformStyle = animatedTranforms.current.length > 0 ? {
212
+ transform: animatedTranforms.current.map(r => {
213
+ const key = Object.keys(r)[0];
214
+ const val = animationsState.current.get(r[key])?.interpolation || r[key];
215
+ return {
216
+ [key]: val
197
217
  };
198
- return {
199
- runners,
200
- completions,
201
- style: [nonAnimatedStyle, animatedStyle]
202
- };
203
- function update(key, animated, valIn) {
204
- const isColorStyleKey = colorStyleKey[key],
205
- [val, type] = isColorStyleKey ? [0, void 0] : getValue(valIn);
206
- let animateToValue = val;
207
- const value = animated || new Animated.Value(val),
208
- curInterpolation = animationsState.current.get(value);
209
- let interpolateArgs;
210
- if (type && (interpolateArgs = getInterpolated(curInterpolation?.current ?? value._value, val, type), animationsState.current.set(value, {
218
+ })
219
+ } : {};
220
+ const animatedStyle = {
221
+ ...Object.fromEntries(Object.entries(animateStyles.current).map(([k, v]) => [k, animationsState.current.get(v)?.interpolation || v])),
222
+ ...animatedTransformStyle
223
+ };
224
+ return {
225
+ runners,
226
+ completions,
227
+ style: [nonAnimatedStyle, animatedStyle]
228
+ };
229
+ function update(key, animated, valIn) {
230
+ const isColorStyleKey = colorStyleKey[key];
231
+ const [val, type] = isColorStyleKey ? [0, void 0] : getValue(valIn);
232
+ let animateToValue = val;
233
+ const value = animated || new Animated.Value(val);
234
+ const curInterpolation = animationsState.current.get(value);
235
+ let interpolateArgs;
236
+ if (type) {
237
+ interpolateArgs = getInterpolated(curInterpolation?.current ?? value["_value"], val, type);
238
+ animationsState.current.set(value, {
211
239
  interpolation: value.interpolate(interpolateArgs),
212
240
  current: val
213
- })), isColorStyleKey && (animateToValue = curInterpolation?.animateToValue ? 0 : 1, interpolateArgs = getColorInterpolated(curInterpolation?.current,
241
+ });
242
+ }
243
+ if (isColorStyleKey) {
244
+ animateToValue = curInterpolation?.animateToValue ? 0 : 1;
245
+ interpolateArgs = getColorInterpolated(curInterpolation?.current,
214
246
  // valIn is the next color
215
- valIn, animateToValue), animationsState.current.set(value, {
247
+ valIn, animateToValue);
248
+ animationsState.current.set(value, {
216
249
  current: valIn,
217
250
  interpolation: value.interpolate(interpolateArgs),
218
251
  animateToValue: curInterpolation?.animateToValue ? 0 : 1
219
- })), value) {
220
- const animationConfig = getAnimationConfig(key, animations, props.transition, animationState);
221
- let resolve;
222
- const promise = new Promise(res2 => {
223
- resolve = res2;
224
- });
225
- completions.push(promise), runners.push(() => {
226
- value.stopAnimation();
227
- function getAnimation() {
228
- return Animated[animationConfig.type || "spring"](value, {
229
- toValue: animateToValue,
230
- useNativeDriver: nativeDriver,
231
- ...animationConfig
232
- });
233
- }
234
- (animationConfig.delay ? Animated.sequence([Animated.delay(animationConfig.delay), getAnimation()]) : getAnimation()).start(({
235
- finished
236
- }) => {
237
- (finished || isExiting) && resolve();
252
+ });
253
+ }
254
+ if (value) {
255
+ const animationConfig = getAnimationConfig(key, animations, props.transition, animationState);
256
+ let resolve;
257
+ const promise = new Promise(res2 => {
258
+ resolve = res2;
259
+ });
260
+ completions.push(promise);
261
+ runners.push(() => {
262
+ value.stopAnimation();
263
+ function getAnimation() {
264
+ return Animated[animationConfig.type || "spring"](value, {
265
+ toValue: animateToValue,
266
+ useNativeDriver: nativeDriver,
267
+ ...animationConfig
238
268
  });
269
+ }
270
+ const animation = animationConfig.delay ? Animated.sequence([Animated.delay(animationConfig.delay), getAnimation()]) : getAnimation();
271
+ animation.start(({
272
+ finished
273
+ }) => {
274
+ if (finished || isExiting) {
275
+ resolve();
276
+ }
239
277
  });
278
+ });
279
+ }
280
+ if (process.env.NODE_ENV === "development") {
281
+ if (props["debug"] === "verbose") {
282
+ console.info(" \u{1F4A0} animate", key, `from (${value["_value"]}) to`, valIn, `(${val})`, "type", type, "interpolate", interpolateArgs);
240
283
  }
241
- return process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info(" \u{1F4A0} animate", key, `from (${value._value}) to`, valIn, `(${val})`, "type", type, "interpolate", interpolateArgs), value;
242
284
  }
243
- }, args);
244
- return React.useEffect(() => {
285
+ return value;
286
+ }
287
+ }, args);
288
+ React.useEffect(() => {
245
289
  wasExitingRef.current = isExiting;
246
- }), useIsomorphicLayoutEffect(() => {
290
+ });
291
+ useIsomorphicLayoutEffect(() => {
247
292
  res.runners.forEach(r => r());
248
293
  const cycleId = exitCycleIdRef.current;
249
294
  if (res.completions.length === 0) {
250
- onDidAnimate?.(), isExiting && !exitCompletedRef.current && (exitCompletedRef.current = !0, sendExitComplete?.());
295
+ onDidAnimate?.();
296
+ if (isExiting && !exitCompletedRef.current) {
297
+ exitCompletedRef.current = true;
298
+ sendExitComplete?.();
299
+ }
251
300
  return;
252
301
  }
253
- let cancel = !1;
254
- return Promise.all(res.completions).then(() => {
255
- cancel || isExiting && cycleId !== exitCycleIdRef.current || isExiting && exitCompletedRef.current || (onDidAnimate?.(), isExiting && (exitCompletedRef.current = !0, sendExitComplete?.()));
256
- }), () => {
257
- cancel = !0;
302
+ let cancel = false;
303
+ Promise.all(res.completions).then(() => {
304
+ if (cancel) return;
305
+ if (isExiting && cycleId !== exitCycleIdRef.current) return;
306
+ if (isExiting && exitCompletedRef.current) return;
307
+ onDidAnimate?.();
308
+ if (isExiting) {
309
+ exitCompletedRef.current = true;
310
+ sendExitComplete?.();
311
+ }
312
+ });
313
+ return () => {
314
+ cancel = true;
258
315
  };
259
- }, args), useStyleEmitter?.(nextStyle => {
316
+ }, args);
317
+ useStyleEmitter?.(nextStyle => {
260
318
  for (const key in nextStyle) {
261
- const rawVal = nextStyle[key],
262
- val = resolveDynamicValue(rawVal, isDark);
263
- if (val !== void 0) if (key === "transform" && Array.isArray(val)) for (const [index, transform] of val.entries()) {
264
- if (!transform) continue;
265
- const tkey = Object.keys(transform)[0],
266
- currentTransform = animatedTranforms.current[index]?.[tkey];
267
- animatedTranforms.current[index] = {
268
- [tkey]: update(tkey, currentTransform, transform[tkey])
269
- };
270
- } else (animatedStyleKey[key] != null || costlyToAnimateStyleKey[key]) && (animateStyles.current[key] = update(key, animateStyles.current[key], val));
319
+ const rawVal = nextStyle[key];
320
+ const val = resolveDynamicValue(rawVal, isDark);
321
+ if (val === void 0) continue;
322
+ if (key === "transform" && Array.isArray(val)) {
323
+ for (const [index, transform] of val.entries()) {
324
+ if (!transform) continue;
325
+ const tkey = Object.keys(transform)[0];
326
+ const currentTransform = animatedTranforms.current[index]?.[tkey];
327
+ animatedTranforms.current[index] = {
328
+ [tkey]: update(tkey, currentTransform, transform[tkey])
329
+ };
330
+ }
331
+ } else if (animatedStyleKey[key] != null || costlyToAnimateStyleKey[key]) {
332
+ animateStyles.current[key] = update(key, animateStyles.current[key], val);
333
+ }
271
334
  }
272
335
  res.runners.forEach(r => r());
273
336
  function update(key, animated, valIn) {
274
- const isColor = colorStyleKey[key],
275
- [numVal, type] = isColor ? [0, void 0] : getValue(valIn);
337
+ const isColor = colorStyleKey[key];
338
+ const [numVal, type] = isColor ? [0, void 0] : getValue(valIn);
276
339
  let animateToValue = numVal;
277
- const value = animated || new Animated.Value(numVal),
278
- curInterpolation = animationsState.current.get(value);
279
- type && animationsState.current.set(value, {
280
- interpolation: value.interpolate(getInterpolated(curInterpolation?.current ?? value._value, numVal, type)),
281
- current: numVal
282
- }), isColor && (animateToValue = curInterpolation?.animateToValue ? 0 : 1, animationsState.current.set(value, {
283
- current: valIn,
284
- interpolation: value.interpolate(getColorInterpolated(curInterpolation?.current, valIn, animateToValue)),
285
- animateToValue: curInterpolation?.animateToValue ? 0 : 1
286
- }));
340
+ const value = animated || new Animated.Value(numVal);
341
+ const curInterpolation = animationsState.current.get(value);
342
+ if (type) {
343
+ animationsState.current.set(value, {
344
+ interpolation: value.interpolate(getInterpolated(curInterpolation?.current ?? value["_value"], numVal, type)),
345
+ current: numVal
346
+ });
347
+ }
348
+ if (isColor) {
349
+ animateToValue = curInterpolation?.animateToValue ? 0 : 1;
350
+ animationsState.current.set(value, {
351
+ current: valIn,
352
+ interpolation: value.interpolate(getColorInterpolated(curInterpolation?.current, valIn, animateToValue)),
353
+ animateToValue: curInterpolation?.animateToValue ? 0 : 1
354
+ });
355
+ }
287
356
  const animationConfig = getAnimationConfig(key, animations, props.transition, "default");
288
- return res.runners.push(() => {
357
+ res.runners.push(() => {
289
358
  value.stopAnimation();
290
359
  const anim = Animated[animationConfig.type || "spring"](value, {
291
360
  toValue: animateToValue,
@@ -293,44 +362,72 @@ function createAnimations(animations, options) {
293
362
  ...animationConfig
294
363
  });
295
364
  (animationConfig.delay ? Animated.sequence([Animated.delay(animationConfig.delay), anim]) : anim).start();
296
- }), value;
365
+ });
366
+ return value;
367
+ }
368
+ });
369
+ if (process.env.NODE_ENV === "development") {
370
+ if (props["debug"] === "verbose") {
371
+ console.info(`Animated`, {
372
+ response: res,
373
+ inputStyle: style,
374
+ isExiting
375
+ });
297
376
  }
298
- }), process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("Animated", {
299
- response: res,
300
- inputStyle: style,
301
- isExiting
302
- }), res;
377
+ }
378
+ return res;
303
379
  }
304
380
  };
305
381
  }
306
382
  function getColorInterpolated(currentColor, nextColor, animateToValue) {
307
- const inputRange = [0, 1],
308
- outputRange = [currentColor || nextColor, nextColor];
309
- return animateToValue === 0 && outputRange.reverse(), {
383
+ const inputRange = [0, 1];
384
+ const outputRange = [currentColor ? currentColor : nextColor, nextColor];
385
+ if (animateToValue === 0) {
386
+ outputRange.reverse();
387
+ }
388
+ return {
310
389
  inputRange,
311
390
  outputRange
312
391
  };
313
392
  }
314
393
  function getInterpolated(current, next, postfix = "deg") {
315
- next === current && (current = next - 1e-9);
316
- const inputRange = [current, next],
317
- outputRange = [`${current}${postfix}`, `${next}${postfix}`];
318
- return next < current && (inputRange.reverse(), outputRange.reverse()), {
394
+ if (next === current) {
395
+ current = next - 1e-9;
396
+ }
397
+ const inputRange = [current, next];
398
+ const outputRange = [`${current}${postfix}`, `${next}${postfix}`];
399
+ if (next < current) {
400
+ inputRange.reverse();
401
+ outputRange.reverse();
402
+ }
403
+ return {
319
404
  inputRange,
320
405
  outputRange
321
406
  };
322
407
  }
323
408
  function getAnimationConfig(key, animations, transition, animationState = "default") {
324
- const normalized = normalizeTransition(transition),
325
- shortKey = transformShorthands[key],
326
- propAnimation = normalized.properties[key] ?? normalized.properties[shortKey];
327
- let animationType = null,
328
- extraConf = {};
329
- return typeof propAnimation == "string" ? animationType = propAnimation : propAnimation && typeof propAnimation == "object" ? (animationType = propAnimation.type || getEffectiveAnimation(normalized, animationState), extraConf = propAnimation) : animationType = getEffectiveAnimation(normalized, animationState), normalized.delay && !extraConf.delay && (extraConf = {
330
- ...extraConf,
331
- delay: normalized.delay
332
- }), {
333
- ...(animationType ? animations[animationType] : {}),
409
+ const normalized = normalizeTransition(transition);
410
+ const shortKey = transformShorthands[key];
411
+ const propAnimation = normalized.properties[key] ?? normalized.properties[shortKey];
412
+ let animationType = null;
413
+ let extraConf = {};
414
+ if (typeof propAnimation === "string") {
415
+ animationType = propAnimation;
416
+ } else if (propAnimation && typeof propAnimation === "object") {
417
+ animationType = propAnimation.type || getEffectiveAnimation(normalized, animationState);
418
+ extraConf = propAnimation;
419
+ } else {
420
+ animationType = getEffectiveAnimation(normalized, animationState);
421
+ }
422
+ if (normalized.delay && !extraConf.delay) {
423
+ extraConf = {
424
+ ...extraConf,
425
+ delay: normalized.delay
426
+ };
427
+ }
428
+ const found = animationType ? animations[animationType] : {};
429
+ return {
430
+ ...found,
334
431
  // Apply global spring config overrides (from transition={['bouncy', { stiffness: 1000 }]})
335
432
  ...normalized.config,
336
433
  // Property-specific config takes highest precedence
@@ -343,8 +440,10 @@ const transformShorthands = {
343
440
  translateX: "x",
344
441
  translateY: "y"
345
442
  };
346
- function getValue(input, isColor = !1) {
347
- if (typeof input != "string") return [input];
443
+ function getValue(input, isColor = false) {
444
+ if (typeof input !== "string") {
445
+ return [input];
446
+ }
348
447
  const [_, number, after] = input.match(/([-0-9]+)(deg|%|px)/) ?? [];
349
448
  return [+number, after];
350
449
  }