@tamagui/animations-react-native 2.7.7 → 3.0.0-beta.1093.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.native.cjs +692 -0
- package/dist/cjs/createAnimations.native.js +643 -597
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/cjs/index.cjs +19 -13
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +12 -13
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/polyfill.cjs +2 -2
- package/dist/cjs/polyfill.native.cjs +5 -0
- package/dist/cjs/polyfill.native.js +2 -1
- package/dist/cjs/polyfill.native.js.map +1 -1
- package/dist/cjs/types.cjs +16 -0
- package/dist/cjs/types.native.cjs +18 -0
- package/dist/cjs/types.native.js +20 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/esm/createAnimations.native.js +621 -567
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/dist/esm/index.js +6 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +6 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +2 -2
- package/dist/esm/polyfill.mjs +2 -1
- package/dist/esm/polyfill.mjs.map +1 -1
- package/dist/esm/polyfill.native.js +2 -1
- package/dist/esm/polyfill.native.js.map +1 -1
- package/dist/esm/types.mjs +0 -0
- package/dist/esm/types.native.js +0 -0
- package/package.json +15 -10
- package/src/{createAnimations.tsx → createAnimations.native.tsx} +277 -137
- package/src/index.native.ts +3 -0
- package/src/index.ts +20 -2
- package/src/types.ts +4 -0
- package/types/{createAnimations.d.ts → createAnimations.native.d.ts} +5 -14
- package/types/createAnimations.native.d.ts.map +11 -0
- package/types/index.d.ts +10 -2
- package/types/index.d.ts.map +2 -2
- package/types/index.native.d.ts +4 -0
- package/types/index.native.d.ts.map +11 -0
- package/types/types.d.ts +5 -0
- package/types/types.d.ts.map +11 -0
- package/dist/cjs/createAnimations.cjs +0 -566
- package/dist/esm/createAnimations.mjs +0 -524
- package/dist/esm/createAnimations.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/types/createAnimations.d.ts.map +0 -11
|
@@ -1,603 +1,657 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { easingToBezier, forAnimationState, getTransitionForKey, resolveTransition } from "@tamagui/animation-helpers";
|
|
2
2
|
import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
3
3
|
import { ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
4
|
-
import { useEvent
|
|
4
|
+
import { useEvent } from "@tamagui/web";
|
|
5
|
+
import { useThemeWithState } from "@tamagui/web/internal-runtime";
|
|
5
6
|
import React from "react";
|
|
6
|
-
import { Animated } from "react-native";
|
|
7
|
-
function _type_of(obj) {
|
|
8
|
-
"@swc/helpers - typeof";
|
|
7
|
+
import { Animated, Easing, processColor } from "react-native";
|
|
9
8
|
|
|
10
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
11
|
-
}
|
|
12
9
|
var isFabric = !isWeb && typeof global !== "undefined" && !!global.__nativeFabricUIManager;
|
|
13
|
-
var resolveDynamicValue = function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
var resolveDynamicValue = function(value, isDark) {
|
|
11
|
+
if (value && typeof value === "object" && "dynamic" in value) {
|
|
12
|
+
var dynamicValue = isDark ? value.dynamic.dark : value.dynamic.light;
|
|
13
|
+
return dynamicValue;
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
19
16
|
};
|
|
20
17
|
var animatedStyleKey = {
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
transform: true,
|
|
19
|
+
opacity: true
|
|
23
20
|
};
|
|
24
21
|
var colorStyleKey = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
backgroundColor: true,
|
|
23
|
+
color: true,
|
|
24
|
+
borderColor: true,
|
|
25
|
+
borderLeftColor: true,
|
|
26
|
+
borderRightColor: true,
|
|
27
|
+
borderTopColor: true,
|
|
28
|
+
borderBottomColor: true
|
|
32
29
|
};
|
|
33
30
|
var layoutStyleKey = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
height: true,
|
|
32
|
+
width: true,
|
|
33
|
+
minHeight: true,
|
|
34
|
+
maxHeight: true,
|
|
35
|
+
minWidth: true,
|
|
36
|
+
maxWidth: true
|
|
40
37
|
};
|
|
41
|
-
function hasAnimatedLayoutKey(style, isDark,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
function hasAnimatedLayoutKey(style, isDark, resolved) {
|
|
39
|
+
for (var key in layoutStyleKey) {
|
|
40
|
+
if (!getTransitionForKey(resolved, key)) continue;
|
|
41
|
+
if (typeof resolveDynamicValue(style[key], isDark) === "number") return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
47
44
|
}
|
|
48
45
|
function isAnimatableColor(value) {
|
|
49
|
-
|
|
50
|
-
if (value === "") return false;
|
|
51
|
-
if (value.includes("var(") || value.includes("calc(")) return false;
|
|
52
|
-
return true;
|
|
46
|
+
return typeof value === "string" && processColor(value) != null;
|
|
53
47
|
}
|
|
54
48
|
var costlyToAnimateStyleKey = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
49
|
+
borderRadius: true,
|
|
50
|
+
borderTopLeftRadius: true,
|
|
51
|
+
borderTopRightRadius: true,
|
|
52
|
+
borderBottomLeftRadius: true,
|
|
53
|
+
borderBottomRightRadius: true,
|
|
54
|
+
borderWidth: true,
|
|
55
|
+
borderLeftWidth: true,
|
|
56
|
+
borderRightWidth: true,
|
|
57
|
+
borderTopWidth: true,
|
|
58
|
+
borderBottomWidth: true,
|
|
59
|
+
...colorStyleKey
|
|
66
60
|
};
|
|
67
61
|
var AnimatedView = Animated.View;
|
|
68
62
|
var AnimatedText = Animated.Text;
|
|
69
63
|
function useAnimatedNumber(initial) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
});
|
|
127
|
-
composite1.start(handleFinish);
|
|
128
|
-
state.current.composite = composite1;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
64
|
+
var state = React.useRef(null);
|
|
65
|
+
if (!state.current) {
|
|
66
|
+
state.current = {
|
|
67
|
+
composite: null,
|
|
68
|
+
val: new Animated.Value(initial),
|
|
69
|
+
strategy: { type: "spring" }
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
getInstance() {
|
|
74
|
+
return state.current.val;
|
|
75
|
+
},
|
|
76
|
+
getValue() {
|
|
77
|
+
return state.current.val["_value"];
|
|
78
|
+
},
|
|
79
|
+
stop() {
|
|
80
|
+
var _state_current_composite;
|
|
81
|
+
(_state_current_composite = state.current.composite) === null || _state_current_composite === void 0 ? void 0 : _state_current_composite.stop();
|
|
82
|
+
state.current.composite = null;
|
|
83
|
+
},
|
|
84
|
+
setValue(next) {
|
|
85
|
+
var { type, ...config } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { type: "spring" }, onFinish = arguments.length > 2 ? arguments[2] : void 0;
|
|
86
|
+
var val = state.current.val;
|
|
87
|
+
var handleFinish = onFinish ? function(param) {
|
|
88
|
+
var { finished } = param;
|
|
89
|
+
return finished ? onFinish() : null;
|
|
90
|
+
} : void 0;
|
|
91
|
+
if (type === "direct") {
|
|
92
|
+
var _state_current_composite;
|
|
93
|
+
(_state_current_composite = state.current.composite) === null || _state_current_composite === void 0 ? void 0 : _state_current_composite.stop();
|
|
94
|
+
state.current.composite = null;
|
|
95
|
+
val.setValue(next);
|
|
96
|
+
onFinish === null || onFinish === void 0 ? void 0 : onFinish();
|
|
97
|
+
} else if (type === "spring") {
|
|
98
|
+
var _state_current_composite1;
|
|
99
|
+
(_state_current_composite1 = state.current.composite) === null || _state_current_composite1 === void 0 ? void 0 : _state_current_composite1.stop();
|
|
100
|
+
var composite = Animated.spring(val, {
|
|
101
|
+
...config,
|
|
102
|
+
toValue: next,
|
|
103
|
+
useNativeDriver: isFabric
|
|
104
|
+
});
|
|
105
|
+
composite.start(handleFinish);
|
|
106
|
+
state.current.composite = composite;
|
|
107
|
+
} else {
|
|
108
|
+
var _state_current_composite2;
|
|
109
|
+
(_state_current_composite2 = state.current.composite) === null || _state_current_composite2 === void 0 ? void 0 : _state_current_composite2.stop();
|
|
110
|
+
var composite1 = Animated.timing(val, {
|
|
111
|
+
...config,
|
|
112
|
+
toValue: next,
|
|
113
|
+
useNativeDriver: isFabric
|
|
114
|
+
});
|
|
115
|
+
composite1.start(handleFinish);
|
|
116
|
+
state.current.composite = composite1;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
132
120
|
}
|
|
133
|
-
var useAnimatedNumberReaction = function
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
};
|
|
145
|
-
}, [value, onChange]);
|
|
121
|
+
var useAnimatedNumberReaction = function(param, onValue) {
|
|
122
|
+
var { value } = param;
|
|
123
|
+
var onChange = useEvent(function(current) {
|
|
124
|
+
onValue(current.value);
|
|
125
|
+
});
|
|
126
|
+
React.useEffect(function() {
|
|
127
|
+
var id = value.getInstance().addListener(onChange);
|
|
128
|
+
return function() {
|
|
129
|
+
value.getInstance().removeListener(id);
|
|
130
|
+
};
|
|
131
|
+
}, [value, onChange]);
|
|
146
132
|
};
|
|
147
|
-
var useAnimatedNumberStyle = function
|
|
148
|
-
|
|
133
|
+
var useAnimatedNumberStyle = function(value, getStyle) {
|
|
134
|
+
var instance = value.getInstance();
|
|
135
|
+
var animatedStyle = getStyle(instance);
|
|
136
|
+
var usesAnimatedNode = hasAnimatedNode(animatedStyle);
|
|
137
|
+
var [current, setCurrent] = React.useState(value.getValue());
|
|
138
|
+
React.useEffect(function() {
|
|
139
|
+
if (usesAnimatedNode) return;
|
|
140
|
+
var id = instance.addListener(function(param) {
|
|
141
|
+
var { value: next } = param;
|
|
142
|
+
setCurrent(next);
|
|
143
|
+
});
|
|
144
|
+
return function() {
|
|
145
|
+
instance.removeListener(id);
|
|
146
|
+
};
|
|
147
|
+
}, [instance, usesAnimatedNode]);
|
|
148
|
+
return usesAnimatedNode ? animatedStyle : getStyle(current);
|
|
149
149
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
150
|
+
function hasAnimatedNode(value) {
|
|
151
|
+
if (!value || typeof value !== "object") return false;
|
|
152
|
+
if (typeof value.__getValue === "function") return true;
|
|
153
|
+
if (Array.isArray(value)) return value.some(hasAnimatedNode);
|
|
154
|
+
return Object.values(value).some(hasAnimatedNode);
|
|
155
|
+
}
|
|
156
|
+
var useAnimatedNumbersStyle = function(vals, getStyle) {
|
|
157
|
+
return getStyle(...vals.map(function(v) {
|
|
158
|
+
return v.getInstance();
|
|
159
|
+
}));
|
|
154
160
|
};
|
|
155
161
|
function createAnimations(animations, options) {
|
|
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
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
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
|
-
|
|
162
|
+
var _options_useNativeDriver;
|
|
163
|
+
var nativeDriver = (_options_useNativeDriver = options === null || options === void 0 ? void 0 : options.useNativeDriver) !== null && _options_useNativeDriver !== void 0 ? _options_useNativeDriver : isFabric;
|
|
164
|
+
return {
|
|
165
|
+
inputStyle: "value",
|
|
166
|
+
outputStyle: "inline",
|
|
167
|
+
avoidReRenders: true,
|
|
168
|
+
animations,
|
|
169
|
+
needsCustomComponent: true,
|
|
170
|
+
View: AnimatedView,
|
|
171
|
+
Text: AnimatedText,
|
|
172
|
+
useAnimatedNumber,
|
|
173
|
+
useAnimatedNumberReaction,
|
|
174
|
+
useAnimatedNumberStyle,
|
|
175
|
+
useAnimatedNumbersStyle,
|
|
176
|
+
usePresence,
|
|
177
|
+
ResetPresence,
|
|
178
|
+
useAnimations: function(param) {
|
|
179
|
+
var { props, onTransition, style, componentState, presence, stateRef, styleState, useStyleEmitter } = param;
|
|
180
|
+
var _themeState_name;
|
|
181
|
+
var isDisabled = isWeb && componentState.unmounted === true;
|
|
182
|
+
var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;
|
|
183
|
+
var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];
|
|
184
|
+
var onTransitionRef = React.useRef(onTransition);
|
|
185
|
+
onTransitionRef.current = onTransition;
|
|
186
|
+
var emit = function(phase, cause, finished) {
|
|
187
|
+
var _onTransitionRef_current;
|
|
188
|
+
(_onTransitionRef_current = onTransitionRef.current) === null || _onTransitionRef_current === void 0 ? void 0 : _onTransitionRef_current.call(onTransitionRef, phase === "end" ? {
|
|
189
|
+
phase,
|
|
190
|
+
cause,
|
|
191
|
+
finished
|
|
192
|
+
} : {
|
|
193
|
+
phase,
|
|
194
|
+
cause
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
var _styleState_effectiveTransition;
|
|
198
|
+
var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;
|
|
199
|
+
var [, themeState] = useThemeWithState({});
|
|
200
|
+
var isDark = (themeState === null || themeState === void 0 ? void 0 : themeState.scheme) === "dark" || (themeState === null || themeState === void 0 ? void 0 : (_themeState_name = themeState.name) === null || _themeState_name === void 0 ? void 0 : _themeState_name.startsWith("dark"));
|
|
201
|
+
var animateStyles = React.useRef({});
|
|
202
|
+
var animatedTranforms = React.useRef([]);
|
|
203
|
+
var animationsState = React.useRef(/* @__PURE__ */ new WeakMap());
|
|
204
|
+
var pseudoActiveRef = React.useRef(false);
|
|
205
|
+
var exitCycleIdRef = React.useRef(0);
|
|
206
|
+
var exitCompletedRef = React.useRef(false);
|
|
207
|
+
var wasExitingRef = React.useRef(false);
|
|
208
|
+
var enterStartedRef = React.useRef(false);
|
|
209
|
+
var exitStartedRef = React.useRef(false);
|
|
210
|
+
var updateInFlightRef = React.useRef(false);
|
|
211
|
+
var updateCycleIdRef = React.useRef(0);
|
|
212
|
+
var prevStyleSigRef = React.useRef(null);
|
|
213
|
+
var justStartedExiting = isExiting && !wasExitingRef.current;
|
|
214
|
+
var justStoppedExiting = !isExiting && wasExitingRef.current;
|
|
215
|
+
if (justStartedExiting) {
|
|
216
|
+
exitCycleIdRef.current++;
|
|
217
|
+
exitCompletedRef.current = false;
|
|
218
|
+
}
|
|
219
|
+
if (justStoppedExiting) {
|
|
220
|
+
exitCycleIdRef.current++;
|
|
221
|
+
}
|
|
222
|
+
var isEntering = !!componentState.unmounted;
|
|
223
|
+
var wasEnteringRef = React.useRef(isEntering);
|
|
224
|
+
var justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
225
|
+
React.useEffect(function() {
|
|
226
|
+
wasEnteringRef.current = isEntering;
|
|
227
|
+
});
|
|
228
|
+
var args = [
|
|
229
|
+
JSON.stringify(style),
|
|
230
|
+
JSON.stringify(effectiveTransition),
|
|
231
|
+
componentState,
|
|
232
|
+
isExiting,
|
|
233
|
+
!!onTransition,
|
|
234
|
+
isDark,
|
|
235
|
+
justFinishedEntering
|
|
236
|
+
];
|
|
237
|
+
var res = React.useMemo(function() {
|
|
238
|
+
var runners = [];
|
|
239
|
+
var completions = [];
|
|
240
|
+
var animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
|
|
241
|
+
var resolved = forAnimationState(resolveTransition(effectiveTransition, { animations }), animationState);
|
|
242
|
+
var nonAnimatedStyle = {};
|
|
243
|
+
var useNativeDriverForNode = nativeDriver && !hasAnimatedLayoutKey(style, isDark, resolved);
|
|
244
|
+
var seenAnimateKeys = /* @__PURE__ */ new Set();
|
|
245
|
+
var sawTransform = false;
|
|
246
|
+
var transformCount = 0;
|
|
247
|
+
for (var key in style) {
|
|
248
|
+
var rawVal = style[key];
|
|
249
|
+
var val = resolveDynamicValue(rawVal, isDark);
|
|
250
|
+
if (val === void 0) continue;
|
|
251
|
+
if (isDisabled) {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (animatedStyleKey[key] == null && !costlyToAnimateStyleKey[key] && !layoutStyleKey[key]) {
|
|
255
|
+
nonAnimatedStyle[key] = val;
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
if (key !== "transform" && !getTransitionForKey(resolved, key)) {
|
|
259
|
+
nonAnimatedStyle[key] = val;
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (layoutStyleKey[key] && typeof val !== "number") {
|
|
263
|
+
nonAnimatedStyle[key] = val;
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (colorStyleKey[key] && !isAnimatableColor(val)) {
|
|
267
|
+
nonAnimatedStyle[key] = val;
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
if (key !== "transform") {
|
|
271
|
+
animateStyles.current[key] = update(key, animateStyles.current[key], val);
|
|
272
|
+
seenAnimateKeys.add(key);
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (!val) continue;
|
|
276
|
+
if (typeof val === "string") {
|
|
277
|
+
console.warn(`Warning: Tamagui can't animate string transforms yet!`);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
sawTransform = true;
|
|
281
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
282
|
+
try {
|
|
283
|
+
for (var _iterator = val[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
284
|
+
var transform = _step.value;
|
|
285
|
+
var _animatedTranforms_current_index;
|
|
286
|
+
if (!transform) continue;
|
|
287
|
+
var index = transformCount++;
|
|
288
|
+
var tkey = Object.keys(transform)[0];
|
|
289
|
+
var currentTransform = (_animatedTranforms_current_index = animatedTranforms.current[index]) === null || _animatedTranforms_current_index === void 0 ? void 0 : _animatedTranforms_current_index[tkey];
|
|
290
|
+
animatedTranforms.current[index] = { [tkey]: update(tkey, currentTransform, transform[tkey]) };
|
|
291
|
+
animatedTranforms.current = [...animatedTranforms.current];
|
|
292
|
+
}
|
|
293
|
+
} catch (err) {
|
|
294
|
+
_didIteratorError = true;
|
|
295
|
+
_iteratorError = err;
|
|
296
|
+
} finally {
|
|
297
|
+
try {
|
|
298
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
299
|
+
_iterator.return();
|
|
300
|
+
}
|
|
301
|
+
} finally {
|
|
302
|
+
if (_didIteratorError) {
|
|
303
|
+
throw _iteratorError;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (!isExiting && !isDisabled && !pseudoActiveRef.current) {
|
|
309
|
+
for (var k in animateStyles.current) {
|
|
310
|
+
if (!seenAnimateKeys.has(k)) delete animateStyles.current[k];
|
|
311
|
+
}
|
|
312
|
+
if (!sawTransform) {
|
|
313
|
+
if (animatedTranforms.current.length) animatedTranforms.current = [];
|
|
314
|
+
} else if (animatedTranforms.current.length > transformCount) {
|
|
315
|
+
animatedTranforms.current = animatedTranforms.current.slice(0, transformCount);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
var animatedTransformStyle = animatedTranforms.current.length > 0 ? { transform: animatedTranforms.current.map(function(r) {
|
|
319
|
+
var _animationsState_current_get;
|
|
320
|
+
var key2 = Object.keys(r)[0];
|
|
321
|
+
var val2 = ((_animationsState_current_get = animationsState.current.get(r[key2])) === null || _animationsState_current_get === void 0 ? void 0 : _animationsState_current_get.interpolation) || r[key2];
|
|
322
|
+
return { [key2]: val2 };
|
|
323
|
+
}) } : {};
|
|
324
|
+
var animatedStyle = {
|
|
325
|
+
...Object.fromEntries(Object.entries(animateStyles.current).map(function(param2) {
|
|
326
|
+
var [k2, v] = param2;
|
|
327
|
+
var _animationsState_current_get;
|
|
328
|
+
return [k2, ((_animationsState_current_get = animationsState.current.get(v)) === null || _animationsState_current_get === void 0 ? void 0 : _animationsState_current_get.interpolation) || v];
|
|
329
|
+
})),
|
|
330
|
+
...animatedTransformStyle
|
|
331
|
+
};
|
|
332
|
+
return {
|
|
333
|
+
runners,
|
|
334
|
+
completions,
|
|
335
|
+
style: [nonAnimatedStyle, animatedStyle]
|
|
336
|
+
};
|
|
337
|
+
function update(key2, animated, valIn) {
|
|
338
|
+
var isColorStyleKey = colorStyleKey[key2];
|
|
339
|
+
var [val2, type] = isColorStyleKey ? [0, void 0] : getValue(valIn);
|
|
340
|
+
var animateToValue = val2;
|
|
341
|
+
var value = animated || new Animated.Value(val2);
|
|
342
|
+
var curInterpolation = animationsState.current.get(value);
|
|
343
|
+
var interpolateArgs;
|
|
344
|
+
if (type) {
|
|
345
|
+
var _curInterpolation_current;
|
|
346
|
+
interpolateArgs = getInterpolated((_curInterpolation_current = curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.current) !== null && _curInterpolation_current !== void 0 ? _curInterpolation_current : value["_value"], val2, type);
|
|
347
|
+
animationsState.current.set(value, {
|
|
348
|
+
interpolation: value.interpolate(interpolateArgs),
|
|
349
|
+
current: val2
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
if (isColorStyleKey) {
|
|
353
|
+
animateToValue = (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1;
|
|
354
|
+
interpolateArgs = getColorInterpolated(curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.current, valIn, animateToValue);
|
|
355
|
+
animationsState.current.set(value, {
|
|
356
|
+
current: valIn,
|
|
357
|
+
interpolation: value.interpolate(interpolateArgs),
|
|
358
|
+
animateToValue: (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
if (value) {
|
|
362
|
+
var animationConfig = getAnimationConfig(key2, animations, effectiveTransition, animationState);
|
|
363
|
+
var resolve;
|
|
364
|
+
var promise = new Promise(function(res2) {
|
|
365
|
+
resolve = res2;
|
|
366
|
+
});
|
|
367
|
+
completions.push(promise);
|
|
368
|
+
runners.push(function() {
|
|
369
|
+
value.stopAnimation();
|
|
370
|
+
var { type: type2, delay, ...config } = animationConfig;
|
|
371
|
+
var animation = Animated[type2 || "spring"](value, {
|
|
372
|
+
toValue: animateToValue,
|
|
373
|
+
...config,
|
|
374
|
+
useNativeDriver: useNativeDriverForNode
|
|
375
|
+
});
|
|
376
|
+
var animation2 = delay ? Animated.sequence([Animated.delay(delay), animation]) : animation;
|
|
377
|
+
animation2.start(function(param2) {
|
|
378
|
+
var { finished } = param2;
|
|
379
|
+
if (finished || isExiting) {
|
|
380
|
+
resolve();
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
if (process.env.NODE_ENV === "development") {
|
|
386
|
+
if (props["debug"] === "verbose") {
|
|
387
|
+
console.info(" 💠 animate", key2, `from (${value["_value"]}) to`, valIn, `(${val2})`, "type", type, "interpolate", interpolateArgs);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return value;
|
|
391
|
+
}
|
|
392
|
+
}, args);
|
|
393
|
+
React.useEffect(function() {
|
|
394
|
+
wasExitingRef.current = isExiting;
|
|
395
|
+
});
|
|
396
|
+
useIsomorphicLayoutEffect(function() {
|
|
397
|
+
if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {
|
|
398
|
+
exitStartedRef.current = false;
|
|
399
|
+
emit("end", "exit", false);
|
|
400
|
+
}
|
|
401
|
+
}, [justStoppedExiting]);
|
|
402
|
+
useIsomorphicLayoutEffect(function() {
|
|
403
|
+
res.runners.forEach(function(r) {
|
|
404
|
+
return r();
|
|
405
|
+
});
|
|
406
|
+
var cycleId = exitCycleIdRef.current;
|
|
407
|
+
var cause = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "update";
|
|
408
|
+
if (cause === "exit") {
|
|
409
|
+
if (enterStartedRef.current) {
|
|
410
|
+
enterStartedRef.current = false;
|
|
411
|
+
emit("end", "enter", false);
|
|
412
|
+
}
|
|
413
|
+
if (updateInFlightRef.current) {
|
|
414
|
+
updateInFlightRef.current = false;
|
|
415
|
+
updateCycleIdRef.current++;
|
|
416
|
+
emit("end", "update", false);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
if (cause === "update") {
|
|
420
|
+
var sig = args[0];
|
|
421
|
+
if (prevStyleSigRef.current === null || prevStyleSigRef.current === sig) {
|
|
422
|
+
prevStyleSigRef.current = sig;
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
prevStyleSigRef.current = sig;
|
|
426
|
+
if (res.completions.length === 0) return;
|
|
427
|
+
if (updateInFlightRef.current) {
|
|
428
|
+
emit("end", "update", false);
|
|
429
|
+
}
|
|
430
|
+
updateInFlightRef.current = true;
|
|
431
|
+
var uid = ++updateCycleIdRef.current;
|
|
432
|
+
emit("start", "update");
|
|
433
|
+
Promise.all(res.completions).then(function() {
|
|
434
|
+
if (uid !== updateCycleIdRef.current) return;
|
|
435
|
+
updateInFlightRef.current = false;
|
|
436
|
+
emit("end", "update", true);
|
|
437
|
+
});
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
prevStyleSigRef.current = args[0];
|
|
441
|
+
if (res.completions.length === 0) {
|
|
442
|
+
emit("start", cause);
|
|
443
|
+
emit("end", cause, true);
|
|
444
|
+
if (isExiting && !exitCompletedRef.current) {
|
|
445
|
+
exitCompletedRef.current = true;
|
|
446
|
+
sendExitComplete === null || sendExitComplete === void 0 ? void 0 : sendExitComplete();
|
|
447
|
+
}
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (cause === "enter" && !enterStartedRef.current) {
|
|
451
|
+
enterStartedRef.current = true;
|
|
452
|
+
emit("start", "enter");
|
|
453
|
+
}
|
|
454
|
+
if (cause === "exit" && !exitStartedRef.current) {
|
|
455
|
+
exitStartedRef.current = true;
|
|
456
|
+
emit("start", "exit");
|
|
457
|
+
}
|
|
458
|
+
Promise.all(res.completions).then(function() {
|
|
459
|
+
if (isExiting && cycleId !== exitCycleIdRef.current) return;
|
|
460
|
+
if (isExiting && exitCompletedRef.current) return;
|
|
461
|
+
if (isExiting) {
|
|
462
|
+
if (exitStartedRef.current) {
|
|
463
|
+
exitStartedRef.current = false;
|
|
464
|
+
emit("end", "exit", true);
|
|
465
|
+
}
|
|
466
|
+
exitCompletedRef.current = true;
|
|
467
|
+
sendExitComplete === null || sendExitComplete === void 0 ? void 0 : sendExitComplete();
|
|
468
|
+
} else if (enterStartedRef.current) {
|
|
469
|
+
enterStartedRef.current = false;
|
|
470
|
+
emit("end", "enter", true);
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
}, args);
|
|
474
|
+
useStyleEmitter === null || useStyleEmitter === void 0 ? void 0 : useStyleEmitter(function(nextStyle, emittedTransition, pseudoActive) {
|
|
475
|
+
pseudoActiveRef.current = pseudoActive === true;
|
|
476
|
+
var runners = [];
|
|
477
|
+
var seenAnimateKeys = /* @__PURE__ */ new Set();
|
|
478
|
+
var transformCount = 0;
|
|
479
|
+
var animatedShapeChanged = false;
|
|
480
|
+
var emittedResolved = forAnimationState(resolveTransition(emittedTransition !== null && emittedTransition !== void 0 ? emittedTransition : effectiveTransition, { animations }), "default");
|
|
481
|
+
var useNativeDriverForNode = nativeDriver && !hasAnimatedLayoutKey(nextStyle, isDark, emittedResolved) && !Object.keys(animateStyles.current).some(function(key2) {
|
|
482
|
+
return layoutStyleKey[key2];
|
|
483
|
+
});
|
|
484
|
+
for (var key in nextStyle) {
|
|
485
|
+
var rawVal = nextStyle[key];
|
|
486
|
+
var val = resolveDynamicValue(rawVal, isDark);
|
|
487
|
+
if (val === void 0) continue;
|
|
488
|
+
if (key === "transform" && Array.isArray(val)) {
|
|
489
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
490
|
+
try {
|
|
491
|
+
for (var _iterator = val[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
492
|
+
var transform = _step.value;
|
|
493
|
+
var _animatedTranforms_current_index;
|
|
494
|
+
if (!transform) continue;
|
|
495
|
+
var index = transformCount++;
|
|
496
|
+
var tkey = Object.keys(transform)[0];
|
|
497
|
+
var currentTransform = (_animatedTranforms_current_index = animatedTranforms.current[index]) === null || _animatedTranforms_current_index === void 0 ? void 0 : _animatedTranforms_current_index[tkey];
|
|
498
|
+
if (!currentTransform) animatedShapeChanged = true;
|
|
499
|
+
animatedTranforms.current[index] = { [tkey]: update(tkey, currentTransform, transform[tkey]) };
|
|
500
|
+
}
|
|
501
|
+
} catch (err) {
|
|
502
|
+
_didIteratorError = true;
|
|
503
|
+
_iteratorError = err;
|
|
504
|
+
} finally {
|
|
505
|
+
try {
|
|
506
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
507
|
+
_iterator.return();
|
|
508
|
+
}
|
|
509
|
+
} finally {
|
|
510
|
+
if (_didIteratorError) {
|
|
511
|
+
throw _iteratorError;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
} else if (animatedStyleKey[key] != null || costlyToAnimateStyleKey[key] || layoutStyleKey[key]) {
|
|
516
|
+
if (layoutStyleKey[key] && typeof val !== "number") continue;
|
|
517
|
+
if (colorStyleKey[key] && !isAnimatableColor(val)) continue;
|
|
518
|
+
if (!animateStyles.current[key]) animatedShapeChanged = true;
|
|
519
|
+
animateStyles.current[key] = update(key, animateStyles.current[key], val);
|
|
520
|
+
seenAnimateKeys.add(key);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
for (var key1 in animateStyles.current) {
|
|
524
|
+
if (!seenAnimateKeys.has(key1)) {
|
|
525
|
+
delete animateStyles.current[key1];
|
|
526
|
+
animatedShapeChanged = true;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
if (animatedTranforms.current.length > transformCount) {
|
|
530
|
+
animatedTranforms.current = animatedTranforms.current.slice(0, transformCount);
|
|
531
|
+
animatedShapeChanged = true;
|
|
532
|
+
}
|
|
533
|
+
runners.forEach(function(r) {
|
|
534
|
+
return r();
|
|
535
|
+
});
|
|
536
|
+
if (animatedShapeChanged && stateRef.current.nextState) {
|
|
537
|
+
var _stateRef_current_baseSetStateShallow, _stateRef_current;
|
|
538
|
+
(_stateRef_current_baseSetStateShallow = (_stateRef_current = stateRef.current).baseSetStateShallow) === null || _stateRef_current_baseSetStateShallow === void 0 ? void 0 : _stateRef_current_baseSetStateShallow.call(_stateRef_current, stateRef.current.nextState);
|
|
539
|
+
}
|
|
540
|
+
function update(key2, animated, valIn) {
|
|
541
|
+
var isColor = colorStyleKey[key2];
|
|
542
|
+
var [numVal, type] = isColor ? [0, void 0] : getValue(valIn);
|
|
543
|
+
var animateToValue = numVal;
|
|
544
|
+
var value = animated || new Animated.Value(numVal);
|
|
545
|
+
var curInterpolation = animationsState.current.get(value);
|
|
546
|
+
if (type) {
|
|
547
|
+
var _curInterpolation_current;
|
|
548
|
+
animationsState.current.set(value, {
|
|
549
|
+
interpolation: value.interpolate(getInterpolated((_curInterpolation_current = curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.current) !== null && _curInterpolation_current !== void 0 ? _curInterpolation_current : value["_value"], numVal, type)),
|
|
550
|
+
current: numVal
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
if (isColor) {
|
|
554
|
+
animateToValue = (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1;
|
|
555
|
+
animationsState.current.set(value, {
|
|
556
|
+
current: valIn,
|
|
557
|
+
interpolation: value.interpolate(getColorInterpolated(curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.current, valIn, animateToValue)),
|
|
558
|
+
animateToValue: (curInterpolation === null || curInterpolation === void 0 ? void 0 : curInterpolation.animateToValue) ? 0 : 1
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
var animationConfig = getAnimationConfig(key2, animations, emittedTransition !== null && emittedTransition !== void 0 ? emittedTransition : effectiveTransition, "default");
|
|
562
|
+
runners.push(function() {
|
|
563
|
+
value.stopAnimation();
|
|
564
|
+
var { type: type2, delay, ...config } = animationConfig;
|
|
565
|
+
var anim = Animated[type2 || "spring"](value, {
|
|
566
|
+
toValue: animateToValue,
|
|
567
|
+
...config,
|
|
568
|
+
useNativeDriver: useNativeDriverForNode
|
|
569
|
+
});
|
|
570
|
+
(delay ? Animated.sequence([Animated.delay(delay), anim]) : anim).start();
|
|
571
|
+
});
|
|
572
|
+
return value;
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
if (process.env.NODE_ENV === "development") {
|
|
576
|
+
if (props["debug"] === "verbose") {
|
|
577
|
+
console.info(`Animated`, {
|
|
578
|
+
response: res,
|
|
579
|
+
inputStyle: style,
|
|
580
|
+
isExiting
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
return res;
|
|
585
|
+
}
|
|
586
|
+
};
|
|
528
587
|
}
|
|
529
588
|
function getColorInterpolated(currentColor, nextColor, animateToValue) {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
589
|
+
var inputRange = [0, 1];
|
|
590
|
+
var outputRange = [currentColor ? currentColor : nextColor, nextColor];
|
|
591
|
+
if (animateToValue === 0) {
|
|
592
|
+
outputRange.reverse();
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
inputRange,
|
|
596
|
+
outputRange
|
|
597
|
+
};
|
|
539
598
|
}
|
|
540
599
|
function getInterpolated(current, next) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
600
|
+
var postfix = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "deg";
|
|
601
|
+
if (next === current) {
|
|
602
|
+
current = next - 1e-9;
|
|
603
|
+
}
|
|
604
|
+
var inputRange = [current, next];
|
|
605
|
+
var outputRange = [`${current}${postfix}`, `${next}${postfix}`];
|
|
606
|
+
if (next < current) {
|
|
607
|
+
inputRange.reverse();
|
|
608
|
+
outputRange.reverse();
|
|
609
|
+
}
|
|
610
|
+
return {
|
|
611
|
+
inputRange,
|
|
612
|
+
outputRange
|
|
613
|
+
};
|
|
555
614
|
}
|
|
556
|
-
function
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
var found = animationType ? animations[animationType] : {};
|
|
579
|
-
return {
|
|
580
|
-
...found,
|
|
581
|
-
// Apply global spring config overrides (from transition={['bouncy', { stiffness: 1000 }]})
|
|
582
|
-
...normalized.config,
|
|
583
|
-
// Property-specific config takes highest precedence
|
|
584
|
-
...extraConf
|
|
585
|
-
};
|
|
615
|
+
function entryToRN(entry) {
|
|
616
|
+
var extra = entry.timing.kind === "spring" ? entry.timing.extra : void 0;
|
|
617
|
+
if (entry.timing.kind === "spring") {
|
|
618
|
+
return {
|
|
619
|
+
type: "spring",
|
|
620
|
+
stiffness: entry.timing.stiffness,
|
|
621
|
+
damping: entry.timing.damping,
|
|
622
|
+
mass: entry.timing.mass,
|
|
623
|
+
...typeof (extra === null || extra === void 0 ? void 0 : extra.velocity) === "number" ? { velocity: extra.velocity } : null,
|
|
624
|
+
...typeof (extra === null || extra === void 0 ? void 0 : extra.overshootClamping) === "boolean" ? { overshootClamping: extra.overshootClamping } : null,
|
|
625
|
+
...entry.delayMs ? { delay: entry.delayMs } : null
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
var bezier = easingToBezier(entry.timing.easing);
|
|
629
|
+
return {
|
|
630
|
+
type: "timing",
|
|
631
|
+
duration: entry.timing.durationMs,
|
|
632
|
+
...bezier ? { easing: Easing.bezier(bezier[0], bezier[1], bezier[2], bezier[3]) } : null,
|
|
633
|
+
...entry.delayMs ? { delay: entry.delayMs } : null
|
|
634
|
+
};
|
|
586
635
|
}
|
|
587
|
-
var
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
translateX: "x",
|
|
591
|
-
translateY: "y"
|
|
636
|
+
var snapConfig = {
|
|
637
|
+
type: "timing",
|
|
638
|
+
duration: 0
|
|
592
639
|
};
|
|
640
|
+
function getAnimationConfig(key, animations, transition) {
|
|
641
|
+
var animationState = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "default";
|
|
642
|
+
var resolved = forAnimationState(resolveTransition(transition, { animations }), animationState);
|
|
643
|
+
var entry = getTransitionForKey(resolved, key);
|
|
644
|
+
return entry ? entryToRN(entry) : snapConfig;
|
|
645
|
+
}
|
|
593
646
|
function getValue(input) {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
647
|
+
var isColor = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
648
|
+
if (typeof input !== "string") {
|
|
649
|
+
return [input];
|
|
650
|
+
}
|
|
651
|
+
var _input_match;
|
|
652
|
+
var [_, number, after] = (_input_match = input.match(/(-?(?:\d+\.?\d*|\.\d+))(deg|%|px)?/)) !== null && _input_match !== void 0 ? _input_match : [];
|
|
653
|
+
return [+number, after];
|
|
601
654
|
}
|
|
655
|
+
|
|
602
656
|
export { AnimatedText, AnimatedView, createAnimations, useAnimatedNumber, useAnimatedNumberReaction, useAnimatedNumberStyle, useAnimatedNumbersStyle };
|
|
603
657
|
//# sourceMappingURL=createAnimations.native.js.map
|