@tamagui/animations-motion 2.7.7 → 3.0.0-beta.637.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/createAnimations.cjs +926 -791
- package/dist/cjs/createAnimations.native.cjs +1158 -0
- package/dist/cjs/createAnimations.native.js +1109 -943
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +42 -0
- package/dist/cjs/index.native.js +28 -29
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/polyfill.cjs +3 -2
- package/dist/cjs/polyfill.native.cjs +6 -0
- package/dist/cjs/polyfill.native.js +3 -1
- package/dist/cjs/polyfill.native.js.map +1 -1
- package/dist/esm/createAnimations.mjs +912 -769
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +1096 -923
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/index.native.js +14 -12
- package/dist/esm/index.native.js.map +1 -1
- 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/package.json +5 -5
- package/src/createAnimations.tsx +338 -56
- package/src/index.native.ts +4 -4
- package/types/createAnimations.d.ts.map +2 -2
- package/types/index.native.d.ts +2 -2
- package/types/index.native.d.ts.map +2 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5,36 +6,29 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
12
13
|
};
|
|
13
14
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
21
22
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
30
26
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
28
|
var createAnimations_exports = {};
|
|
35
29
|
__export(createAnimations_exports, {
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
createAnimations: () => createAnimations,
|
|
31
|
+
disableAnimationProps: () => disableAnimationProps
|
|
38
32
|
});
|
|
39
33
|
module.exports = __toCommonJS(createAnimations_exports);
|
|
40
34
|
var import_animation_helpers = require("@tamagui/animation-helpers");
|
|
@@ -45,790 +39,931 @@ var import_react2 = __toESM(require("react"), 1);
|
|
|
45
39
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
46
40
|
const isServer = typeof window === "undefined";
|
|
47
41
|
function useAnimateSSRSafe() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
if (isServer) {
|
|
43
|
+
return [(0, import_react2.useRef)(null), (() => {})];
|
|
44
|
+
}
|
|
45
|
+
return (0, import_react.useAnimate)();
|
|
52
46
|
}
|
|
53
|
-
const
|
|
54
|
-
|
|
47
|
+
const asStyleRecord = (style) => style && typeof style === "object" && !Array.isArray(style) ? style : {};
|
|
48
|
+
function assignInlineStyles(node, styles) {
|
|
49
|
+
for (const key in styles) {
|
|
50
|
+
node.style[key] = (0, import_web.normalizeValueWithProperty)(styles[key], key);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const MotionValueStrategy = /* @__PURE__ */ new WeakMap();
|
|
54
|
+
const PendingMotionOnFinish = /* @__PURE__ */ new WeakMap();
|
|
55
55
|
function settlePendingMotionOnFinish(mv, controls) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
const onFinish = PendingMotionOnFinish.get(mv);
|
|
57
|
+
if (!onFinish) return;
|
|
58
|
+
PendingMotionOnFinish.delete(mv);
|
|
59
|
+
controls.then(() => onFinish()).catch(() => onFinish());
|
|
60
60
|
}
|
|
61
|
-
const PopperPositionAnims = /* @__PURE__ */new WeakMap();
|
|
61
|
+
const PopperPositionAnims = /* @__PURE__ */ new WeakMap();
|
|
62
62
|
function parseTranslate(transform) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
if (!transform || transform === "none") return {
|
|
64
|
+
x: 0,
|
|
65
|
+
y: 0
|
|
66
|
+
};
|
|
67
|
+
try {
|
|
68
|
+
const m = new DOMMatrixReadOnly(transform);
|
|
69
|
+
if (!m.is2D || m.a !== 1 || m.b !== 0 || m.c !== 0 || m.d !== 1) return null;
|
|
70
|
+
return {
|
|
71
|
+
x: m.e,
|
|
72
|
+
y: m.f
|
|
73
|
+
};
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
77
|
}
|
|
78
78
|
function createAnimations(animations) {
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
79
|
+
let isHydratingGlobal;
|
|
80
|
+
const hydratingComponents = /* @__PURE__ */ new Set();
|
|
81
|
+
return {
|
|
82
|
+
View: MotionView,
|
|
83
|
+
Text: MotionText,
|
|
84
|
+
isReactNative: false,
|
|
85
|
+
inputStyle: "css",
|
|
86
|
+
outputStyle: "inline",
|
|
87
|
+
avoidReRenders: true,
|
|
88
|
+
animations,
|
|
89
|
+
usePresence: import_use_presence.usePresence,
|
|
90
|
+
ResetPresence: import_use_presence.ResetPresence,
|
|
91
|
+
onMount() {
|
|
92
|
+
isHydratingGlobal = false;
|
|
93
|
+
hydratingComponents.forEach((cb) => cb());
|
|
94
|
+
},
|
|
95
|
+
useAnimations: (animationProps) => {
|
|
96
|
+
if (isHydratingGlobal === void 0 && !(0, import_web.getConfig)().settings.disableSSR) {
|
|
97
|
+
isHydratingGlobal = true;
|
|
98
|
+
}
|
|
99
|
+
const { props, style, componentState, stateRef, useStyleEmitter, presence, onTransition, styleProps } = animationProps;
|
|
100
|
+
const animationKey = Array.isArray(props.transition) ? props.transition[0] : props.transition;
|
|
101
|
+
const isComponentHydrating = componentState.unmounted === true;
|
|
102
|
+
const isMounting = componentState.unmounted === "should-enter";
|
|
103
|
+
const isEntering = !!componentState.unmounted;
|
|
104
|
+
const isExiting = presence?.[0] === false;
|
|
105
|
+
const sendExitComplete = presence?.[1];
|
|
106
|
+
const refs = (0, import_react2.useRef)(null);
|
|
107
|
+
if (!refs.current) {
|
|
108
|
+
refs.current = {
|
|
109
|
+
isFirstRender: true,
|
|
110
|
+
lastDoAnimate: null,
|
|
111
|
+
lastDontAnimate: null,
|
|
112
|
+
controls: null,
|
|
113
|
+
lastAnimateAt: 0,
|
|
114
|
+
disposed: false,
|
|
115
|
+
wasExiting: false,
|
|
116
|
+
isExiting: false,
|
|
117
|
+
sendExitComplete: void 0,
|
|
118
|
+
animationState: "default",
|
|
119
|
+
frozenExitTarget: null,
|
|
120
|
+
exitCompleteScheduled: false,
|
|
121
|
+
enterCompleteScheduled: false,
|
|
122
|
+
disableAnimation: true,
|
|
123
|
+
wasEntering: false,
|
|
124
|
+
wasDisabled: false,
|
|
125
|
+
onTransition: void 0,
|
|
126
|
+
enterStarted: false,
|
|
127
|
+
exitStarted: false,
|
|
128
|
+
updateInFlight: false,
|
|
129
|
+
updateControls: null,
|
|
130
|
+
wasNoClass: !!styleProps.noClass
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const emit = (phase, cause, finished) => {
|
|
134
|
+
refs.current.onTransition?.(phase === "end" ? {
|
|
135
|
+
phase,
|
|
136
|
+
cause,
|
|
137
|
+
finished
|
|
138
|
+
} : {
|
|
139
|
+
phase,
|
|
140
|
+
cause
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
const justFinishedEntering = refs.current.wasEntering && !isEntering;
|
|
144
|
+
(0, import_react2.useEffect)(() => {
|
|
145
|
+
refs.current.wasEntering = isEntering;
|
|
146
|
+
});
|
|
147
|
+
const animationState = isExiting ? "exit" : isMounting || justFinishedEntering ? "enter" : "default";
|
|
148
|
+
const disableAnimation = isComponentHydrating || isMounting || !animationKey;
|
|
149
|
+
const [scope] = useAnimateSSRSafe();
|
|
150
|
+
refs.current.isExiting = isExiting;
|
|
151
|
+
refs.current.sendExitComplete = sendExitComplete;
|
|
152
|
+
refs.current.animationState = animationState;
|
|
153
|
+
refs.current.disableAnimation = disableAnimation;
|
|
154
|
+
refs.current.onTransition = onTransition;
|
|
155
|
+
const justStartedExiting = isExiting && !refs.current.wasExiting;
|
|
156
|
+
const justStoppedExiting = !isExiting && refs.current.wasExiting;
|
|
157
|
+
if (justStartedExiting || justStoppedExiting) {
|
|
158
|
+
refs.current.frozenExitTarget = null;
|
|
159
|
+
refs.current.exitCompleteScheduled = false;
|
|
160
|
+
refs.current.enterCompleteScheduled = false;
|
|
161
|
+
}
|
|
162
|
+
(0, import_react2.useEffect)(() => {
|
|
163
|
+
refs.current.wasExiting = isExiting;
|
|
164
|
+
});
|
|
165
|
+
(0, import_web.useIsomorphicLayoutEffect)(() => {
|
|
166
|
+
if (justStoppedExiting && refs.current.exitStarted) {
|
|
167
|
+
refs.current.exitStarted = false;
|
|
168
|
+
emit("end", "exit", false);
|
|
169
|
+
}
|
|
170
|
+
}, [justStoppedExiting]);
|
|
171
|
+
const { dontAnimate = {}, doAnimate, animationOptions } = getMotionAnimatedProps(props, style, disableAnimation, animationState);
|
|
172
|
+
const [firstRenderStyle] = (0, import_react2.useState)(style);
|
|
173
|
+
if (refs.current.isFirstRender) {
|
|
174
|
+
refs.current.lastDontAnimate = firstRenderStyle;
|
|
175
|
+
}
|
|
176
|
+
const [isHydrating, setIsHydrating] = (0, import_react2.useState)(isHydratingGlobal);
|
|
177
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
178
|
+
if (isHydratingGlobal) {
|
|
179
|
+
hydratingComponents.add(() => {
|
|
180
|
+
setIsHydrating(false);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return () => {
|
|
184
|
+
refs.current.disposed = true;
|
|
185
|
+
};
|
|
186
|
+
}, []);
|
|
187
|
+
const flushAnimation = ({ doAnimate: doAnimateRaw = {}, animationOptions: passedOptions = {}, dontAnimate: dontAnimate2 }) => {
|
|
188
|
+
let startedControls = null;
|
|
189
|
+
const isCurrentlyExiting = refs.current.isExiting;
|
|
190
|
+
const currentSendExitComplete = refs.current.sendExitComplete;
|
|
191
|
+
const currentAnimationState = refs.current.animationState;
|
|
192
|
+
let doAnimate2 = doAnimateRaw;
|
|
193
|
+
if (isCurrentlyExiting && refs.current.frozenExitTarget) {
|
|
194
|
+
doAnimate2 = refs.current.frozenExitTarget;
|
|
195
|
+
}
|
|
196
|
+
const animationOptions2 = isCurrentlyExiting && currentSendExitComplete ? getAnimationOptions(props.transition ?? null, "exit") : passedOptions;
|
|
197
|
+
try {
|
|
198
|
+
const node = stateRef.current.host;
|
|
199
|
+
if (refs.current.isFirstRender) {
|
|
200
|
+
refs.current.lastDontAnimate = null;
|
|
201
|
+
refs.current.lastDoAnimate = null;
|
|
202
|
+
}
|
|
203
|
+
if (process.env.NODE_ENV === "development") {
|
|
204
|
+
if (props["debug"] && props["debug"] !== "profile") {
|
|
205
|
+
console.groupCollapsed(`[motion] animate (${JSON.stringify(getDiff(refs.current.lastDoAnimate, doAnimate2), null, 2)})`);
|
|
206
|
+
console.info({
|
|
207
|
+
props,
|
|
208
|
+
componentState,
|
|
209
|
+
doAnimate: doAnimate2,
|
|
210
|
+
dontAnimate: dontAnimate2,
|
|
211
|
+
animationOptions: animationOptions2,
|
|
212
|
+
animationProps,
|
|
213
|
+
lastDoAnimate: { ...refs.current.lastDoAnimate },
|
|
214
|
+
lastDontAnimate: { ...refs.current.lastDontAnimate },
|
|
215
|
+
isExiting,
|
|
216
|
+
style,
|
|
217
|
+
node
|
|
218
|
+
});
|
|
219
|
+
console.groupCollapsed(`trace >`);
|
|
220
|
+
console.trace();
|
|
221
|
+
console.groupEnd();
|
|
222
|
+
console.groupEnd();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (!(node instanceof HTMLElement)) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const prevDont = refs.current.lastDontAnimate;
|
|
229
|
+
if (dontAnimate2) {
|
|
230
|
+
if (prevDont) {
|
|
231
|
+
removeRemovedStyles(prevDont, dontAnimate2, node, doAnimate2);
|
|
232
|
+
const changed = getDiff(prevDont, dontAnimate2);
|
|
233
|
+
if (changed) {
|
|
234
|
+
assignInlineStyles(node, changed);
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
assignInlineStyles(node, dontAnimate2);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (doAnimate2) {
|
|
241
|
+
if (prevDont) {
|
|
242
|
+
for (const key in prevDont) {
|
|
243
|
+
if (key in doAnimate2) {
|
|
244
|
+
node.style[key] = (0, import_web.normalizeValueWithProperty)(prevDont[key], key);
|
|
245
|
+
if (refs.current.lastDoAnimate) {
|
|
246
|
+
refs.current.lastDoAnimate[key] = prevDont[key];
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const lastAnimated = refs.current.lastDoAnimate;
|
|
252
|
+
if (lastAnimated) {
|
|
253
|
+
removeRemovedStyles(lastAnimated, doAnimate2, node, dontAnimate2);
|
|
254
|
+
}
|
|
255
|
+
const diff = getDiff(refs.current.lastDoAnimate, doAnimate2);
|
|
256
|
+
if (diff) {
|
|
257
|
+
if (isCurrentlyExiting && !refs.current.frozenExitTarget) {
|
|
258
|
+
refs.current.frozenExitTarget = { ...doAnimate2 };
|
|
259
|
+
}
|
|
260
|
+
const isPopperPosition = node.hasAttribute("data-popper-animate-position");
|
|
261
|
+
let popperHandledTransform = false;
|
|
262
|
+
if (isPopperPosition && !isCurrentlyExiting && typeof diff.transform === "string") {
|
|
263
|
+
const target = parseTranslate(diff.transform);
|
|
264
|
+
if (target) {
|
|
265
|
+
let entry = PopperPositionAnims.get(node);
|
|
266
|
+
if (!entry) {
|
|
267
|
+
let seed = target;
|
|
268
|
+
try {
|
|
269
|
+
seed = parseTranslate(getComputedStyle(node).transform) ?? target;
|
|
270
|
+
} catch {}
|
|
271
|
+
const x = (0, import_react.motionValue)(seed.x);
|
|
272
|
+
const y = (0, import_react.motionValue)(seed.y);
|
|
273
|
+
const write = () => {
|
|
274
|
+
node.style.transform = `translate3d(${x.get()}px, ${y.get()}px, 0)`;
|
|
275
|
+
};
|
|
276
|
+
x.on("change", write);
|
|
277
|
+
y.on("change", write);
|
|
278
|
+
entry = {
|
|
279
|
+
x,
|
|
280
|
+
y,
|
|
281
|
+
stop: null
|
|
282
|
+
};
|
|
283
|
+
PopperPositionAnims.set(node, entry);
|
|
284
|
+
}
|
|
285
|
+
if (!entry.stop) {
|
|
286
|
+
try {
|
|
287
|
+
const live = parseTranslate(getComputedStyle(node).transform);
|
|
288
|
+
if (live) {
|
|
289
|
+
entry.x.jump(live.x);
|
|
290
|
+
entry.y.jump(live.y);
|
|
291
|
+
}
|
|
292
|
+
} catch {}
|
|
293
|
+
}
|
|
294
|
+
for (const anim of node.getAnimations()) {
|
|
295
|
+
try {
|
|
296
|
+
const kf = anim.effect?.getKeyframes?.();
|
|
297
|
+
if (kf?.some((k) => "transform" in k)) {
|
|
298
|
+
anim.cancel();
|
|
299
|
+
}
|
|
300
|
+
} catch {}
|
|
301
|
+
}
|
|
302
|
+
const opts = animationOptions2;
|
|
303
|
+
const positionTransition = opts.transform ?? opts.default ?? animationOptions2;
|
|
304
|
+
const cx = (0, import_react.animate)(entry.x, target.x, positionTransition);
|
|
305
|
+
const cy = (0, import_react.animate)(entry.y, target.y, positionTransition);
|
|
306
|
+
entry.stop = () => {
|
|
307
|
+
cx.stop();
|
|
308
|
+
cy.stop();
|
|
309
|
+
};
|
|
310
|
+
popperHandledTransform = true;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (isCurrentlyExiting) {
|
|
314
|
+
const entry = PopperPositionAnims.get(node);
|
|
315
|
+
if (entry?.stop) {
|
|
316
|
+
entry.stop();
|
|
317
|
+
entry.stop = null;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
let midFlightValues = null;
|
|
321
|
+
if (refs.current.controls) {
|
|
322
|
+
try {
|
|
323
|
+
const computed = getComputedStyle(node);
|
|
324
|
+
midFlightValues = {};
|
|
325
|
+
for (const key in diff) {
|
|
326
|
+
const val = computed[key];
|
|
327
|
+
if (val !== void 0 && val !== "") {
|
|
328
|
+
midFlightValues[key] = val;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
} catch {}
|
|
332
|
+
if (isCurrentlyExiting) {
|
|
333
|
+
refs.current.controls.stop();
|
|
334
|
+
}
|
|
335
|
+
if (midFlightValues) {
|
|
336
|
+
for (const key in midFlightValues) {
|
|
337
|
+
if (key === "transform" && popperHandledTransform) continue;
|
|
338
|
+
node.style[key] = midFlightValues[key];
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
if (isPopperPosition && !popperHandledTransform) {
|
|
342
|
+
const anims = node.getAnimations();
|
|
343
|
+
for (const anim of anims) {
|
|
344
|
+
anim.cancel();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
const fixedDiff = fixTransparentColors(diff, refs.current.lastDoAnimate, doAnimate2);
|
|
349
|
+
let waapiDiff = Object.fromEntries(Object.entries(fixedDiff).map(([key, value]) => [key, Array.isArray(value) ? value.map((item) => (0, import_web.normalizeValueWithProperty)(item, key)) : (0, import_web.normalizeValueWithProperty)(value, key)]));
|
|
350
|
+
if (popperHandledTransform && "transform" in waapiDiff) {
|
|
351
|
+
waapiDiff = { ...waapiDiff };
|
|
352
|
+
delete waapiDiff.transform;
|
|
353
|
+
}
|
|
354
|
+
if ((isPopperPosition || isCurrentlyExiting) && midFlightValues?.transform && waapiDiff.transform) {
|
|
355
|
+
waapiDiff.transform = [midFlightValues.transform, waapiDiff.transform];
|
|
356
|
+
}
|
|
357
|
+
if (Object.keys(waapiDiff).length > 0) {
|
|
358
|
+
startedControls = (0, import_react.animate)(node, waapiDiff, animationOptions2);
|
|
359
|
+
refs.current.controls = startedControls;
|
|
360
|
+
}
|
|
361
|
+
refs.current.lastAnimateAt = Date.now();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
refs.current.lastDontAnimate = dontAnimate2 ? { ...dontAnimate2 } : {};
|
|
365
|
+
refs.current.lastDoAnimate = doAnimate2 ? { ...doAnimate2 } : {};
|
|
366
|
+
} finally {
|
|
367
|
+
if (isCurrentlyExiting && currentSendExitComplete) {
|
|
368
|
+
if (refs.current.enterStarted) {
|
|
369
|
+
refs.current.enterStarted = false;
|
|
370
|
+
emit("end", "enter", false);
|
|
371
|
+
}
|
|
372
|
+
if (startedControls) {
|
|
373
|
+
if (!refs.current.exitStarted) {
|
|
374
|
+
refs.current.exitStarted = true;
|
|
375
|
+
emit("start", "exit");
|
|
376
|
+
}
|
|
377
|
+
refs.current.exitCompleteScheduled = true;
|
|
378
|
+
const complete = (finished) => {
|
|
379
|
+
if (!refs.current.isExiting) return;
|
|
380
|
+
if (refs.current.exitStarted) {
|
|
381
|
+
refs.current.exitStarted = false;
|
|
382
|
+
emit("end", "exit", finished);
|
|
383
|
+
}
|
|
384
|
+
currentSendExitComplete();
|
|
385
|
+
};
|
|
386
|
+
startedControls.finished.then(() => complete(true)).catch(() => complete(false));
|
|
387
|
+
} else if (!refs.current.exitCompleteScheduled) {
|
|
388
|
+
emit("start", "exit");
|
|
389
|
+
emit("end", "exit", true);
|
|
390
|
+
currentSendExitComplete();
|
|
391
|
+
}
|
|
392
|
+
} else if (currentAnimationState === "enter") {
|
|
393
|
+
if (startedControls) {
|
|
394
|
+
if (!refs.current.enterStarted) {
|
|
395
|
+
refs.current.enterStarted = true;
|
|
396
|
+
emit("start", "enter");
|
|
397
|
+
}
|
|
398
|
+
refs.current.enterCompleteScheduled = true;
|
|
399
|
+
const complete = (finished) => {
|
|
400
|
+
if (refs.current.disposed || refs.current.animationState !== "enter") return;
|
|
401
|
+
if (refs.current.enterStarted) {
|
|
402
|
+
refs.current.enterStarted = false;
|
|
403
|
+
emit("end", "enter", finished);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
startedControls.finished.then(() => complete(true)).catch(() => complete(false));
|
|
407
|
+
} else if (!refs.current.enterCompleteScheduled && !refs.current.disableAnimation) {
|
|
408
|
+
emit("start", "enter");
|
|
409
|
+
emit("end", "enter", true);
|
|
410
|
+
}
|
|
411
|
+
} else if (startedControls) {
|
|
412
|
+
const controls = startedControls;
|
|
413
|
+
if (refs.current.updateInFlight) {
|
|
414
|
+
emit("end", "update", false);
|
|
415
|
+
}
|
|
416
|
+
refs.current.updateInFlight = true;
|
|
417
|
+
refs.current.updateControls = controls;
|
|
418
|
+
emit("start", "update");
|
|
419
|
+
const settle = (finished) => {
|
|
420
|
+
if (refs.current.updateControls !== controls) return;
|
|
421
|
+
refs.current.updateInFlight = false;
|
|
422
|
+
refs.current.updateControls = null;
|
|
423
|
+
emit("end", "update", finished);
|
|
424
|
+
};
|
|
425
|
+
controls.finished.then(() => settle(true)).catch(() => settle(false));
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
useStyleEmitter?.((nextStyle, effectiveTransition) => {
|
|
430
|
+
const animationProps2 = getMotionAnimatedProps(props, nextStyle, disableAnimation, refs.current.animationState, effectiveTransition);
|
|
431
|
+
flushAnimation(animationProps2);
|
|
432
|
+
});
|
|
433
|
+
(0, import_web.useIsomorphicLayoutEffect)(() => {
|
|
434
|
+
if (refs.current.isFirstRender) {
|
|
435
|
+
refs.current.isFirstRender = false;
|
|
436
|
+
refs.current.wasDisabled = disableAnimation;
|
|
437
|
+
if (isHydrating) {
|
|
438
|
+
if (doAnimate && Object.keys(doAnimate).length > 0) {
|
|
439
|
+
refs.current.lastDoAnimate = { ...doAnimate };
|
|
440
|
+
} else {
|
|
441
|
+
refs.current.lastDoAnimate = dontAnimate ? { ...dontAnimate } : {};
|
|
442
|
+
}
|
|
443
|
+
refs.current.lastDontAnimate = dontAnimate ? { ...dontAnimate } : {};
|
|
444
|
+
refs.current.lastAnimateAt = Date.now();
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
refs.current.lastDontAnimate = dontAnimate ? { ...dontAnimate } : {};
|
|
448
|
+
refs.current.lastDoAnimate = doAnimate ? { ...doAnimate } : {};
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
const justEnabled = refs.current.wasDisabled && !disableAnimation;
|
|
452
|
+
refs.current.wasDisabled = disableAnimation;
|
|
453
|
+
const justStrippedClasses = !refs.current.wasNoClass && !!styleProps.noClass;
|
|
454
|
+
refs.current.wasNoClass = !!styleProps.noClass;
|
|
455
|
+
if ((justEnabled || justStrippedClasses) && animationState !== "enter") {
|
|
456
|
+
const node = stateRef.current.host;
|
|
457
|
+
if (node instanceof HTMLElement) {
|
|
458
|
+
if (dontAnimate) assignInlineStyles(node, dontAnimate);
|
|
459
|
+
if (doAnimate) assignInlineStyles(node, doAnimate);
|
|
460
|
+
const entry = PopperPositionAnims.get(node);
|
|
461
|
+
if (entry) {
|
|
462
|
+
const target = parseTranslate(doAnimate?.transform ?? dontAnimate?.transform);
|
|
463
|
+
if (target) {
|
|
464
|
+
entry.stop?.();
|
|
465
|
+
entry.stop = null;
|
|
466
|
+
entry.x.jump(target.x);
|
|
467
|
+
entry.y.jump(target.y);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
refs.current.lastDontAnimate = dontAnimate ? { ...dontAnimate } : {};
|
|
472
|
+
refs.current.lastDoAnimate = doAnimate ? { ...doAnimate } : {};
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
flushAnimation({
|
|
476
|
+
doAnimate,
|
|
477
|
+
dontAnimate,
|
|
478
|
+
animationOptions
|
|
479
|
+
});
|
|
480
|
+
}, [
|
|
481
|
+
style,
|
|
482
|
+
isExiting,
|
|
483
|
+
disableAnimation,
|
|
484
|
+
styleProps.noClass
|
|
485
|
+
]);
|
|
486
|
+
if (process.env.NODE_ENV === "development") {
|
|
487
|
+
if (props["debug"] && props["debug"] !== "profile") {
|
|
488
|
+
console.groupCollapsed(`[motion] render`);
|
|
489
|
+
console.info({
|
|
490
|
+
style,
|
|
491
|
+
doAnimate,
|
|
492
|
+
dontAnimate,
|
|
493
|
+
scope,
|
|
494
|
+
animationOptions,
|
|
495
|
+
isExiting,
|
|
496
|
+
isFirstRender: refs.current.isFirstRender,
|
|
497
|
+
animationProps
|
|
498
|
+
});
|
|
499
|
+
console.groupEnd();
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return {
|
|
503
|
+
style: firstRenderStyle,
|
|
504
|
+
ref: scope,
|
|
505
|
+
render: "div"
|
|
506
|
+
};
|
|
507
|
+
},
|
|
508
|
+
useAnimatedNumber(initial) {
|
|
509
|
+
const motionValue2 = (0, import_react.useMotionValue)(initial);
|
|
510
|
+
return import_react2.default.useMemo(() => ({
|
|
511
|
+
getInstance() {
|
|
512
|
+
return motionValue2;
|
|
513
|
+
},
|
|
514
|
+
getValue() {
|
|
515
|
+
return motionValue2.get();
|
|
516
|
+
},
|
|
517
|
+
setValue(next, config = { type: "spring" }, onFinish) {
|
|
518
|
+
if (config.type === "direct") {
|
|
519
|
+
MotionValueStrategy.set(motionValue2, { type: "direct" });
|
|
520
|
+
motionValue2.set(next);
|
|
521
|
+
onFinish?.();
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
MotionValueStrategy.set(motionValue2, config);
|
|
525
|
+
if (onFinish) {
|
|
526
|
+
const prior = PendingMotionOnFinish.get(motionValue2);
|
|
527
|
+
if (prior) {
|
|
528
|
+
PendingMotionOnFinish.delete(motionValue2);
|
|
529
|
+
prior();
|
|
530
|
+
}
|
|
531
|
+
PendingMotionOnFinish.set(motionValue2, onFinish);
|
|
532
|
+
}
|
|
533
|
+
motionValue2.set(next);
|
|
534
|
+
},
|
|
535
|
+
stop() {
|
|
536
|
+
motionValue2.stop();
|
|
537
|
+
}
|
|
538
|
+
}), [motionValue2]);
|
|
539
|
+
},
|
|
540
|
+
useAnimatedNumberReaction({ value }, onValue) {
|
|
541
|
+
const instance = value.getInstance();
|
|
542
|
+
(0, import_react.useMotionValueEvent)(instance, "change", onValue);
|
|
543
|
+
},
|
|
544
|
+
useAnimatedNumberStyle(val, getStyleProp) {
|
|
545
|
+
const motionValue2 = val.getInstance();
|
|
546
|
+
const getStyleRef = (0, import_react2.useRef)(getStyleProp);
|
|
547
|
+
getStyleRef.current = getStyleProp;
|
|
548
|
+
return (0, import_react2.useMemo)(() => {
|
|
549
|
+
return {
|
|
550
|
+
getStyle: (cur) => {
|
|
551
|
+
return getStyleRef.current(cur);
|
|
552
|
+
},
|
|
553
|
+
motionValue: motionValue2
|
|
554
|
+
};
|
|
555
|
+
}, []);
|
|
556
|
+
},
|
|
557
|
+
useAnimatedNumbersStyle(vals, getStyleProp) {
|
|
558
|
+
const motionValues = vals.map((v) => v.getInstance());
|
|
559
|
+
const getStyleRef = (0, import_react2.useRef)(getStyleProp);
|
|
560
|
+
getStyleRef.current = getStyleProp;
|
|
561
|
+
return (0, import_react2.useMemo)(() => {
|
|
562
|
+
return {
|
|
563
|
+
getStyle: (...currentValues) => getStyleRef.current(...currentValues),
|
|
564
|
+
motionValues
|
|
565
|
+
};
|
|
566
|
+
}, []);
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
function getMotionAnimatedProps(props, style, disable, animationState = "default", transitionOverride) {
|
|
570
|
+
if (disable) {
|
|
571
|
+
return { dontAnimate: style };
|
|
572
|
+
}
|
|
573
|
+
const animationOptions = getAnimationOptions(transitionOverride ?? props.transition ?? null, animationState);
|
|
574
|
+
let dontAnimate;
|
|
575
|
+
let doAnimate;
|
|
576
|
+
const animateOnly = props.animateOnly;
|
|
577
|
+
for (const key in style) {
|
|
578
|
+
const value = style[key];
|
|
579
|
+
if (disableAnimationProps.has(key) || animateOnly && !animateOnly.includes(key)) {
|
|
580
|
+
dontAnimate ||= {};
|
|
581
|
+
dontAnimate[key] = value;
|
|
582
|
+
} else {
|
|
583
|
+
doAnimate ||= {};
|
|
584
|
+
doAnimate[key] = value;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return {
|
|
588
|
+
dontAnimate,
|
|
589
|
+
doAnimate,
|
|
590
|
+
animationOptions
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
function getAnimationOptions(transitionProp, animationState = "default") {
|
|
594
|
+
const normalized = (0, import_animation_helpers.normalizeTransition)(transitionProp);
|
|
595
|
+
let effectiveKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);
|
|
596
|
+
if (!effectiveKey && animationState === "default") {
|
|
597
|
+
effectiveKey = normalized.enter || normalized.exit || null;
|
|
598
|
+
}
|
|
599
|
+
const globalConfigOverride = normalized.config ? { ...normalized.config } : void 0;
|
|
600
|
+
if (!effectiveKey && Object.keys(normalized.properties).length === 0 && !globalConfigOverride) {
|
|
601
|
+
return {};
|
|
602
|
+
}
|
|
603
|
+
const defaultConfig = effectiveKey ? withInferredType(animations[effectiveKey]) : null;
|
|
604
|
+
const delay = normalized.delay;
|
|
605
|
+
const result = {};
|
|
606
|
+
if (defaultConfig) {
|
|
607
|
+
Object.assign(result, defaultConfig);
|
|
608
|
+
}
|
|
609
|
+
if (globalConfigOverride) {
|
|
610
|
+
Object.assign(result, globalConfigOverride);
|
|
611
|
+
if (result.type === void 0 && result.duration !== void 0 && result.damping === void 0 && result.stiffness === void 0 && result.mass === void 0) {
|
|
612
|
+
result.type = "tween";
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
if (delay) {
|
|
616
|
+
result.delay = delay;
|
|
617
|
+
}
|
|
618
|
+
if (defaultConfig || globalConfigOverride || delay) {
|
|
619
|
+
result.default = {
|
|
620
|
+
...defaultConfig,
|
|
621
|
+
...globalConfigOverride,
|
|
622
|
+
...delay ? { delay } : null
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
for (const [propName, animationNameOrConfig] of Object.entries(normalized.properties)) {
|
|
626
|
+
if (typeof animationNameOrConfig === "string") {
|
|
627
|
+
result[propName] = withInferredType(animations[animationNameOrConfig]);
|
|
628
|
+
} else if (animationNameOrConfig && typeof animationNameOrConfig === "object") {
|
|
629
|
+
const baseConfig = animationNameOrConfig.type ? withInferredType(animations[animationNameOrConfig.type]) : defaultConfig;
|
|
630
|
+
result[propName] = {
|
|
631
|
+
...baseConfig,
|
|
632
|
+
...animationNameOrConfig
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
convertMsToS(result);
|
|
637
|
+
convertMsToS(result.default);
|
|
638
|
+
for (const key in result) {
|
|
639
|
+
if (key !== "default" && typeof result[key] === "object") {
|
|
640
|
+
convertMsToS(result[key]);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return result;
|
|
644
|
+
}
|
|
623
645
|
}
|
|
624
646
|
function withInferredType(config) {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
...config
|
|
634
|
-
};
|
|
647
|
+
if (!config) {
|
|
648
|
+
return { type: "spring" };
|
|
649
|
+
}
|
|
650
|
+
const isTimingBased = config.duration !== void 0 && config.damping === void 0 && config.stiffness === void 0 && config.mass === void 0;
|
|
651
|
+
return {
|
|
652
|
+
type: isTimingBased ? "tween" : "spring",
|
|
653
|
+
...config
|
|
654
|
+
};
|
|
635
655
|
}
|
|
636
656
|
function convertMsToS(config) {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
657
|
+
if (!config) return;
|
|
658
|
+
if (typeof config.delay === "number") config.delay = config.delay / 1e3;
|
|
659
|
+
if (typeof config.duration === "number") {
|
|
660
|
+
const isTimingBased = config.type === "tween" || config.type === void 0 && config.damping === void 0 && config.stiffness === void 0 && config.mass === void 0;
|
|
661
|
+
if (isTimingBased) {
|
|
662
|
+
config.duration = config.duration / 1e3;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
645
665
|
}
|
|
646
666
|
function removeRemovedStyles(prev, next, node, dontClearIfIn) {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
667
|
+
for (const key in prev) {
|
|
668
|
+
if (!(key in next)) {
|
|
669
|
+
if (dontClearIfIn && key in dontClearIfIn) {
|
|
670
|
+
continue;
|
|
671
|
+
}
|
|
672
|
+
node.style[key] = "";
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
const disableAnimationProps = /* @__PURE__ */ new Set([
|
|
677
|
+
"alignContent",
|
|
678
|
+
"alignItems",
|
|
679
|
+
"boxSizing",
|
|
680
|
+
"contain",
|
|
681
|
+
"containerType",
|
|
682
|
+
"display",
|
|
683
|
+
"flexBasis",
|
|
684
|
+
"flexDirection",
|
|
685
|
+
"fontFamily",
|
|
686
|
+
"justifyContent",
|
|
687
|
+
"overflow",
|
|
688
|
+
"overflowX",
|
|
689
|
+
"overflowY",
|
|
690
|
+
"pointerEvents",
|
|
691
|
+
"position",
|
|
692
|
+
"textWrap",
|
|
693
|
+
"userSelect"
|
|
694
|
+
]);
|
|
695
|
+
function motionPropsEqual(a, b) {
|
|
696
|
+
for (const key in a) {
|
|
697
|
+
if (!(key in b)) return false;
|
|
698
|
+
}
|
|
699
|
+
for (const key in b) {
|
|
700
|
+
if (key === "children") continue;
|
|
701
|
+
const av = a[key];
|
|
702
|
+
const bv = b[key];
|
|
703
|
+
if (typeof bv === "function" && typeof av === "function") continue;
|
|
704
|
+
if (!Object.is(av, bv)) return false;
|
|
705
|
+
}
|
|
706
|
+
return true;
|
|
707
|
+
}
|
|
708
|
+
function motionStylesEqual(a, b) {
|
|
709
|
+
if (a.length !== b.length) return false;
|
|
710
|
+
for (let i = 0; i < a.length; i++) {
|
|
711
|
+
const sa = a[i];
|
|
712
|
+
const sb = b[i];
|
|
713
|
+
if (sa === sb) continue;
|
|
714
|
+
if (!sa || !sb) return false;
|
|
715
|
+
let aCount = 0;
|
|
716
|
+
for (const key in sa) {
|
|
717
|
+
aCount++;
|
|
718
|
+
if (!Object.is(sa[key], sb[key])) return false;
|
|
719
|
+
}
|
|
720
|
+
let bCount = 0;
|
|
721
|
+
for (const _key in sb) {
|
|
722
|
+
bCount++;
|
|
723
|
+
}
|
|
724
|
+
if (aCount !== bCount) return false;
|
|
725
|
+
}
|
|
726
|
+
return true;
|
|
655
727
|
}
|
|
656
|
-
const disableAnimationProps = /* @__PURE__ */new Set(["alignContent", "alignItems", "boxSizing", "contain", "containerType", "display", "flexBasis", "flexDirection", "fontFamily", "justifyContent", "overflow", "overflowX", "overflowY", "pointerEvents", "position", "textWrap", "userSelect"]);
|
|
657
728
|
const MotionView = createMotionView("div");
|
|
658
729
|
const MotionText = createMotionView("span");
|
|
730
|
+
const transformAliases = {
|
|
731
|
+
x: "translateX",
|
|
732
|
+
y: "translateY",
|
|
733
|
+
scale: "scale",
|
|
734
|
+
scaleX: "scaleX",
|
|
735
|
+
scaleY: "scaleY",
|
|
736
|
+
rotate: "rotate",
|
|
737
|
+
rotateX: "rotateX",
|
|
738
|
+
rotateY: "rotateY",
|
|
739
|
+
rotateZ: "rotateZ",
|
|
740
|
+
skewX: "skewX",
|
|
741
|
+
skewY: "skewY"
|
|
742
|
+
};
|
|
743
|
+
function compileAnimatedStyle(initialSource, initialResolved) {
|
|
744
|
+
const shorthands = (0, import_web.getConfig)().shorthands;
|
|
745
|
+
const entries = Object.keys(initialSource).map((source) => ({
|
|
746
|
+
source,
|
|
747
|
+
target: shorthands?.[source] ?? source,
|
|
748
|
+
tokenValue: typeof initialSource[source] === "string" && initialResolved[shorthands?.[source] ?? source] !== initialSource[source] ? initialResolved[shorthands?.[source] ?? source] : void 0
|
|
749
|
+
}));
|
|
750
|
+
return (sourceStyle) => {
|
|
751
|
+
const resolved = {};
|
|
752
|
+
const transforms = [];
|
|
753
|
+
for (const entry of entries) {
|
|
754
|
+
const value = sourceStyle[entry.source];
|
|
755
|
+
if (value === void 0) continue;
|
|
756
|
+
if (entry.source === "transform" && Array.isArray(value)) {
|
|
757
|
+
resolved.transform = (0, import_web.transformsToString)(value);
|
|
758
|
+
} else if (entry.source in transformAliases) {
|
|
759
|
+
transforms.push({ [transformAliases[entry.source]]: value });
|
|
760
|
+
} else {
|
|
761
|
+
resolved[entry.target] = entry.tokenValue ?? (0, import_web.normalizeValueWithProperty)(value, entry.target);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
if (transforms.length) resolved.transform = (0, import_web.transformsToString)(transforms);
|
|
765
|
+
return resolved;
|
|
766
|
+
};
|
|
767
|
+
}
|
|
659
768
|
function createMotionView(defaultTag) {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
769
|
+
const isText = defaultTag === "span";
|
|
770
|
+
const Component = (0, import_web.createRefComponent)((propsIn, ref) => {
|
|
771
|
+
const { forwardedRef, animation, render = defaultTag, style, ...propsRest } = propsIn;
|
|
772
|
+
const [scope, animate] = useAnimateSSRSafe();
|
|
773
|
+
const hostRef = (0, import_react2.useRef)(null);
|
|
774
|
+
const seededNode = (0, import_react2.useRef)(null);
|
|
775
|
+
const seededInCurrentFrame = (0, import_react2.useRef)(false);
|
|
776
|
+
const queuedAnimationFrames = (0, import_react2.useRef)(/* @__PURE__ */ new WeakMap());
|
|
777
|
+
const composedRefs = (0, import_web.useComposedRefs)(forwardedRef, ref, hostRef, scope);
|
|
778
|
+
const stateRef = (0, import_react2.useRef)(null);
|
|
779
|
+
if (!stateRef.current) {
|
|
780
|
+
stateRef.current = { get host() {
|
|
781
|
+
return hostRef.current;
|
|
782
|
+
} };
|
|
783
|
+
}
|
|
784
|
+
const [_, state] = (0, import_web.useThemeWithState)({});
|
|
785
|
+
const styles = Array.isArray(style) ? style : [style];
|
|
786
|
+
const [animatedStyle, nonAnimatedStyles] = (() => {
|
|
787
|
+
let animatedStyle2;
|
|
788
|
+
const nonAnimatedStyles2 = [];
|
|
789
|
+
for (const style2 of styles) {
|
|
790
|
+
if (style2.getStyle) {
|
|
791
|
+
animatedStyle2 = style2;
|
|
792
|
+
} else {
|
|
793
|
+
nonAnimatedStyles2.push(style2);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return [animatedStyle2, nonAnimatedStyles2];
|
|
797
|
+
})();
|
|
798
|
+
function getProps(props2) {
|
|
799
|
+
if (process.env.NODE_ENV === "development" && propsIn.debug === "profile" && typeof performance !== "undefined") {
|
|
800
|
+
performance.mark("tamagui-motion-style-split");
|
|
801
|
+
}
|
|
802
|
+
const out = (0, import_web.getSplitStyles)(props2, isText ? import_web.Text.staticConfig : import_web.View.staticConfig, state?.theme, state?.name, { unmounted: false }, {
|
|
803
|
+
isAnimated: false,
|
|
804
|
+
noClass: true,
|
|
805
|
+
resolveValues: "auto"
|
|
806
|
+
});
|
|
807
|
+
if (!out) {
|
|
808
|
+
return {};
|
|
809
|
+
}
|
|
810
|
+
if (out.viewProps.style) {
|
|
811
|
+
(0, import_web.fixStyles)(out.viewProps.style);
|
|
812
|
+
(0, import_web.styleToCSS)(out.viewProps.style);
|
|
813
|
+
}
|
|
814
|
+
return out.viewProps;
|
|
815
|
+
}
|
|
816
|
+
const resolvedAnimatedStyle = (0, import_react2.useMemo)(() => {
|
|
817
|
+
if (!animatedStyle) return null;
|
|
818
|
+
const currentValues = animatedStyle.motionValues ? animatedStyle.motionValues.map((value) => value.get()) : animatedStyle.motionValue ? [animatedStyle.motionValue.get()] : [];
|
|
819
|
+
const initialSource = animatedStyle.getStyle(...currentValues);
|
|
820
|
+
const initialResolved = asStyleRecord(getProps({ style: initialSource }).style);
|
|
821
|
+
return {
|
|
822
|
+
initial: initialResolved,
|
|
823
|
+
resolve: compileAnimatedStyle(initialSource, initialResolved)
|
|
824
|
+
};
|
|
825
|
+
}, [
|
|
826
|
+
animatedStyle,
|
|
827
|
+
state?.theme,
|
|
828
|
+
state?.name
|
|
829
|
+
]);
|
|
830
|
+
const memoRef = (0, import_react2.useRef)(null);
|
|
831
|
+
let props;
|
|
832
|
+
const cached = memoRef.current;
|
|
833
|
+
if (cached && cached.theme === state?.theme && cached.themeName === state?.name && motionStylesEqual(cached.styles, nonAnimatedStyles) && motionPropsEqual(cached.propsRest, propsRest)) {
|
|
834
|
+
props = { ...cached.result };
|
|
835
|
+
for (const key in propsRest) {
|
|
836
|
+
const val = propsRest[key];
|
|
837
|
+
if (key === "children" || typeof val === "function") {
|
|
838
|
+
props[key] = val;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
} else {
|
|
842
|
+
props = getProps({
|
|
843
|
+
...propsRest,
|
|
844
|
+
style: nonAnimatedStyles
|
|
845
|
+
});
|
|
846
|
+
memoRef.current = {
|
|
847
|
+
propsRest,
|
|
848
|
+
styles: nonAnimatedStyles,
|
|
849
|
+
theme: state?.theme,
|
|
850
|
+
themeName: state?.name,
|
|
851
|
+
result: props
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
if (resolvedAnimatedStyle) {
|
|
855
|
+
props = {
|
|
856
|
+
...props,
|
|
857
|
+
style: {
|
|
858
|
+
...asStyleRecord(props.style),
|
|
859
|
+
...resolvedAnimatedStyle.initial
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
const Element = render || "div";
|
|
864
|
+
const transformedProps = import_web.hooks.usePropsTransform?.(render, props, stateRef, false);
|
|
865
|
+
(0, import_web.useIsomorphicLayoutEffect)(() => {
|
|
866
|
+
if (!animatedStyle) return;
|
|
867
|
+
const node = hostRef.current;
|
|
868
|
+
if (node instanceof HTMLElement && seededNode.current !== node) {
|
|
869
|
+
const currentStyle = animatedStyle.motionValues ? animatedStyle.getStyle(...animatedStyle.motionValues.map((value) => value.get())) : animatedStyle.motionValue ? animatedStyle.getStyle(animatedStyle.motionValue.get()) : null;
|
|
870
|
+
const webStyle = currentStyle && resolvedAnimatedStyle?.resolve(currentStyle);
|
|
871
|
+
if (webStyle) {
|
|
872
|
+
assignInlineStyles(node, webStyle);
|
|
873
|
+
seededNode.current = node;
|
|
874
|
+
seededInCurrentFrame.current = true;
|
|
875
|
+
requestAnimationFrame(() => {
|
|
876
|
+
if (seededNode.current === node) seededInCurrentFrame.current = false;
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
const toTransition = (animationConfig) => animationConfig?.type === "timing" ? {
|
|
881
|
+
type: "tween",
|
|
882
|
+
duration: (animationConfig.duration || 0) / 1e3
|
|
883
|
+
} : animationConfig?.type === "direct" ? {
|
|
884
|
+
type: "tween",
|
|
885
|
+
duration: 0
|
|
886
|
+
} : {
|
|
887
|
+
type: "spring",
|
|
888
|
+
...animationConfig
|
|
889
|
+
};
|
|
890
|
+
const animateNodeTo = (nextStyle, transition, motionValue3) => {
|
|
891
|
+
if (!(node instanceof HTMLElement) || hostRef.current !== node) return;
|
|
892
|
+
const webStyle = resolvedAnimatedStyle?.resolve(nextStyle);
|
|
893
|
+
if (!webStyle) return;
|
|
894
|
+
settlePendingMotionOnFinish(motionValue3, animate(node, webStyle, transition));
|
|
895
|
+
};
|
|
896
|
+
const animateChangedValue = (nextStyle, transition, motionValue3) => {
|
|
897
|
+
if (seededInCurrentFrame.current && seededNode.current === node) {
|
|
898
|
+
const queuedFrame = queuedAnimationFrames.current.get(motionValue3);
|
|
899
|
+
if (queuedFrame !== void 0) cancelAnimationFrame(queuedFrame);
|
|
900
|
+
const frame = requestAnimationFrame(() => {
|
|
901
|
+
if (queuedAnimationFrames.current.get(motionValue3) !== frame) return;
|
|
902
|
+
queuedAnimationFrames.current.delete(motionValue3);
|
|
903
|
+
if (hostRef.current === node) {
|
|
904
|
+
animateNodeTo(nextStyle, transition, motionValue3);
|
|
905
|
+
} else {
|
|
906
|
+
const onFinish = PendingMotionOnFinish.get(motionValue3);
|
|
907
|
+
PendingMotionOnFinish.delete(motionValue3);
|
|
908
|
+
onFinish?.();
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
queuedAnimationFrames.current.set(motionValue3, frame);
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
animateNodeTo(nextStyle, transition, motionValue3);
|
|
915
|
+
};
|
|
916
|
+
if (animatedStyle.motionValues) {
|
|
917
|
+
const mvs = animatedStyle.motionValues;
|
|
918
|
+
const styleForAll = () => animatedStyle.getStyle(...mvs.map((value) => value.get()));
|
|
919
|
+
const unsubs = mvs.map((mv) => mv.on("change", () => animateChangedValue(styleForAll(), toTransition(MotionValueStrategy.get(mv)), mv)));
|
|
920
|
+
return () => unsubs.forEach((fn) => fn());
|
|
921
|
+
}
|
|
922
|
+
const motionValue2 = animatedStyle.motionValue;
|
|
923
|
+
if (!motionValue2) return;
|
|
924
|
+
return motionValue2.on("change", (value) => animateChangedValue(animatedStyle.getStyle(value), toTransition(MotionValueStrategy.get(motionValue2)), motionValue2));
|
|
925
|
+
}, [animatedStyle, resolvedAnimatedStyle]);
|
|
926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Element, {
|
|
927
|
+
...transformedProps,
|
|
928
|
+
ref: composedRefs
|
|
929
|
+
});
|
|
930
|
+
});
|
|
931
|
+
Component["acceptRenderProp"] = true;
|
|
932
|
+
return Component;
|
|
796
933
|
}
|
|
797
934
|
function getDiff(previous, next) {
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
935
|
+
if (!previous) {
|
|
936
|
+
return next;
|
|
937
|
+
}
|
|
938
|
+
let diff = null;
|
|
939
|
+
for (const key in next) {
|
|
940
|
+
if (next[key] !== previous[key]) {
|
|
941
|
+
diff ||= {};
|
|
942
|
+
diff[key] = next[key];
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
return diff;
|
|
809
946
|
}
|
|
810
947
|
function fixTransparentColors(diff, previous, next) {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
return result;
|
|
834
|
-
}
|
|
948
|
+
let result = diff;
|
|
949
|
+
for (const key in diff) {
|
|
950
|
+
if (diff[key] === "transparent") {
|
|
951
|
+
let fixed = "rgba(0, 0, 0, 0)";
|
|
952
|
+
const candidates = [previous?.[key], next?.[key]];
|
|
953
|
+
for (const candidate of candidates) {
|
|
954
|
+
if (typeof candidate === "string" && candidate !== "transparent") {
|
|
955
|
+
const rgbaMatch = candidate.match(/^rgba?\(([^,]+),\s*([^,]+),\s*([^,)]+)/);
|
|
956
|
+
if (rgbaMatch) {
|
|
957
|
+
fixed = `rgba(${rgbaMatch[1]}, ${rgbaMatch[2]}, ${rgbaMatch[3]}, 0)`;
|
|
958
|
+
break;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
if (result === diff) {
|
|
963
|
+
result = { ...diff };
|
|
964
|
+
}
|
|
965
|
+
result[key] = fixed;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
return result;
|
|
969
|
+
}
|