@mkbabb/keyframes.js 1.2.0 → 2.1.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/README.md +99 -2
- package/dist/_redirects +1 -0
- package/dist/keyframes.d.ts +615 -108
- package/dist/keyframes.js +1169 -1270
- package/package.json +100 -96
package/dist/keyframes.js
CHANGED
|
@@ -1,1288 +1,1187 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
throw new TypeError(
|
|
15
|
-
`Expected parsed CSS value node, got ${typeof s}.`
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
return t;
|
|
19
|
-
}, _t = J.Function, Nt = $(N, ut(/[^{}]+/), K).map(
|
|
20
|
-
(e) => {
|
|
21
|
-
const t = e.join(`
|
|
22
|
-
`), s = JSON.parse(t);
|
|
23
|
-
return new f(s, "json");
|
|
24
|
-
}
|
|
25
|
-
), Y = I(
|
|
26
|
-
A.Value,
|
|
27
|
-
_t,
|
|
28
|
-
Nt,
|
|
29
|
-
ut(/[^\(\)\{\}\s,;]+/).map((e) => new f(e))
|
|
30
|
-
).trim(m), Kt = Y.sepBy(m), Yt = $(
|
|
31
|
-
j.skip(jt).trim(m).map((e) => mt(e)),
|
|
32
|
-
Kt.skip(kt.opt()).trim(m)
|
|
33
|
-
).map((e) => {
|
|
34
|
-
const [t, s] = e, n = new V(...$t(s));
|
|
35
|
-
return n.setProperty(t), {
|
|
36
|
-
[t]: n
|
|
37
|
-
};
|
|
38
|
-
}), Rt = I(
|
|
39
|
-
A.TimePercentage.trim(m).map((e) => e.toString()),
|
|
40
|
-
dt.map((e) => `${e}%`)
|
|
41
|
-
), Wt = Rt.sepBy(xt).trim(m), lt = Yt.many().trim(m).wrap(N, K).map((e) => Object.assign({}, ...e)), Lt = g("@keyframes").trim(m).next(j), W = $(Wt, lt).map(
|
|
42
|
-
([e, t]) => e.reduce((s, n) => (s.set(n, t), s), /* @__PURE__ */ new Map())
|
|
43
|
-
), ct = I(
|
|
44
|
-
Lt.next(W.many(1).trim(m).wrap(N, K).trim(m)),
|
|
45
|
-
W.many(1).trim(m)
|
|
46
|
-
).map((e) => e.reduce(
|
|
47
|
-
(t, s) => {
|
|
48
|
-
for (const [n, i] of s)
|
|
49
|
-
t.has(n) ? t.set(n, { ...t.get(n), ...i }) : t.set(n, i);
|
|
50
|
-
return t;
|
|
51
|
-
},
|
|
52
|
-
/* @__PURE__ */ new Map()
|
|
53
|
-
)), Bt = Ut.trim(m).next(j).trim(m), Dt = lt.map((e) => {
|
|
54
|
-
const t = {};
|
|
55
|
-
for (const [s, n] of Object.entries(e))
|
|
56
|
-
if (s.includes("animation")) {
|
|
57
|
-
const i = s.replace(/^animation/i, "").replace(/^\w/, (r) => r.toLowerCase()), o = gt(n.toString());
|
|
58
|
-
t[i] = o, delete e[s];
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
options: t,
|
|
62
|
-
values: e
|
|
63
|
-
};
|
|
64
|
-
}), Ht = Bt.next(Dt), Xt = I(
|
|
65
|
-
Ht.map((e) => e),
|
|
66
|
-
ct.map((e) => ({
|
|
67
|
-
keyframes: e
|
|
68
|
-
}))
|
|
69
|
-
), zt = Xt.sepBy(m).map((e) => Object.assign({}, ...e)), L = {
|
|
70
|
-
Value: Y,
|
|
71
|
-
FunctionArgs: J.FunctionArgs
|
|
72
|
-
}, Gt = w(
|
|
73
|
-
(e) => F(Y, _(e))
|
|
74
|
-
), Zt = w(
|
|
75
|
-
(e) => F(ct, _(e))
|
|
76
|
-
);
|
|
77
|
-
w((e) => {
|
|
78
|
-
const t = F(
|
|
79
|
-
zt,
|
|
80
|
-
_(e)
|
|
81
|
-
), s = {
|
|
82
|
-
keyframes: t.keyframes
|
|
83
|
-
};
|
|
84
|
-
return t.options != null && (s.options = t.options), t.values != null && (s.values = t.values), s;
|
|
85
|
-
});
|
|
86
|
-
w(
|
|
87
|
-
(e) => F(A.Percentage, String(e)).valueOf()
|
|
88
|
-
);
|
|
89
|
-
const B = w((e) => F(
|
|
90
|
-
A.Time.map((t) => t.unit === "ms" ? t.value : t.unit === "s" ? t.value * 1e3 : t.value),
|
|
91
|
-
e
|
|
92
|
-
));
|
|
93
|
-
w((e) => e >= 5e3 ? `${e / 1e3}s` : `${e}ms`);
|
|
94
|
-
w((e) => e === 1 / 0 ? "infinite" : String(e));
|
|
95
|
-
const qt = {
|
|
96
|
-
duration: 1e3,
|
|
97
|
-
delay: 0,
|
|
98
|
-
iterationCount: 1,
|
|
99
|
-
direction: "normal",
|
|
100
|
-
fillMode: "forwards",
|
|
101
|
-
timingFunction: tt,
|
|
102
|
-
useWAAPI: !0,
|
|
103
|
-
colorSpace: "oklab"
|
|
104
|
-
}, Qt = {
|
|
105
|
-
zIndex: 0,
|
|
106
|
-
weight: 1,
|
|
107
|
-
blendMode: "replace",
|
|
108
|
-
enabled: !0
|
|
109
|
-
}, O = (e) => typeof e != "object" || e == null ? !1 : "value" in e && typeof e.value == "number";
|
|
110
|
-
class Jt {
|
|
111
|
-
animations = {};
|
|
112
|
-
transform;
|
|
113
|
-
superKey;
|
|
114
|
-
paused = !1;
|
|
115
|
-
started = !1;
|
|
116
|
-
done = !1;
|
|
117
|
-
singleTarget = !0;
|
|
118
|
-
lastTickTime = 0;
|
|
119
|
-
handleId = void 0;
|
|
120
|
-
resolvePromise = null;
|
|
121
|
-
constructor(...t) {
|
|
122
|
-
const s = [];
|
|
123
|
-
for (const n of t) {
|
|
124
|
-
let i, o;
|
|
125
|
-
n instanceof pt ? i = n : (i = n.animation, o = n.layer), this.transform ??= i.frames[0].transform;
|
|
126
|
-
const r = k(i);
|
|
127
|
-
this.animations[r] = {
|
|
128
|
-
values: {},
|
|
129
|
-
animation: i,
|
|
130
|
-
layer: { ...Qt, ...o }
|
|
131
|
-
}, i.managed = !0, s.push(i);
|
|
132
|
-
}
|
|
133
|
-
this.singleTarget = s.every(
|
|
134
|
-
(n) => n.targets[0] === s[0]?.targets[0]
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
setSuperKey(t) {
|
|
138
|
-
return this.superKey = t, Object.values(this.animations).forEach((s) => {
|
|
139
|
-
s.animation.superKey = t;
|
|
140
|
-
}), this;
|
|
141
|
-
}
|
|
142
|
-
setTargets(...t) {
|
|
143
|
-
Object.values(this.animations).forEach((n) => {
|
|
144
|
-
n.animation.setTargets(...t);
|
|
145
|
-
});
|
|
146
|
-
const s = Object.values(this.animations).map(
|
|
147
|
-
(n) => n.animation
|
|
148
|
-
);
|
|
149
|
-
return this.singleTarget = s.every(
|
|
150
|
-
(n) => n.targets[0] === s[0]?.targets[0]
|
|
151
|
-
), this;
|
|
152
|
-
}
|
|
153
|
-
onStart() {
|
|
154
|
-
return this.started = !0, this;
|
|
155
|
-
}
|
|
156
|
-
onEnd() {
|
|
157
|
-
return this;
|
|
158
|
-
}
|
|
159
|
-
transformFramesGrouped(t) {
|
|
160
|
-
const s = {}, n = Object.values(this.animations);
|
|
161
|
-
n.sort((o, r) => o.layer.zIndex - r.layer.zIndex);
|
|
162
|
-
let i = !0;
|
|
163
|
-
for (const o of n) {
|
|
164
|
-
const { animation: r, values: a, layer: u } = o;
|
|
165
|
-
if (i = i && r.done, !u.enabled) continue;
|
|
166
|
-
if (!(r.done || r.paused)) {
|
|
167
|
-
const l = r.interpFrames(r.t, !1);
|
|
168
|
-
Object.assign(a, l);
|
|
169
|
-
}
|
|
170
|
-
const c = u.properties ? Object.fromEntries(
|
|
171
|
-
Object.entries(a).filter(
|
|
172
|
-
([l]) => u.properties.has(l)
|
|
173
|
-
)
|
|
174
|
-
) : a;
|
|
175
|
-
switch (u.blendMode) {
|
|
176
|
-
case "replace":
|
|
177
|
-
Object.assign(s, c);
|
|
178
|
-
break;
|
|
179
|
-
case "add":
|
|
180
|
-
for (const [l, h] of Object.entries(c))
|
|
181
|
-
if (l in s) {
|
|
182
|
-
const d = s[l], p = h;
|
|
183
|
-
O(d) && O(p) ? d.value = d.value + p.value : s[l] = h;
|
|
184
|
-
} else
|
|
185
|
-
s[l] = h;
|
|
186
|
-
break;
|
|
187
|
-
case "weighted":
|
|
188
|
-
for (const [l, h] of Object.entries(c))
|
|
189
|
-
if (l in s && u.weight < 1) {
|
|
190
|
-
const d = s[l], p = h;
|
|
191
|
-
O(d) && O(p) ? d.value = E(
|
|
192
|
-
u.weight,
|
|
193
|
-
d.value,
|
|
194
|
-
p.value
|
|
195
|
-
) : s[l] = h;
|
|
196
|
-
} else
|
|
197
|
-
s[l] = h;
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return this.done = i, this.transform(s, t), s;
|
|
202
|
-
}
|
|
203
|
-
async tick(t) {
|
|
204
|
-
return this.lastTickTime = t, this.started || this.onStart(), await Promise.all(
|
|
205
|
-
Object.values(this.animations).map(async (s) => {
|
|
206
|
-
(!s.animation.paused || s.animation.pausedTime === 0) && await s.animation.tick(t);
|
|
207
|
-
})
|
|
208
|
-
), this.done && this.onEnd(), this;
|
|
209
|
-
}
|
|
210
|
-
async draw(t) {
|
|
211
|
-
await this.tick(t), !this.paused && (this.singleTarget ? this.transformFramesGrouped(t) : this.done = Object.values(this.animations).map(({ animation: s }) => (s.interpFrames(s.t, !0), s)).every((s) => s.done), this.done ? (this.reset(), this.resolvePromise && this.resolvePromise()) : this.handleId = v(this.draw.bind(this)));
|
|
212
|
-
}
|
|
213
|
-
async play() {
|
|
214
|
-
return new Promise((t) => {
|
|
215
|
-
this.resolvePromise = t, this.handleId = v(this.draw.bind(this));
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
pause() {
|
|
219
|
-
const t = this.paused;
|
|
220
|
-
if (this.started) {
|
|
221
|
-
this.paused = !this.paused;
|
|
222
|
-
const s = this.lastTickTime || performance.now();
|
|
223
|
-
if (Object.values(this.animations).forEach((n) => {
|
|
224
|
-
const i = n.animation;
|
|
225
|
-
this.paused ? (i.pause(!1), i.pausedTime === 0 && (i.pausedTime = s)) : i.paused = !1;
|
|
226
|
-
}), this.paused && this.singleTarget) {
|
|
227
|
-
for (const n of Object.values(this.animations)) {
|
|
228
|
-
const i = n.animation, o = i.interpFrames(i.t, !1);
|
|
229
|
-
Object.assign(n.values, o);
|
|
230
|
-
}
|
|
231
|
-
this.transformFramesGrouped(s);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return t && (this.handleId = v(this.draw.bind(this))), this;
|
|
235
|
-
}
|
|
236
|
-
reset() {
|
|
237
|
-
return Object.values(this.animations).forEach((t) => {
|
|
238
|
-
const s = t.animation;
|
|
239
|
-
s.started && s.frames.length > 0 && s.interpFrames(0, !0), s.managed = !1, s.reset();
|
|
240
|
-
}), this.started = !1, this.done = !1, this.paused = !1, this.lastTickTime = 0, this;
|
|
241
|
-
}
|
|
242
|
-
stop() {
|
|
243
|
-
return et(this.handleId), this.reset(), this;
|
|
244
|
-
}
|
|
245
|
-
playing() {
|
|
246
|
-
return !(!this.started || this.paused);
|
|
247
|
-
}
|
|
248
|
-
forcePause() {
|
|
249
|
-
this.paused = !0, Object.values(this.animations).forEach((t) => {
|
|
250
|
-
t.animation.paused = !0;
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
forcePlay() {
|
|
254
|
-
this.paused = !1, Object.values(this.animations).forEach((t) => {
|
|
255
|
-
t.animation.paused = !1;
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
// --- Layer management API ---
|
|
259
|
-
/** Set layer config for an animation by name or reference. Chainable. */
|
|
260
|
-
setLayerConfig(t, s) {
|
|
261
|
-
const n = typeof t == "string" ? t : k(t), i = this.animations[n];
|
|
262
|
-
return i && Object.assign(i.layer, s), this;
|
|
263
|
-
}
|
|
264
|
-
/** Convenience toggle for enabling/disabling a layer. Chainable. */
|
|
265
|
-
setLayerEnabled(t, s) {
|
|
266
|
-
return this.setLayerConfig(t, { enabled: s });
|
|
267
|
-
}
|
|
268
|
-
/** Read the layer config for an animation. */
|
|
269
|
-
getLayerConfig(t) {
|
|
270
|
-
const s = typeof t == "string" ? t : k(t);
|
|
271
|
-
return this.animations[s]?.layer;
|
|
272
|
-
}
|
|
1
|
+
import { COMPUTED_UNITS as e, CSSCubicBezier as t, CSSFunction as n, CSSValues as r, FunctionValue as i, ValueArray as a, ValueUnit as o, cancelAnimationFrame as s, clamp as c, convertToMs as l, easeInOutCubic as u, extractAnimationOptions as d, extractKeyframes as f, extractProperties as p, flattenObject as m, isObject as ee, lerp as h, lerpValue as te, normalizeValueUnits as g, parseCSSStylesheet as _, parseCSSTime as v, parseCSSValueUnit as ne, prepareInterpVar as re, requestAnimationFrame as y, scale as b, seekPreviousValue as x, sleep as ie, timingFunctions as S, tryParse as ae, unflattenObject as oe, unflattenObjectToString as C } from "@mkbabb/value.js";
|
|
2
|
+
import { any as se } from "@mkbabb/parse-that";
|
|
3
|
+
//#region src/animation/internal/binarySearch.ts
|
|
4
|
+
function w(e, t, n, r) {
|
|
5
|
+
let i = 0, a = e.length - 1;
|
|
6
|
+
for (; i <= a;) {
|
|
7
|
+
let o = i + a >> 1, s = e[o];
|
|
8
|
+
if (t < n(s)) a = o - 1;
|
|
9
|
+
else if (t > r(s)) i = o + 1;
|
|
10
|
+
else return o;
|
|
11
|
+
}
|
|
12
|
+
return -1;
|
|
273
13
|
}
|
|
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
|
-
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/animation/adapter.ts
|
|
16
|
+
var ce = (e) => {
|
|
17
|
+
let t = {};
|
|
18
|
+
for (let n of e.declarations) t[n.name] = n.value;
|
|
19
|
+
return t;
|
|
20
|
+
}, T = (e) => {
|
|
21
|
+
let t = [];
|
|
22
|
+
for (let n of e.selectors) n.kind === "percent" ? t.push(`${n.value}%`) : t.push(n.name);
|
|
23
|
+
return t;
|
|
24
|
+
}, E = (e) => {
|
|
25
|
+
let t = f(e);
|
|
26
|
+
for (let e of t.values()) if (e.length > 0) return e;
|
|
27
|
+
return [];
|
|
28
|
+
}, D = (e) => {
|
|
29
|
+
let t = e.trim();
|
|
30
|
+
return /@keyframes\b/i.test(t) || t.length === 0 ? e : `@keyframes anonymous {\n${t}\n}`;
|
|
31
|
+
}, O = (e) => {
|
|
32
|
+
let t = typeof e == "string" ? _(D(e)) : e, n = E(t), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
33
|
+
for (let e of n) {
|
|
34
|
+
let t = ce(e);
|
|
35
|
+
for (let n of T(e)) {
|
|
36
|
+
let a = r.get(n);
|
|
37
|
+
r.set(n, {
|
|
38
|
+
...a ?? {},
|
|
39
|
+
...t
|
|
40
|
+
}), e.timingFunction != null && i.set(n, e.timingFunction);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
keyframes: r,
|
|
45
|
+
timingFunctions: i,
|
|
46
|
+
properties: p(t),
|
|
47
|
+
options: d(t)
|
|
48
|
+
};
|
|
49
|
+
}, le = [
|
|
50
|
+
"normal",
|
|
51
|
+
"reverse",
|
|
52
|
+
"alternate",
|
|
53
|
+
"alternate-reverse"
|
|
54
|
+
], ue = [
|
|
55
|
+
"none",
|
|
56
|
+
"forwards",
|
|
57
|
+
"backwards",
|
|
58
|
+
"both"
|
|
59
|
+
], k = {
|
|
60
|
+
duration: 1e3,
|
|
61
|
+
delay: 0,
|
|
62
|
+
iterationCount: 1,
|
|
63
|
+
direction: "normal",
|
|
64
|
+
fillMode: "forwards",
|
|
65
|
+
timingFunction: u,
|
|
66
|
+
useWAAPI: !0,
|
|
67
|
+
colorSpace: "oklab"
|
|
68
|
+
}, A = {
|
|
69
|
+
zIndex: 0,
|
|
70
|
+
weight: 1,
|
|
71
|
+
blendMode: "replace",
|
|
72
|
+
enabled: !0
|
|
73
|
+
}, j = (e) => typeof e != "object" || !e ? !1 : "value" in e && typeof e.value == "number", M = class {
|
|
74
|
+
animations = {};
|
|
75
|
+
transform;
|
|
76
|
+
superKey;
|
|
77
|
+
paused = !1;
|
|
78
|
+
started = !1;
|
|
79
|
+
done = !1;
|
|
80
|
+
singleTarget = !0;
|
|
81
|
+
lastTickTime = 0;
|
|
82
|
+
handleId = void 0;
|
|
83
|
+
resolvePromise = null;
|
|
84
|
+
_boundDraw;
|
|
85
|
+
_entries = [];
|
|
86
|
+
_entriesDirty = !0;
|
|
87
|
+
constructor(...e) {
|
|
88
|
+
this._boundDraw = this.draw.bind(this);
|
|
89
|
+
let t = [];
|
|
90
|
+
for (let n of e) {
|
|
91
|
+
let e, r;
|
|
92
|
+
n instanceof $ ? e = n : (e = n.animation, r = n.layer), this.transform == null && e.frames[0] != null && (this.transform = e.frames[0].transform);
|
|
93
|
+
let i = Q(e);
|
|
94
|
+
this.animations[i] = {
|
|
95
|
+
values: {},
|
|
96
|
+
animation: e,
|
|
97
|
+
layer: {
|
|
98
|
+
...A,
|
|
99
|
+
...r
|
|
100
|
+
}
|
|
101
|
+
}, e.managed = !0, t.push(e);
|
|
102
|
+
}
|
|
103
|
+
this.singleTarget = t.every((e) => e.targets[0] === t[0]?.targets[0]), this.invalidateEntries();
|
|
104
|
+
}
|
|
105
|
+
getEntries() {
|
|
106
|
+
return this._entriesDirty &&= (this._entries = Object.values(this.animations), this._entries.sort((e, t) => e.layer.zIndex - t.layer.zIndex), !1), this._entries;
|
|
107
|
+
}
|
|
108
|
+
invalidateEntries() {
|
|
109
|
+
this._entriesDirty = !0;
|
|
110
|
+
}
|
|
111
|
+
setSuperKey(e) {
|
|
112
|
+
this.superKey = e;
|
|
113
|
+
for (let t of this.getEntries()) t.animation.superKey = e;
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
setTargets(...e) {
|
|
117
|
+
let t = this.getEntries();
|
|
118
|
+
for (let n of t) n.animation.setTargets(...e);
|
|
119
|
+
return this.singleTarget = t.every((e) => e.animation.targets[0] === t[0]?.animation.targets[0]), this;
|
|
120
|
+
}
|
|
121
|
+
onStart() {
|
|
122
|
+
return this.started = !0, this;
|
|
123
|
+
}
|
|
124
|
+
onEnd() {
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
transformFramesGrouped(e) {
|
|
128
|
+
let t = {}, n = this.getEntries(), r = !0;
|
|
129
|
+
for (let e of n) {
|
|
130
|
+
let { animation: n, layer: i, values: a } = e;
|
|
131
|
+
if (r &&= n.done, !i.enabled) continue;
|
|
132
|
+
n.interpFrames(n.t, !1, a);
|
|
133
|
+
let o = i.properties ? Object.fromEntries(Object.entries(a).filter(([e]) => i.properties.has(e))) : a;
|
|
134
|
+
switch (i.blendMode) {
|
|
135
|
+
case "replace":
|
|
136
|
+
Object.assign(t, o);
|
|
137
|
+
break;
|
|
138
|
+
case "add":
|
|
139
|
+
for (let [e, n] of Object.entries(o)) if (e in t) {
|
|
140
|
+
let r = t[e], i = n;
|
|
141
|
+
j(r) && j(i) ? r.value += i.value : t[e] = n;
|
|
142
|
+
} else t[e] = n;
|
|
143
|
+
break;
|
|
144
|
+
case "weighted":
|
|
145
|
+
for (let [e, n] of Object.entries(o)) if (e in t) {
|
|
146
|
+
let r = t[e], a = n;
|
|
147
|
+
j(r) && j(a) ? r.value = h(r.value, a.value, i.weight) : t[e] = n;
|
|
148
|
+
} else t[e] = n;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return this.done = r, this.transform(t, e), t;
|
|
153
|
+
}
|
|
154
|
+
render() {
|
|
155
|
+
let e = this.lastTickTime || performance.now();
|
|
156
|
+
if (this.singleTarget) this.transformFramesGrouped(e);
|
|
157
|
+
else for (let e of this.getEntries()) e.animation.interpFrames(e.animation.t, !0);
|
|
158
|
+
}
|
|
159
|
+
setChildTime(e, t) {
|
|
160
|
+
let n = typeof e == "string" ? e : Q(e), r = this.animations[n];
|
|
161
|
+
if (!r) throw Error(`AnimationGroup.setChildTime: no animation registered for key "${n}". Known keys: ${Object.keys(this.animations).join(", ") || "(none)"}.`);
|
|
162
|
+
let i = r.animation;
|
|
163
|
+
return i.t = t, i.startTime !== void 0 && (i.pausedTime = i.startTime + t), this;
|
|
164
|
+
}
|
|
165
|
+
async tick(e) {
|
|
166
|
+
this.lastTickTime = e, this.started || this.onStart();
|
|
167
|
+
let t = [];
|
|
168
|
+
for (let n of this.getEntries()) {
|
|
169
|
+
let r = n.animation;
|
|
170
|
+
(!r.paused || r.pausedTime === 0) && t.push(r.tick(e));
|
|
171
|
+
}
|
|
172
|
+
return await Promise.all(t), this.done && this.onEnd(), this;
|
|
173
|
+
}
|
|
174
|
+
async draw(e) {
|
|
175
|
+
if (await this.tick(e), !this.paused) {
|
|
176
|
+
if (this.singleTarget) this.transformFramesGrouped(e);
|
|
177
|
+
else {
|
|
178
|
+
let e = !0;
|
|
179
|
+
for (let t of this.getEntries()) t.animation.interpFrames(t.animation.t, !0), e &&= t.animation.done;
|
|
180
|
+
this.done = e;
|
|
181
|
+
}
|
|
182
|
+
this.done ? (this.reset(), this.resolvePromise && this.resolvePromise()) : this.handleId = y(this._boundDraw);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async play() {
|
|
186
|
+
return new Promise((e) => {
|
|
187
|
+
this.resolvePromise = e, this.handleId = y(this._boundDraw);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
pause() {
|
|
191
|
+
if (!this.started) return this;
|
|
192
|
+
this.paused = !this.paused;
|
|
193
|
+
let e = this.lastTickTime || performance.now();
|
|
194
|
+
for (let t of this.getEntries()) {
|
|
195
|
+
let n = t.animation;
|
|
196
|
+
this.paused ? (n.pause(!1), n.pausedTime === 0 && (n.pausedTime = e)) : n.paused = !1;
|
|
197
|
+
}
|
|
198
|
+
return this.paused ? (s(this.handleId), this.handleId = void 0, this.render()) : this.handleId = y(this._boundDraw), this;
|
|
199
|
+
}
|
|
200
|
+
reset() {
|
|
201
|
+
for (let e of this.getEntries()) {
|
|
202
|
+
let t = e.animation;
|
|
203
|
+
t.started && t.frames.length > 0 && t.interpFrames(0, !0), t.managed = !1, t.reset();
|
|
204
|
+
}
|
|
205
|
+
return this.started = !1, this.done = !1, this.paused = !1, this.lastTickTime = 0, this;
|
|
206
|
+
}
|
|
207
|
+
stop() {
|
|
208
|
+
return s(this.handleId), this.handleId = void 0, this.reset(), this;
|
|
209
|
+
}
|
|
210
|
+
playing() {
|
|
211
|
+
return !(!this.started || this.paused);
|
|
212
|
+
}
|
|
213
|
+
forcePause() {
|
|
214
|
+
this.paused = !0;
|
|
215
|
+
for (let e of this.getEntries()) e.animation.paused = !0;
|
|
216
|
+
}
|
|
217
|
+
forcePlay() {
|
|
218
|
+
this.paused = !1;
|
|
219
|
+
for (let e of this.getEntries()) e.animation.paused = !1;
|
|
220
|
+
}
|
|
221
|
+
setLayerConfig(e, t) {
|
|
222
|
+
let n = typeof e == "string" ? e : Q(e), r = this.animations[n];
|
|
223
|
+
if (!r) throw Error(`AnimationGroup.setLayerConfig: no animation registered for key "${n}". Known keys: ${Object.keys(this.animations).join(", ") || "(none)"}.`);
|
|
224
|
+
return Object.assign(r.layer, t), this.invalidateEntries(), this;
|
|
225
|
+
}
|
|
226
|
+
setLayerEnabled(e, t) {
|
|
227
|
+
return this.setLayerConfig(e, { enabled: t });
|
|
228
|
+
}
|
|
229
|
+
getLayerConfig(e) {
|
|
230
|
+
let t = typeof e == "string" ? e : Q(e);
|
|
231
|
+
return this.animations[t]?.layer;
|
|
232
|
+
}
|
|
233
|
+
}, de = class {
|
|
234
|
+
_rafId = null;
|
|
235
|
+
_startTime = void 0;
|
|
236
|
+
_resolve = null;
|
|
237
|
+
play(e, t) {
|
|
238
|
+
if (e <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
|
|
239
|
+
return this.stop(), new Promise((n) => {
|
|
240
|
+
this._resolve = n, this._startTime = void 0;
|
|
241
|
+
let r = (n) => {
|
|
242
|
+
this._startTime === void 0 && (this._startTime = n);
|
|
243
|
+
let i = c((n - this._startTime) / e, 0, 1);
|
|
244
|
+
t(i), i < 1 ? this._rafId = y(r) : this._cleanup();
|
|
245
|
+
};
|
|
246
|
+
this._rafId = y(r);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
stop() {
|
|
250
|
+
this._rafId !== null && s(this._rafId), this._cleanup();
|
|
251
|
+
}
|
|
252
|
+
_cleanup() {
|
|
253
|
+
this._rafId = null, this._startTime = void 0;
|
|
254
|
+
let e = this._resolve;
|
|
255
|
+
this._resolve = null, e?.();
|
|
256
|
+
}
|
|
257
|
+
}, N = (e) => {
|
|
258
|
+
if (e instanceof o) return [e.clone()];
|
|
259
|
+
if (e instanceof i) return e.values.flatMap((e) => N(e));
|
|
260
|
+
if (e instanceof a) return e.flatMap((e) => N(e));
|
|
261
|
+
throw TypeError(`Expected ValueUnit/FunctionValue/ValueArray, got ${typeof e}`);
|
|
262
|
+
}, P = (e) => {
|
|
263
|
+
let t = e.split(".").pop(), n = e.split(".").shift();
|
|
264
|
+
if (!t || !n) throw Error(`Invalid flattened key: ${e}`);
|
|
265
|
+
return {
|
|
266
|
+
mainKey: n,
|
|
267
|
+
childKey: t
|
|
268
|
+
};
|
|
269
|
+
}, F = (e, t, n) => (e.setProperty(t), n !== t && e.setSubProperty(n), e), I = /^\s*cubic-bezier\s*\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)\s*\)\s*$/i, L = (e) => {
|
|
270
|
+
if (e == null) return;
|
|
271
|
+
if (typeof e != "string") return e;
|
|
272
|
+
let n = e.match(I);
|
|
273
|
+
if (n) {
|
|
274
|
+
let e = n.slice(1, 5).map((e) => Number.parseFloat(e ?? ""));
|
|
275
|
+
if (e.length === 4 && e.every((e) => Number.isFinite(e))) {
|
|
276
|
+
let [n, r, i, a] = e;
|
|
277
|
+
return t(n, r, i, a);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
let r = S[e];
|
|
281
|
+
if (typeof r == "function" && r.length <= 1) return r;
|
|
282
|
+
}, R = /* @__PURE__ */ new Map();
|
|
283
|
+
function z(e) {
|
|
284
|
+
let t = m(e), s = (e, t) => {
|
|
285
|
+
let { childKey: c, mainKey: l } = P(e);
|
|
286
|
+
if (t instanceof o) return F(new a(...N(t)), l, c);
|
|
287
|
+
if (t instanceof i) return F(new a(...t.values.flatMap((t) => N(s(e, t)))), l, c);
|
|
288
|
+
if (t instanceof a) return F(new a(...t.flatMap((t) => N(s(e, t)))), l, c);
|
|
289
|
+
let u = String(t), d = `${c}:${u}`, f = R.get(d);
|
|
290
|
+
if (f) return F(f.clone(), l, c);
|
|
291
|
+
let p = F(new a(...N(ae(se(n.FunctionArgs.map((e) => (e.setSubProperty(c), e)), r.Value), u))), l, c);
|
|
292
|
+
return R.set(d, p.clone()), p;
|
|
293
|
+
};
|
|
294
|
+
return Object.entries(t).reduce((e, [t, n]) => (e[t] = s(t, n), e), {});
|
|
453
295
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
return;
|
|
475
|
-
return e;
|
|
296
|
+
var B = (e, t, n, r, i = "oklab", a) => {
|
|
297
|
+
let s = r[t], c = r[n];
|
|
298
|
+
if (!s || !c) throw Error(`Invalid interpolation frame bounds (${t} -> ${n}).`);
|
|
299
|
+
let l = s[e], u = c[e];
|
|
300
|
+
if (!l || !u) throw Error(`Missing variable "${e}" in interpolation bounds.`);
|
|
301
|
+
let d = Math.max(l.length, u.length), f = (t) => {
|
|
302
|
+
let n = t.map((t) => {
|
|
303
|
+
if (!(t instanceof o)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
|
|
304
|
+
return t;
|
|
305
|
+
});
|
|
306
|
+
for (; n.length < d;) n.push(new o(0));
|
|
307
|
+
return n;
|
|
308
|
+
}, p = f(l), m = f(u);
|
|
309
|
+
return p.map((t, n) => {
|
|
310
|
+
let r = m[n];
|
|
311
|
+
if (!r) throw Error(`Missing right-hand interpolation value at index ${n}.`);
|
|
312
|
+
if (!(t instanceof o) || !(r instanceof o)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
|
|
313
|
+
let s = { colorSpace: i };
|
|
314
|
+
return a !== void 0 && (s.hueMethod = a), re(g(t, r, s));
|
|
315
|
+
});
|
|
476
316
|
};
|
|
477
|
-
function
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
const o = z(t, i), r = z(s, i), a = U.includes(o.unit) ? r.unit : o.unit, u = E(e, o.value, r.value);
|
|
484
|
-
return n.value = u, n.unit = a, n;
|
|
485
|
-
}
|
|
486
|
-
function me(e, { start: t, stop: s, value: n }) {
|
|
487
|
-
return t.value.keys().forEach((i) => {
|
|
488
|
-
const o = t.value[i], r = s.value[i], a = o instanceof f ? o.value : o, u = r instanceof f ? r.value : r, c = E(e, a, u), l = n.value[i];
|
|
489
|
-
l instanceof f ? l.value = c : n.value[i] = c;
|
|
490
|
-
}), n;
|
|
317
|
+
function V(e, t, n) {
|
|
318
|
+
let [r, i] = [e.start, t.start];
|
|
319
|
+
return {
|
|
320
|
+
start: r.value * n / 100,
|
|
321
|
+
stop: i.value * n / 100
|
|
322
|
+
};
|
|
491
323
|
}
|
|
492
|
-
function
|
|
493
|
-
|
|
494
|
-
|
|
324
|
+
function H(e, t, n = !0) {
|
|
325
|
+
e = n ? e : m(e);
|
|
326
|
+
let r = C(e);
|
|
327
|
+
t.forEach((e) => {
|
|
328
|
+
Object.entries(r).forEach(([t, n]) => {
|
|
329
|
+
e.style.setProperty(t, n);
|
|
330
|
+
});
|
|
331
|
+
});
|
|
495
332
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
return P(
|
|
502
|
-
new V(...b(o)),
|
|
503
|
-
a,
|
|
504
|
-
r
|
|
505
|
-
);
|
|
506
|
-
if (o instanceof x) {
|
|
507
|
-
const p = o.values.flatMap(
|
|
508
|
-
(y) => b(s(i, y))
|
|
509
|
-
);
|
|
510
|
-
return P(
|
|
511
|
-
new V(...p),
|
|
512
|
-
a,
|
|
513
|
-
r
|
|
514
|
-
);
|
|
515
|
-
} else if (o instanceof V) {
|
|
516
|
-
const p = o.flatMap(
|
|
517
|
-
(y) => b(s(i, y))
|
|
518
|
-
);
|
|
519
|
-
return P(
|
|
520
|
-
new V(...p),
|
|
521
|
-
a,
|
|
522
|
-
r
|
|
523
|
-
);
|
|
524
|
-
}
|
|
525
|
-
const u = String(o), c = `${r}:${u}`, l = G.get(c);
|
|
526
|
-
if (l)
|
|
527
|
-
return P(l.clone(), a, r);
|
|
528
|
-
const h = F(
|
|
529
|
-
I(
|
|
530
|
-
L.FunctionArgs.map((p) => (p.setSubProperty(r), p)),
|
|
531
|
-
L.Value
|
|
532
|
-
),
|
|
533
|
-
u
|
|
534
|
-
), d = P(
|
|
535
|
-
new V(...b(h)),
|
|
536
|
-
a,
|
|
537
|
-
r
|
|
538
|
-
);
|
|
539
|
-
return G.set(c, d.clone()), d;
|
|
540
|
-
};
|
|
541
|
-
return Object.entries(t).reduce(
|
|
542
|
-
(i, [o, r]) => (i[o] = s(o, r), i),
|
|
543
|
-
{}
|
|
544
|
-
);
|
|
333
|
+
H[Symbol.for("keyframes.defaultRenderer")] = !0;
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region src/animation/numeric.ts
|
|
336
|
+
function fe() {
|
|
337
|
+
return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
545
338
|
}
|
|
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
|
-
|
|
339
|
+
var pe = (e) => e, U = class {
|
|
340
|
+
keyframes;
|
|
341
|
+
segments;
|
|
342
|
+
positions;
|
|
343
|
+
timingFn;
|
|
344
|
+
result;
|
|
345
|
+
_duration;
|
|
346
|
+
_respectReducedMotion;
|
|
347
|
+
_playback = new de();
|
|
348
|
+
constructor(e, t) {
|
|
349
|
+
if (e.length < 2) throw Error("NumericAnimation requires at least 2 keyframes.");
|
|
350
|
+
if (this.keyframes = e.map((e) => ({ ...e })), this._duration = t?.duration ?? 0, this._respectReducedMotion = t?.respectReducedMotion ?? !1, this.timingFn = (t?.timingFunction ? L(t.timingFunction) : void 0) ?? pe, t?.positions) {
|
|
351
|
+
if (t.positions.length !== e.length) throw Error("positions length must match keyframes length.");
|
|
352
|
+
this.positions = t.positions;
|
|
353
|
+
} else this.positions = e.map((t, n) => n / (e.length - 1) * 100);
|
|
354
|
+
this.result = { ...e[0] }, this.segments = this.buildSegments();
|
|
355
|
+
}
|
|
356
|
+
buildSegments() {
|
|
357
|
+
let e = [];
|
|
358
|
+
for (let t = 0; t < this.keyframes.length - 1; t++) e.push(this.buildSegment(t));
|
|
359
|
+
return e;
|
|
360
|
+
}
|
|
361
|
+
buildSegment(e) {
|
|
362
|
+
let t = this.keyframes[e], n = this.keyframes[e + 1], r = Object.keys(t);
|
|
363
|
+
return {
|
|
364
|
+
startPos: this.positions[e],
|
|
365
|
+
stopPos: this.positions[e + 1],
|
|
366
|
+
keys: r,
|
|
367
|
+
startVals: r.map((e) => t[e]),
|
|
368
|
+
stopVals: r.map((e) => n[e]),
|
|
369
|
+
timingFunction: this.timingFn
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
at(e) {
|
|
373
|
+
let t = c(e, 0, 1) * 100, n = w(this.segments, t, (e) => e.startPos, (e) => e.stopPos);
|
|
374
|
+
n === -1 && (n = this.segments.length - 1);
|
|
375
|
+
let r = this.segments[n], i = b(c(t, r.startPos, r.stopPos), r.startPos, r.stopPos, 0, 1), a = r.timingFunction(i);
|
|
376
|
+
for (let e = 0; e < r.keys.length; e++) this.result[r.keys[e]] = h(r.startVals[e], r.stopVals[e], a);
|
|
377
|
+
return this.result;
|
|
378
|
+
}
|
|
379
|
+
updateKeyframe(e, t) {
|
|
380
|
+
if (e < 0 || e >= this.keyframes.length) throw RangeError(`Keyframe index ${e} out of range [0, ${this.keyframes.length - 1}].`);
|
|
381
|
+
return Object.assign(this.keyframes[e], t), e > 0 && (this.segments[e - 1] = this.buildSegment(e - 1)), e < this.keyframes.length - 1 && (this.segments[e] = this.buildSegment(e)), this;
|
|
382
|
+
}
|
|
383
|
+
play(e, t) {
|
|
384
|
+
let n = t ?? this._duration;
|
|
385
|
+
if (this._respectReducedMotion && fe()) {
|
|
386
|
+
let t = this.at(1);
|
|
387
|
+
return e?.(t), Promise.resolve();
|
|
388
|
+
}
|
|
389
|
+
return this._playback.play(n, (t) => {
|
|
390
|
+
let n = this.at(t);
|
|
391
|
+
e?.(n);
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
stop() {
|
|
395
|
+
this._playback.stop();
|
|
396
|
+
}
|
|
397
|
+
}, me = {
|
|
398
|
+
damping: .1,
|
|
399
|
+
snapThreshold: .001,
|
|
400
|
+
targetEpsilon: 0,
|
|
401
|
+
initial: 0,
|
|
402
|
+
clamp: !0,
|
|
403
|
+
respectReducedMotion: !1
|
|
579
404
|
};
|
|
580
|
-
function
|
|
581
|
-
|
|
582
|
-
return {
|
|
583
|
-
start: n.value * s / 100,
|
|
584
|
-
stop: i.value * s / 100
|
|
585
|
-
};
|
|
405
|
+
function W() {
|
|
406
|
+
return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
586
407
|
}
|
|
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
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
initial: 0,
|
|
677
|
-
clamp: !0
|
|
408
|
+
var G = class {
|
|
409
|
+
options;
|
|
410
|
+
targetValue;
|
|
411
|
+
currentValue;
|
|
412
|
+
isSettled;
|
|
413
|
+
_rafId = null;
|
|
414
|
+
_lastFrameT = 0;
|
|
415
|
+
_onFrame = void 0;
|
|
416
|
+
constructor(e) {
|
|
417
|
+
this.options = {
|
|
418
|
+
...me,
|
|
419
|
+
...e
|
|
420
|
+
}, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
|
|
421
|
+
}
|
|
422
|
+
get target() {
|
|
423
|
+
return this.targetValue;
|
|
424
|
+
}
|
|
425
|
+
get current() {
|
|
426
|
+
return this.currentValue;
|
|
427
|
+
}
|
|
428
|
+
get settled() {
|
|
429
|
+
return this.isSettled;
|
|
430
|
+
}
|
|
431
|
+
setTarget(e) {
|
|
432
|
+
this.options.clamp && (e = Math.max(0, Math.min(1, e)));
|
|
433
|
+
let t = Math.abs(e - this.targetValue);
|
|
434
|
+
if (t > 0 && t >= this.options.targetEpsilon) {
|
|
435
|
+
if (this.targetValue = e, this.options.respectReducedMotion && W()) {
|
|
436
|
+
this.currentValue = e, this.isSettled = !0, this._onFrame?.(e);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
this.isSettled = !1, this._onFrame && this._rafId === null && this._startLoop();
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
tick() {
|
|
443
|
+
return this.isSettled ? this.currentValue : (this.currentValue += (this.targetValue - this.currentValue) * this.options.damping, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = Math.max(0, Math.min(1, this.currentValue))), this.currentValue);
|
|
444
|
+
}
|
|
445
|
+
tickDt(e) {
|
|
446
|
+
if (this.isSettled) return this.currentValue;
|
|
447
|
+
let t = 1 - Math.exp(-this.options.damping * e / 16.667);
|
|
448
|
+
return this.currentValue += (this.targetValue - this.currentValue) * t, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = Math.max(0, Math.min(1, this.currentValue))), this.currentValue;
|
|
449
|
+
}
|
|
450
|
+
snap() {
|
|
451
|
+
this.currentValue = this.targetValue, this.isSettled = !0, this._stopLoop();
|
|
452
|
+
}
|
|
453
|
+
reset(e) {
|
|
454
|
+
let t = e ?? 0;
|
|
455
|
+
this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._stopLoop();
|
|
456
|
+
}
|
|
457
|
+
play(e) {
|
|
458
|
+
if (this._onFrame = e, this.options.respectReducedMotion && W()) {
|
|
459
|
+
this.currentValue = this.targetValue, this.isSettled = !0, e?.(this.currentValue);
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
if (this.isSettled) {
|
|
463
|
+
e?.(this.currentValue);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
this._startLoop();
|
|
467
|
+
}
|
|
468
|
+
stop() {
|
|
469
|
+
this._onFrame = void 0, this._stopLoop();
|
|
470
|
+
}
|
|
471
|
+
_startLoop() {
|
|
472
|
+
if (this._rafId !== null) return;
|
|
473
|
+
this._lastFrameT = 0;
|
|
474
|
+
let e = (t) => {
|
|
475
|
+
let n = this._lastFrameT ? t - this._lastFrameT : 16.667;
|
|
476
|
+
this._lastFrameT = t;
|
|
477
|
+
let r = this.tickDt(n);
|
|
478
|
+
if (this._onFrame?.(r), this.isSettled) {
|
|
479
|
+
this._stopLoop();
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
this._rafId = y(e);
|
|
483
|
+
};
|
|
484
|
+
this._rafId = y(e);
|
|
485
|
+
}
|
|
486
|
+
_stopLoop() {
|
|
487
|
+
this._rafId !== null && (s(this._rafId), this._rafId = null), this._lastFrameT = 0;
|
|
488
|
+
}
|
|
489
|
+
}, he = {
|
|
490
|
+
response: .5,
|
|
491
|
+
dampingFraction: .86,
|
|
492
|
+
initial: 0,
|
|
493
|
+
initialVelocity: 0,
|
|
494
|
+
settleThreshold: .001,
|
|
495
|
+
velocitySettleThreshold: .001,
|
|
496
|
+
respectReducedMotion: !1
|
|
678
497
|
};
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
targetValue;
|
|
682
|
-
currentValue;
|
|
683
|
-
isSettled;
|
|
684
|
-
constructor(t) {
|
|
685
|
-
this.options = { ...Te, ...t }, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
|
|
686
|
-
}
|
|
687
|
-
get target() {
|
|
688
|
-
return this.targetValue;
|
|
689
|
-
}
|
|
690
|
-
get current() {
|
|
691
|
-
return this.currentValue;
|
|
692
|
-
}
|
|
693
|
-
get settled() {
|
|
694
|
-
return this.isSettled;
|
|
695
|
-
}
|
|
696
|
-
setTarget(t) {
|
|
697
|
-
this.options.clamp && (t = Math.max(0, Math.min(1, t))), t !== this.targetValue && (this.targetValue = t, this.isSettled = !1);
|
|
698
|
-
}
|
|
699
|
-
/** Advance one step using fixed damping. Returns current value. */
|
|
700
|
-
tick() {
|
|
701
|
-
return this.isSettled ? this.currentValue : (this.currentValue += (this.targetValue - this.currentValue) * this.options.damping, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = Math.max(
|
|
702
|
-
0,
|
|
703
|
-
Math.min(1, this.currentValue)
|
|
704
|
-
)), this.currentValue);
|
|
705
|
-
}
|
|
706
|
-
/** Frame-rate independent tick. dt is in milliseconds. */
|
|
707
|
-
tickDt(t) {
|
|
708
|
-
if (this.isSettled) return this.currentValue;
|
|
709
|
-
const s = 1 - Math.exp(-this.options.damping * t / 16.667);
|
|
710
|
-
return this.currentValue += (this.targetValue - this.currentValue) * s, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = Math.max(
|
|
711
|
-
0,
|
|
712
|
-
Math.min(1, this.currentValue)
|
|
713
|
-
)), this.currentValue;
|
|
714
|
-
}
|
|
715
|
-
/** Immediately set current = target. */
|
|
716
|
-
snap() {
|
|
717
|
-
this.currentValue = this.targetValue, this.isSettled = !0;
|
|
718
|
-
}
|
|
719
|
-
/** Reset to a specific value (default 0). */
|
|
720
|
-
reset(t) {
|
|
721
|
-
const s = t ?? 0;
|
|
722
|
-
this.targetValue = s, this.currentValue = s, this.isSettled = !0;
|
|
723
|
-
}
|
|
498
|
+
function K() {
|
|
499
|
+
return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
724
500
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
501
|
+
var q = class {
|
|
502
|
+
options;
|
|
503
|
+
targetValue;
|
|
504
|
+
currentValue;
|
|
505
|
+
currentVelocity;
|
|
506
|
+
isSettled;
|
|
507
|
+
elapsed;
|
|
508
|
+
originValue;
|
|
509
|
+
originVelocity;
|
|
510
|
+
omega;
|
|
511
|
+
zeta;
|
|
512
|
+
omegaD;
|
|
513
|
+
subscribers = /* @__PURE__ */ new Set();
|
|
514
|
+
disposed = !1;
|
|
515
|
+
_rafId = null;
|
|
516
|
+
_lastFrameT = 0;
|
|
517
|
+
_onFrame = void 0;
|
|
518
|
+
constructor(e) {
|
|
519
|
+
this.options = {
|
|
520
|
+
...he,
|
|
521
|
+
...e
|
|
522
|
+
}, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.currentVelocity = this.options.initialVelocity, this.isSettled = this.options.initialVelocity === 0, this.elapsed = 0, this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.omega = 2 * Math.PI / this.options.response, this.zeta = this.options.dampingFraction, this.omegaD = this.zeta < 1 ? this.omega * Math.sqrt(1 - this.zeta * this.zeta) : 0;
|
|
523
|
+
}
|
|
524
|
+
get target() {
|
|
525
|
+
return this.targetValue;
|
|
526
|
+
}
|
|
527
|
+
get value() {
|
|
528
|
+
return this.currentValue;
|
|
529
|
+
}
|
|
530
|
+
get velocity() {
|
|
531
|
+
return this.currentVelocity;
|
|
532
|
+
}
|
|
533
|
+
get settled() {
|
|
534
|
+
return this.isSettled;
|
|
535
|
+
}
|
|
536
|
+
set target(e) {
|
|
537
|
+
e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
|
|
538
|
+
}
|
|
539
|
+
reseatTarget(e) {
|
|
540
|
+
if (this.targetValue = e, this.options.respectReducedMotion && K()) {
|
|
541
|
+
this.currentValue = e, this.currentVelocity = 0, this.isSettled = !0, this.originValue = e, this.originVelocity = 0, this.elapsed = 0, this.emit(), this._stopLoop();
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this._onFrame && this._rafId === null && this._startLoop();
|
|
545
|
+
}
|
|
546
|
+
tick(e) {
|
|
547
|
+
return this.disposed || this.isSettled || e <= 0 ? this.currentValue : (this.elapsed += e, this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
|
|
548
|
+
}
|
|
549
|
+
tickToTime(e) {
|
|
550
|
+
return this.disposed || this.isSettled ? this.currentValue : (this.elapsed = Math.max(0, e), this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
|
|
551
|
+
}
|
|
552
|
+
evaluateAt(e) {
|
|
553
|
+
let t = this.originValue - this.targetValue, n = this.originVelocity, r = this.omega, i = this.zeta, a, o;
|
|
554
|
+
if (i < 1) {
|
|
555
|
+
let s = this.omegaD, c = Math.exp(-i * r * e), l = t, u = (n + i * r * t) / s, d = Math.cos(s * e), f = Math.sin(s * e);
|
|
556
|
+
a = c * (l * d + u * f), o = c * ((u * s - l * i * r) * d - (l * s + u * i * r) * f);
|
|
557
|
+
} else if (i === 1) {
|
|
558
|
+
let i = Math.exp(-r * e), s = t, c = n + r * t;
|
|
559
|
+
a = i * (s + c * e), o = i * (c - r * (s + c * e));
|
|
560
|
+
} else {
|
|
561
|
+
let s = r * Math.sqrt(i * i - 1), c = -i * r + s, l = -i * r - s, u = (n - l * t) / (c - l), d = t - u, f = Math.exp(c * e), p = Math.exp(l * e);
|
|
562
|
+
a = u * f + d * p, o = u * c * f + d * l * p;
|
|
563
|
+
}
|
|
564
|
+
this.currentValue = this.targetValue + a, this.currentVelocity = o;
|
|
565
|
+
}
|
|
566
|
+
checkSettled() {
|
|
567
|
+
let e = Math.abs(this.currentValue - this.targetValue), t = Math.abs(this.currentVelocity);
|
|
568
|
+
e < this.options.settleThreshold && t < this.options.velocitySettleThreshold && (this.currentValue = this.targetValue, this.currentVelocity = 0, this.isSettled = !0);
|
|
569
|
+
}
|
|
570
|
+
snap() {
|
|
571
|
+
this.currentValue = this.targetValue, this.currentVelocity = 0, this.originValue = this.targetValue, this.originVelocity = 0, this.elapsed = 0, this.isSettled = !0, this.emit(), this._stopLoop();
|
|
572
|
+
}
|
|
573
|
+
reset(e, t) {
|
|
574
|
+
let n = e ?? 0, r = t ?? 0;
|
|
575
|
+
this.targetValue = n, this.currentValue = n, this.currentVelocity = r, this.originValue = n, this.originVelocity = r, this.elapsed = 0, this.isSettled = r === 0, this.emit(), this._stopLoop();
|
|
576
|
+
}
|
|
577
|
+
subscribe(e) {
|
|
578
|
+
return this.subscribers.add(e), () => {
|
|
579
|
+
this.subscribers.delete(e);
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
emit() {
|
|
583
|
+
if (this.subscribers.size !== 0) for (let e of this.subscribers) e(this.currentValue, this.currentVelocity);
|
|
584
|
+
}
|
|
585
|
+
dispose() {
|
|
586
|
+
this.disposed = !0, this._stopLoop(), this.subscribers.clear();
|
|
587
|
+
}
|
|
588
|
+
play(e) {
|
|
589
|
+
if (!this.disposed) {
|
|
590
|
+
if (this._onFrame = e, this.options.respectReducedMotion && K()) {
|
|
591
|
+
this.currentValue = this.targetValue, this.currentVelocity = 0, this.isSettled = !0, e?.(this.currentValue, this.currentVelocity);
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
if (this.isSettled) {
|
|
595
|
+
e?.(this.currentValue, this.currentVelocity);
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
this._startLoop();
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
stop() {
|
|
602
|
+
this._onFrame = void 0, this._stopLoop();
|
|
603
|
+
}
|
|
604
|
+
_startLoop() {
|
|
605
|
+
if (this._rafId !== null) return;
|
|
606
|
+
this._lastFrameT = 0;
|
|
607
|
+
let e = (t) => {
|
|
608
|
+
let n = this._lastFrameT ? t - this._lastFrameT : 16.667;
|
|
609
|
+
if (this._lastFrameT = t, this.tick(n / 1e3), this._onFrame?.(this.currentValue, this.currentVelocity), this.isSettled) {
|
|
610
|
+
this._stopLoop();
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
this._rafId = y(e);
|
|
614
|
+
};
|
|
615
|
+
this._rafId = y(e);
|
|
616
|
+
}
|
|
617
|
+
_stopLoop() {
|
|
618
|
+
this._rafId !== null && (s(this._rafId), this._rafId = null), this._lastFrameT = 0;
|
|
619
|
+
}
|
|
731
620
|
};
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
/** Get raw transform values at the given progress [0, 1]. */
|
|
751
|
-
at(t) {
|
|
752
|
-
return this.animation.at(t);
|
|
753
|
-
}
|
|
754
|
-
/** Get a CSS transform string at the given progress [0, 1]. */
|
|
755
|
-
toCSSTransform(t) {
|
|
756
|
-
const { translateX: s, translateY: n, scaleX: i, scaleY: o } = this.animation.at(t);
|
|
757
|
-
return `translate(${s}px, ${n}px) scale(${i}, ${o})`;
|
|
758
|
-
}
|
|
759
|
-
/** Apply the morph transform to an element at the given progress [0, 1]. */
|
|
760
|
-
apply(t, s) {
|
|
761
|
-
t.style.transform = this.toCSSTransform(s), t.style.transformOrigin = this.transformOrigin;
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
const ve = (e) => {
|
|
765
|
-
if (e == null) return null;
|
|
766
|
-
if (typeof e == "function") return e;
|
|
767
|
-
const t = it[e];
|
|
768
|
-
return typeof t == "function" && t.length <= 1 ? t : null;
|
|
769
|
-
}, q = (e) => Math.max(0, Math.min(1, e));
|
|
770
|
-
class ft {
|
|
771
|
-
smoother;
|
|
772
|
-
easingFn;
|
|
773
|
-
currentProgress = 0;
|
|
774
|
-
constructor(t) {
|
|
775
|
-
this.easingFn = ve(t?.easing), t?.smoothing === !1 ? this.smoother = null : this.smoother = new be(
|
|
776
|
-
t?.smoothing
|
|
777
|
-
);
|
|
778
|
-
}
|
|
779
|
-
/** Advance one frame. Applies easing -> boundary snap -> smoothing. */
|
|
780
|
-
tick() {
|
|
781
|
-
let t = q(this.sample());
|
|
782
|
-
return this.easingFn && (t = this.easingFn(t)), this.smoother ? (this.smoother.setTarget(t), t <= 0 || t >= 1 ? this.smoother.snap() : this.smoother.tick(), this.currentProgress = this.smoother.current) : this.currentProgress = t, this.currentProgress;
|
|
783
|
-
}
|
|
784
|
-
/** Frame-rate independent variant. dt in ms. */
|
|
785
|
-
tickDt(t) {
|
|
786
|
-
let s = q(this.sample());
|
|
787
|
-
return this.easingFn && (s = this.easingFn(s)), this.smoother ? (this.smoother.setTarget(s), s <= 0 || s >= 1 ? this.smoother.snap() : this.smoother.tickDt(t), this.currentProgress = this.smoother.current) : this.currentProgress = s, this.currentProgress;
|
|
788
|
-
}
|
|
789
|
-
get progress() {
|
|
790
|
-
return this.currentProgress;
|
|
791
|
-
}
|
|
792
|
-
/** True if no smoother or smoother is settled. */
|
|
793
|
-
get settled() {
|
|
794
|
-
return this.smoother == null || this.smoother.settled;
|
|
795
|
-
}
|
|
796
|
-
/** Immediately converge smoother to current target. */
|
|
797
|
-
snap() {
|
|
798
|
-
this.smoother?.snap(), this.smoother && (this.currentProgress = this.smoother.current);
|
|
799
|
-
}
|
|
800
|
-
/** Reset progress to a specific value (default 0). */
|
|
801
|
-
reset(t) {
|
|
802
|
-
const s = t ?? 0;
|
|
803
|
-
this.smoother && this.smoother.reset(s), this.currentProgress = s;
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
class xe extends ft {
|
|
807
|
-
threshold;
|
|
808
|
-
getScrollY;
|
|
809
|
-
getViewportHeight;
|
|
810
|
-
constructor(t) {
|
|
811
|
-
super(t), this.threshold = t?.threshold ?? 0.35, this.getScrollY = t?.getScrollY ?? (() => window.scrollY), this.getViewportHeight = t?.getViewportHeight ?? (() => window.innerHeight);
|
|
812
|
-
}
|
|
813
|
-
sample() {
|
|
814
|
-
const t = this.getViewportHeight() * this.threshold;
|
|
815
|
-
return t <= 0 ? 0 : this.getScrollY() / t;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
class Ue extends ft {
|
|
819
|
-
value = 0;
|
|
820
|
-
constructor(t) {
|
|
821
|
-
super({ smoothing: !1, ...t });
|
|
822
|
-
}
|
|
823
|
-
/** Set the raw progress value. */
|
|
824
|
-
set(t) {
|
|
825
|
-
this.value = t;
|
|
826
|
-
}
|
|
827
|
-
sample() {
|
|
828
|
-
return this.value;
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
const Fe = (e) => typeof e.transform == "function", Q = (e) => typeof e == "string" && U.includes(e);
|
|
832
|
-
function Pe(e) {
|
|
833
|
-
if (!e.targets || e.targets.length === 0)
|
|
834
|
-
return !1;
|
|
835
|
-
const t = Fe(e) ? e.transform : void 0;
|
|
836
|
-
for (const s of e.frames) {
|
|
837
|
-
const n = s.transform;
|
|
838
|
-
if (n !== ht && n !== t)
|
|
839
|
-
return !1;
|
|
840
|
-
}
|
|
841
|
-
if (e.frames.length > 1) {
|
|
842
|
-
const s = e.frames[0].timingFunction;
|
|
843
|
-
for (let n = 1; n < e.frames.length; n++)
|
|
844
|
-
if (e.frames[n].timingFunction !== s)
|
|
845
|
-
return !1;
|
|
846
|
-
}
|
|
847
|
-
for (const s of e.frames)
|
|
848
|
-
for (const n of Object.values(s.interpVars))
|
|
849
|
-
for (const i of n) {
|
|
850
|
-
const o = i.start?.unit, r = i.stop?.unit;
|
|
851
|
-
if (Q(o) || Q(r))
|
|
852
|
-
return !1;
|
|
853
|
-
}
|
|
854
|
-
for (const s of e.frames)
|
|
855
|
-
for (const n of Object.values(s.interpVars))
|
|
856
|
-
for (const i of n)
|
|
857
|
-
if (i.start?.unit === "color" || i.stop?.unit === "color")
|
|
858
|
-
return !1;
|
|
859
|
-
return !0;
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/animation/springLinearStops.ts
|
|
623
|
+
function ge(e) {
|
|
624
|
+
let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = new q({
|
|
625
|
+
response: e.response,
|
|
626
|
+
dampingFraction: e.dampingFraction,
|
|
627
|
+
initial: 0,
|
|
628
|
+
settleThreshold: n,
|
|
629
|
+
velocitySettleThreshold: n
|
|
630
|
+
});
|
|
631
|
+
i.target = 1;
|
|
632
|
+
let a = ["0"], o = r / (t + 1);
|
|
633
|
+
for (let e = 1; e <= t; e++) {
|
|
634
|
+
i.tick(o);
|
|
635
|
+
let n = e / (t + 1) * 100, r = i.settled ? 1 : i.value;
|
|
636
|
+
a.push(`${r.toFixed(5)} ${n.toFixed(3)}%`);
|
|
637
|
+
}
|
|
638
|
+
return a.push("1"), i.dispose(), `linear(${a.join(", ")})`;
|
|
860
639
|
}
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
640
|
+
//#endregion
|
|
641
|
+
//#region src/animation/springTimingFunction.ts
|
|
642
|
+
function _e(e) {
|
|
643
|
+
let t = e.sampleCount ?? 64, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = new q({
|
|
644
|
+
response: e.response,
|
|
645
|
+
dampingFraction: e.dampingFraction,
|
|
646
|
+
initial: 0,
|
|
647
|
+
settleThreshold: n,
|
|
648
|
+
velocitySettleThreshold: n
|
|
649
|
+
});
|
|
650
|
+
i.target = 1;
|
|
651
|
+
let a = new Float64Array(t + 1);
|
|
652
|
+
a[0] = 0;
|
|
653
|
+
let o = r / t;
|
|
654
|
+
for (let e = 1; e <= t; e++) i.tick(o), a[e] = i.settled ? 1 : i.value;
|
|
655
|
+
return a[t] = 1, i.dispose(), (e) => {
|
|
656
|
+
if (e <= 0) return 0;
|
|
657
|
+
if (e >= 1) return 1;
|
|
658
|
+
let n = e * t, r = Math.floor(n), i = n - r, o = a[r];
|
|
659
|
+
return o + (a[r + 1] - o) * i;
|
|
660
|
+
};
|
|
876
661
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
662
|
+
//#endregion
|
|
663
|
+
//#region src/animation/morph.ts
|
|
664
|
+
var J = (e) => {
|
|
665
|
+
if (e instanceof HTMLElement) {
|
|
666
|
+
let t = e.getBoundingClientRect();
|
|
667
|
+
return {
|
|
668
|
+
x: t.x,
|
|
669
|
+
y: t.y,
|
|
670
|
+
width: t.width,
|
|
671
|
+
height: t.height
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
return e;
|
|
675
|
+
}, ve = class {
|
|
676
|
+
animation;
|
|
677
|
+
transformOrigin;
|
|
678
|
+
timingFunction;
|
|
679
|
+
duration;
|
|
680
|
+
constructor(e, t, n) {
|
|
681
|
+
this.transformOrigin = n?.transformOrigin ?? "top left", this.timingFunction = n?.timingFunction, this.duration = n?.duration ?? 0, this.measure(e, t);
|
|
682
|
+
}
|
|
683
|
+
measure(e, t) {
|
|
684
|
+
let n = J(e), r = J(t), i = r.x - n.x, a = r.y - n.y, o = n.width === 0 ? 1 : r.width / n.width, s = n.height === 0 ? 1 : r.height / n.height;
|
|
685
|
+
return this.animation = new U([{
|
|
686
|
+
translateX: 0,
|
|
687
|
+
translateY: 0,
|
|
688
|
+
scaleX: 1,
|
|
689
|
+
scaleY: 1
|
|
690
|
+
}, {
|
|
691
|
+
translateX: i,
|
|
692
|
+
translateY: a,
|
|
693
|
+
scaleX: o,
|
|
694
|
+
scaleY: s
|
|
695
|
+
}], {
|
|
696
|
+
timingFunction: this.timingFunction,
|
|
697
|
+
duration: this.duration
|
|
698
|
+
}), this;
|
|
699
|
+
}
|
|
700
|
+
at(e) {
|
|
701
|
+
return this.animation.at(e);
|
|
702
|
+
}
|
|
703
|
+
toCSSTransform(e) {
|
|
704
|
+
let { translateX: t, translateY: n, scaleX: r, scaleY: i } = this.animation.at(e);
|
|
705
|
+
return `translate(${t}px, ${n}px) scale(${r}, ${i})`;
|
|
706
|
+
}
|
|
707
|
+
apply(e, t) {
|
|
708
|
+
e.style.transform = this.toCSSTransform(t), e.style.transformOrigin = this.transformOrigin;
|
|
709
|
+
}
|
|
710
|
+
play(e, t) {
|
|
711
|
+
return this.animation.play((t) => {
|
|
712
|
+
let { translateX: n, translateY: r, scaleX: i, scaleY: a } = t;
|
|
713
|
+
e.style.transform = `translate(${n}px, ${r}px) scale(${i}, ${a})`, e.style.transformOrigin = this.transformOrigin;
|
|
714
|
+
}, t ?? this.duration);
|
|
715
|
+
}
|
|
716
|
+
stop() {
|
|
717
|
+
this.animation.stop();
|
|
718
|
+
}
|
|
719
|
+
}, ye = (e) => {
|
|
720
|
+
if (e == null) return null;
|
|
721
|
+
if (typeof e == "function") return e;
|
|
722
|
+
let t = S[e];
|
|
723
|
+
return typeof t == "function" && t.length <= 1 ? t : null;
|
|
724
|
+
}, be = (e) => Math.max(0, Math.min(1, e)), Y = class {
|
|
725
|
+
smoother;
|
|
726
|
+
easingFn;
|
|
727
|
+
currentProgress = 0;
|
|
728
|
+
boundaryEpsilon;
|
|
729
|
+
constructor(e) {
|
|
730
|
+
this.easingFn = ye(e?.easing), this.boundaryEpsilon = e?.boundaryEpsilon ?? .005, e?.smoothing === !1 ? this.smoother = null : this.smoother = new G(e?.smoothing);
|
|
731
|
+
}
|
|
732
|
+
applyPipeline() {
|
|
733
|
+
let e = be(this.sample());
|
|
734
|
+
this.easingFn && (e = this.easingFn(e));
|
|
735
|
+
let t = this.boundaryEpsilon;
|
|
736
|
+
return e <= t ? e = 0 : e >= 1 - t && (e = 1), e;
|
|
737
|
+
}
|
|
738
|
+
finalizeProgress(e) {
|
|
739
|
+
return this.smoother && (this.smoother.setTarget(e), (e <= 0 || e >= 1) && this.smoother.snap()), this.currentProgress = this.smoother ? this.smoother.current : e, this.currentProgress;
|
|
740
|
+
}
|
|
741
|
+
_advance(e) {
|
|
742
|
+
let t = this.applyPipeline();
|
|
743
|
+
return this.smoother && t > 0 && t < 1 ? (this.smoother.setTarget(t), e === void 0 ? this.smoother.tick() : this.smoother.tickDt(e), this.currentProgress = this.smoother.current) : this.finalizeProgress(t), this.currentProgress;
|
|
744
|
+
}
|
|
745
|
+
tick() {
|
|
746
|
+
return this._advance();
|
|
747
|
+
}
|
|
748
|
+
tickDt(e) {
|
|
749
|
+
return this._advance(e);
|
|
750
|
+
}
|
|
751
|
+
get progress() {
|
|
752
|
+
return this.currentProgress;
|
|
753
|
+
}
|
|
754
|
+
get settled() {
|
|
755
|
+
return this.smoother == null || this.smoother.settled;
|
|
756
|
+
}
|
|
757
|
+
snap() {
|
|
758
|
+
this.smoother?.snap(), this.smoother && (this.currentProgress = this.smoother.current);
|
|
759
|
+
}
|
|
760
|
+
reset(e) {
|
|
761
|
+
let t = e ?? 0;
|
|
762
|
+
this.smoother && this.smoother.reset(t), this.currentProgress = t;
|
|
763
|
+
}
|
|
764
|
+
}, xe = class extends Y {
|
|
765
|
+
threshold;
|
|
766
|
+
getScrollY;
|
|
767
|
+
getViewportHeight;
|
|
768
|
+
constructor(e) {
|
|
769
|
+
super(e), this.threshold = e?.threshold ?? .35, this.getScrollY = e?.getScrollY ?? (() => window.scrollY), this.getViewportHeight = e?.getViewportHeight ?? (() => window.innerHeight);
|
|
770
|
+
}
|
|
771
|
+
sample() {
|
|
772
|
+
let e = this.getViewportHeight() * this.threshold;
|
|
773
|
+
return e <= 0 ? 0 : this.getScrollY() / e;
|
|
774
|
+
}
|
|
775
|
+
}, Se = class extends Y {
|
|
776
|
+
value = 0;
|
|
777
|
+
constructor(e) {
|
|
778
|
+
super({
|
|
779
|
+
smoothing: !1,
|
|
780
|
+
...e
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
set(e) {
|
|
784
|
+
this.value = e;
|
|
785
|
+
}
|
|
786
|
+
sample() {
|
|
787
|
+
return this.value;
|
|
788
|
+
}
|
|
789
|
+
}, X = (t) => typeof t == "string" && e.includes(t), Z = Symbol.for("keyframes.defaultRenderer"), Ce = (e) => typeof e == "function" && e[Z] === !0;
|
|
790
|
+
function we(e) {
|
|
791
|
+
if (!e.targets || e.targets.length === 0) return {
|
|
792
|
+
eligible: !1,
|
|
793
|
+
reason: "no DOM targets"
|
|
794
|
+
};
|
|
795
|
+
if (typeof e.targets[0]?.animate != "function") return {
|
|
796
|
+
eligible: !1,
|
|
797
|
+
reason: "target does not implement Element.animate()"
|
|
798
|
+
};
|
|
799
|
+
for (let t of e.frames) if (!Ce(t.transform)) return {
|
|
800
|
+
eligible: !1,
|
|
801
|
+
reason: "custom transform function (not the default DOM renderer)"
|
|
802
|
+
};
|
|
803
|
+
if (e.frames.length > 1) {
|
|
804
|
+
let t = e.frames[0].timingFunction;
|
|
805
|
+
for (let n = 1; n < e.frames.length; n++) if (e.frames[n].timingFunction !== t) return {
|
|
806
|
+
eligible: !1,
|
|
807
|
+
reason: "non-uniform per-frame timing function (WAAPI supports one easing per animation)"
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
for (let t of e.frames) for (let e of Object.values(t.interpVars)) for (let t of e) {
|
|
811
|
+
if (X(t.start?.unit) || X(t.stop?.unit)) return {
|
|
812
|
+
eligible: !1,
|
|
813
|
+
reason: `computed unit (${String(t.start?.unit ?? t.stop?.unit)}) requires DOM resolution`
|
|
814
|
+
};
|
|
815
|
+
if (t.start?.unit === "color" || t.stop?.unit === "color") return {
|
|
816
|
+
eligible: !1,
|
|
817
|
+
reason: "color interpolation requires perceptual lerp"
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
return { eligible: !0 };
|
|
900
821
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
822
|
+
function Te(e) {
|
|
823
|
+
let t = e.options.duration, n = [], r = /* @__PURE__ */ new Set();
|
|
824
|
+
for (let t of e.frames) r.add(t.time.start), r.add(t.time.stop);
|
|
825
|
+
let i = [...r].sort((e, t) => e - t);
|
|
826
|
+
for (let r of i) {
|
|
827
|
+
let i = e.interpFrames(r, !1);
|
|
828
|
+
if (Object.keys(i).length === 0) continue;
|
|
829
|
+
let a = C(i);
|
|
830
|
+
n.push({
|
|
831
|
+
offset: Math.max(0, Math.min(1, r / t)),
|
|
832
|
+
...a
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
return n;
|
|
908
836
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
managed = !1;
|
|
933
|
-
unflatten = !0;
|
|
934
|
-
resolvePromise = null;
|
|
935
|
-
_playingPromise = null;
|
|
936
|
-
dispatchAnimationEvent(t) {
|
|
937
|
-
if (!(typeof AnimationEvent > "u"))
|
|
938
|
-
for (const s of this.targets)
|
|
939
|
-
typeof s?.dispatchEvent == "function" && s.dispatchEvent(
|
|
940
|
-
new AnimationEvent(t, {
|
|
941
|
-
animationName: this.name ?? "",
|
|
942
|
-
elapsedTime: this.t / 1e3
|
|
943
|
-
})
|
|
944
|
-
);
|
|
945
|
-
}
|
|
946
|
-
constructor(t, s, n, i) {
|
|
947
|
-
this.options = {}, this.setOptions({ ...qt, ...t ?? {} }), this.targets = s == null ? [] : Array.isArray(s) ? s : [s], this.name = n, this.superKey = i;
|
|
948
|
-
}
|
|
949
|
-
convertFrameStart(t) {
|
|
950
|
-
if (t.start.unit === "s" || t.start.unit === "ms" || !t.start.unit) {
|
|
951
|
-
const s = t.start.unit === "s" ? "s" : "ms", n = nt(t.start.value, s);
|
|
952
|
-
t.start.value = n / this.options.duration * 100, t.start.unit = "%";
|
|
953
|
-
}
|
|
954
|
-
return t.start.value = C(t.start.value, 0, 100), t;
|
|
955
|
-
}
|
|
956
|
-
addFrame(t, s, n, i) {
|
|
957
|
-
typeof t == "number" ? t = String(t) + "%" : typeof t == "string" ? t = t : t instanceof f && (t = String(t));
|
|
958
|
-
const o = st(t);
|
|
959
|
-
let r = {
|
|
960
|
-
id: this.frameId,
|
|
961
|
-
start: o,
|
|
962
|
-
vars: s,
|
|
963
|
-
transform: n,
|
|
964
|
-
timingFunction: M(i) ?? this.options.timingFunction
|
|
965
|
-
};
|
|
966
|
-
return this.convertFrameStart(
|
|
967
|
-
r
|
|
968
|
-
), this.templateFrames.push(
|
|
969
|
-
r
|
|
970
|
-
), this.frameId += 1, this;
|
|
971
|
-
}
|
|
972
|
-
createFrame(t, s) {
|
|
973
|
-
const n = this.templateFrames[t], i = this.templateFrames[s], o = {
|
|
974
|
-
start: t,
|
|
975
|
-
stop: s
|
|
976
|
-
}, r = we(n, i, this.options.duration);
|
|
977
|
-
let a = n.transform;
|
|
978
|
-
if (a == null) {
|
|
979
|
-
const l = R(
|
|
980
|
-
t,
|
|
981
|
-
this.frames,
|
|
982
|
-
(h) => h.transform != null
|
|
983
|
-
);
|
|
984
|
-
a = this.frames[l].transform;
|
|
985
|
-
}
|
|
986
|
-
let u = n.timingFunction;
|
|
987
|
-
if (u == null) {
|
|
988
|
-
const l = R(
|
|
989
|
-
t,
|
|
990
|
-
this.frames,
|
|
991
|
-
(h) => h.timingFunction != null
|
|
992
|
-
);
|
|
993
|
-
u = this.frames[l].timingFunction;
|
|
994
|
-
}
|
|
995
|
-
return {
|
|
996
|
-
id: this.frameId++,
|
|
997
|
-
ixs: o,
|
|
998
|
-
start: n.start,
|
|
999
|
-
time: r,
|
|
1000
|
-
vars: void 0,
|
|
1001
|
-
flatVars: void 0,
|
|
1002
|
-
interpVars: {},
|
|
1003
|
-
transform: a,
|
|
1004
|
-
timingFunction: u
|
|
1005
|
-
};
|
|
1006
|
-
}
|
|
1007
|
-
reconcileVars(t) {
|
|
1008
|
-
const s = this.parsedVars[t];
|
|
1009
|
-
s && Object.keys(s).forEach((n) => {
|
|
1010
|
-
const i = this.parsedVars.findIndex(
|
|
1011
|
-
(c, l) => l > t && c[n] != null
|
|
1012
|
-
);
|
|
1013
|
-
if (i === -1)
|
|
1014
|
-
return;
|
|
1015
|
-
const [o, r] = [t, i], a = this.frames.findIndex(
|
|
1016
|
-
(c) => c.ixs.start === o && c.ixs.stop === r
|
|
1017
|
-
), u = a !== -1 ? this.frames[a] : this.createFrame(o, r);
|
|
1018
|
-
u.interpVars[n] = ye(
|
|
1019
|
-
n,
|
|
1020
|
-
o,
|
|
1021
|
-
r,
|
|
1022
|
-
this.parsedVars,
|
|
1023
|
-
this.options.colorSpace,
|
|
1024
|
-
this.options.hueMethod
|
|
1025
|
-
), a === -1 && this.frames.push(u);
|
|
1026
|
-
});
|
|
1027
|
-
}
|
|
1028
|
-
parse() {
|
|
1029
|
-
this.frames = [], this.templateFrames.sort((t, s) => t.start.value - s.start.value), this.parsedVars = this.templateFrames.map((t) => {
|
|
1030
|
-
const s = ge(
|
|
1031
|
-
t.vars
|
|
1032
|
-
);
|
|
1033
|
-
return Object.values(s).forEach((n) => {
|
|
1034
|
-
n.setTargets(this.targets);
|
|
1035
|
-
}), s;
|
|
1036
|
-
});
|
|
1037
|
-
for (let t = 0; t < this.templateFrames.length - 1; t++)
|
|
1038
|
-
this.frames.push(this.createFrame(t, t + 1));
|
|
1039
|
-
return this.frames.forEach((t, s) => this.reconcileVars(s)), this.frames.sort((t, s) => t.time.start === s.time.start ? t.time.stop - s.time.stop : t.time.start - s.time.start), this.frames = this.frames.filter(
|
|
1040
|
-
(t) => t.interpVars != null && Object.keys(t.interpVars).length > 0
|
|
1041
|
-
), this.frames.forEach((t) => {
|
|
1042
|
-
const s = Object.entries(t.interpVars).reduce((n, [i, o]) => (n[i] = o.map((r) => r.value), n), {});
|
|
1043
|
-
t.flatVars = s, t.vars = Et(t.flatVars);
|
|
1044
|
-
}), this;
|
|
1045
|
-
}
|
|
1046
|
-
setTimingFunction(t) {
|
|
1047
|
-
return this.options.timingFunction = M(t) ?? tt, this;
|
|
1048
|
-
}
|
|
1049
|
-
setIterationCount(t) {
|
|
1050
|
-
if (!t || t === "infinite" || t === "∞" || t === "Infinity")
|
|
1051
|
-
this.options.iterationCount = 1 / 0;
|
|
1052
|
-
else if (typeof t == "string") {
|
|
1053
|
-
const s = parseFloat(t.trim());
|
|
1054
|
-
if (isNaN(s) || s < 0) return this;
|
|
1055
|
-
this.options.iterationCount = s;
|
|
1056
|
-
} else {
|
|
1057
|
-
if (isNaN(t) || t < 0) return this;
|
|
1058
|
-
this.options.iterationCount = t;
|
|
1059
|
-
}
|
|
1060
|
-
return this;
|
|
1061
|
-
}
|
|
1062
|
-
setDuration(t) {
|
|
1063
|
-
typeof t == "string" && (t = B(t));
|
|
1064
|
-
const s = t ?? this.options.duration;
|
|
1065
|
-
if (!isFinite(s) || s <= 0) return this;
|
|
1066
|
-
const n = this.options.duration, i = s / n;
|
|
1067
|
-
for (let o = 0; o < this.frames.length; o++) {
|
|
1068
|
-
const r = this.frames[o];
|
|
1069
|
-
r.time.start *= i, r.time.stop *= i;
|
|
1070
|
-
}
|
|
1071
|
-
return this.options.duration = s, this;
|
|
1072
|
-
}
|
|
1073
|
-
setDelay(t) {
|
|
1074
|
-
return typeof t == "string" && (t = B(t)), this.options.delay = t ?? 0, this;
|
|
1075
|
-
}
|
|
1076
|
-
setDirection(t) {
|
|
1077
|
-
return this.options.direction = t ?? "normal", this.reversed = !1, (this.options.direction === "reverse" || this.options.direction === "alternate-reverse" && this.iteration % 2 === 0 || this.options.direction === "alternate" && this.iteration % 2 === 1) && (this.reversed = !0), this;
|
|
1078
|
-
}
|
|
1079
|
-
setFillMode(t) {
|
|
1080
|
-
return this.options.fillMode = t ?? "forwards", this;
|
|
1081
|
-
}
|
|
1082
|
-
setUseWAAPI(t) {
|
|
1083
|
-
return this.options.useWAAPI = t ?? !0, this;
|
|
1084
|
-
}
|
|
1085
|
-
setColorSpace(t) {
|
|
1086
|
-
return this.options.colorSpace = t ?? "oklab", this;
|
|
1087
|
-
}
|
|
1088
|
-
setHueMethod(t) {
|
|
1089
|
-
return t !== void 0 && (this.options.hueMethod = t), this;
|
|
1090
|
-
}
|
|
1091
|
-
setOptions(t) {
|
|
1092
|
-
return this.setTimingFunction(t.timingFunction), this.setDuration(t.duration), this.setIterationCount(t.iterationCount), this.setDelay(t.delay), this.setDirection(t.direction), this.setFillMode(t.fillMode), this.setUseWAAPI(t.useWAAPI), this.setColorSpace(t.colorSpace), this.setHueMethod(t.hueMethod), this;
|
|
1093
|
-
}
|
|
1094
|
-
reverse() {
|
|
1095
|
-
if (this.startTime !== void 0) {
|
|
1096
|
-
const t = this.t, s = this.options.duration - 2 * t;
|
|
1097
|
-
this.startTime -= s;
|
|
1098
|
-
}
|
|
1099
|
-
return this.reversed = !this.reversed, this;
|
|
1100
|
-
}
|
|
1101
|
-
fillForwards() {
|
|
1102
|
-
this.interpFrames(this.options.duration, !0);
|
|
1103
|
-
}
|
|
1104
|
-
fillBackwards() {
|
|
1105
|
-
this.interpFrames(0, !0);
|
|
1106
|
-
}
|
|
1107
|
-
/**
|
|
1108
|
-
* Stateless progress query. Maps [0,1] from first keyframe to last,
|
|
1109
|
-
* regardless of playback direction. `apply=true` invokes transform callbacks.
|
|
1110
|
-
*/
|
|
1111
|
-
at(t, s = !1) {
|
|
1112
|
-
const n = this.reversed;
|
|
1113
|
-
this.reversed = !1;
|
|
1114
|
-
const i = C(t, 0, 1) * this.options.duration, o = this.interpFrames(i, s);
|
|
1115
|
-
return this.reversed = n, o;
|
|
1116
|
-
}
|
|
1117
|
-
interpFrames(t, s = !1) {
|
|
1118
|
-
t = this.reversed ? this.options.duration - t : t;
|
|
1119
|
-
const n = {};
|
|
1120
|
-
for (let i = 0; i < this.frames.length; i++) {
|
|
1121
|
-
const o = this.frames[i], { start: r, stop: a } = o.time;
|
|
1122
|
-
if (t < r || t > a)
|
|
1123
|
-
continue;
|
|
1124
|
-
const u = at(t, r, a, 0, 1), c = o.timingFunction(u);
|
|
1125
|
-
for (const l of Object.values(o.interpVars))
|
|
1126
|
-
for (const h of l)
|
|
1127
|
-
de(c, h);
|
|
1128
|
-
s && o.transform(
|
|
1129
|
-
this.unflatten ? o.vars : o.flatVars,
|
|
1130
|
-
t
|
|
1131
|
-
), Object.assign(n, o.flatVars);
|
|
1132
|
-
}
|
|
1133
|
-
return n;
|
|
1134
|
-
}
|
|
1135
|
-
async onStart() {
|
|
1136
|
-
this.reversed = !1, (this.options.direction === "reverse" || this.options.direction === "alternate-reverse" && this.iteration % 2 === 0 || this.options.direction === "alternate" && this.iteration % 2 === 1) && this.reverse(), (this.options.fillMode === "backwards" || this.options.fillMode === "both") && this.fillBackwards(), this.options.delay > 0 && (this.paused = !0, await It(this.options.delay), this.paused = !1), this.started = !0;
|
|
1137
|
-
}
|
|
1138
|
-
async onEnd() {
|
|
1139
|
-
this.options.fillMode === "forwards" || this.options.fillMode === "both" ? this.fillForwards() : (this.options.fillMode === "none" || this.options.fillMode === "backwards") && this.fillBackwards(), this.startTime = void 0, this.iteration >= this.options.iterationCount - 1 ? (this.done = !0, this.iteration = 0, this.dispatchAnimationEvent("animationend")) : (this.iteration += 1, this.dispatchAnimationEvent("animationiteration"));
|
|
1140
|
-
}
|
|
1141
|
-
async tick(t) {
|
|
1142
|
-
if (this.startTime === void 0 && (await this.onStart(), this.startTime = t + this.options.delay, this.dispatchAnimationEvent("animationstart")), this.paused && this.pausedTime === 0)
|
|
1143
|
-
return this.pausedTime = t, this.t;
|
|
1144
|
-
if (this.pausedTime > 0 && !this.paused) {
|
|
1145
|
-
const s = t - this.pausedTime;
|
|
1146
|
-
this.startTime += s, this.pausedTime = 0;
|
|
1147
|
-
}
|
|
1148
|
-
return this.t = t - this.startTime, this.t >= this.options.duration && (await this.onEnd(), this.t = this.options.duration), this.t;
|
|
1149
|
-
}
|
|
1150
|
-
async draw(t) {
|
|
1151
|
-
this.managed || (t = await this.tick(t), !this.paused && (this.interpFrames(t, !0), this.done ? (this.reset(), this.resolvePromise && this.resolvePromise()) : this.handleId = v(this.draw.bind(this))));
|
|
1152
|
-
}
|
|
1153
|
-
/** Internal rAF-based play loop. */
|
|
1154
|
-
_playRAF() {
|
|
1155
|
-
return new Promise((t) => {
|
|
1156
|
-
this.resolvePromise = t, this.handleId = v(this.draw.bind(this));
|
|
1157
|
-
});
|
|
1158
|
-
}
|
|
1159
|
-
/** Play via the Web Animations API for compositor-thread execution. */
|
|
1160
|
-
async _playWAAPI() {
|
|
1161
|
-
try {
|
|
1162
|
-
await Oe(this), this.reset();
|
|
1163
|
-
} catch {
|
|
1164
|
-
return this._playRAF();
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
async play() {
|
|
1168
|
-
if (this.managed)
|
|
1169
|
-
return;
|
|
1170
|
-
if (this._playingPromise) return this._playingPromise;
|
|
1171
|
-
let t;
|
|
1172
|
-
return this.options.useWAAPI && this.targets.length > 0 && typeof this.targets[0]?.animate == "function" && Pe(this) ? t = this._playWAAPI() : t = this._playRAF(), this._playingPromise = t, t.finally(() => {
|
|
1173
|
-
this._playingPromise = null;
|
|
1174
|
-
}), t;
|
|
1175
|
-
}
|
|
1176
|
-
pause(t = !0) {
|
|
1177
|
-
return this.paused && t ? this.resume() : (this.started && (this.paused = !0), this);
|
|
1178
|
-
}
|
|
1179
|
-
resume() {
|
|
1180
|
-
return this.started && this.paused && (this.paused = !1, this.handleId = v(this.draw.bind(this))), this;
|
|
1181
|
-
}
|
|
1182
|
-
stop() {
|
|
1183
|
-
et(this.handleId), this.reset();
|
|
1184
|
-
}
|
|
1185
|
-
playing() {
|
|
1186
|
-
return !(!this.started || this.paused);
|
|
1187
|
-
}
|
|
1188
|
-
/** Returns the effective time accounting for direction reversal. */
|
|
1189
|
-
get effectiveT() {
|
|
1190
|
-
return this.reversed ? this.options.duration - this.t : this.t;
|
|
1191
|
-
}
|
|
1192
|
-
reset() {
|
|
1193
|
-
return this.done = !1, this.started = !1, this.paused = !1, this.reversed = !1, this.iteration = 0, this.startTime = void 0, this.pausedTime = 0, this.t = 0, this;
|
|
1194
|
-
}
|
|
1195
|
-
setTargets(...t) {
|
|
1196
|
-
return this.targets = t, this.frames.forEach((s) => {
|
|
1197
|
-
Object.values(s.interpVars).forEach((n) => {
|
|
1198
|
-
n.forEach(({ start: i, stop: o, value: r }) => {
|
|
1199
|
-
i.setTargets(this.targets), o.setTargets(this.targets), r.setTargets(this.targets);
|
|
1200
|
-
});
|
|
1201
|
-
});
|
|
1202
|
-
}), this;
|
|
1203
|
-
}
|
|
1204
|
-
group(...t) {
|
|
1205
|
-
return new Jt(this, ...t);
|
|
1206
|
-
}
|
|
837
|
+
var Ee = {
|
|
838
|
+
normal: "normal",
|
|
839
|
+
reverse: "reverse",
|
|
840
|
+
alternate: "alternate",
|
|
841
|
+
"alternate-reverse": "alternate-reverse"
|
|
842
|
+
}, De = {
|
|
843
|
+
none: "none",
|
|
844
|
+
forwards: "forwards",
|
|
845
|
+
backwards: "backwards",
|
|
846
|
+
both: "both"
|
|
847
|
+
};
|
|
848
|
+
function Oe(e) {
|
|
849
|
+
let t = e.options, n = Ee[t.direction], r = De[t.fillMode];
|
|
850
|
+
if (n == null) throw TypeError(`Unrecognised animation direction "${t.direction}".`);
|
|
851
|
+
if (r == null) throw TypeError(`Unrecognised animation fill mode "${t.fillMode}".`);
|
|
852
|
+
return {
|
|
853
|
+
duration: t.duration,
|
|
854
|
+
delay: t.delay,
|
|
855
|
+
iterations: t.iterationCount === Infinity ? Infinity : t.iterationCount,
|
|
856
|
+
direction: n,
|
|
857
|
+
fill: r,
|
|
858
|
+
easing: "linear"
|
|
859
|
+
};
|
|
1207
860
|
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
const n = t instanceof Map ? t.entries() : Object.entries(t);
|
|
1223
|
-
for (const [i, o] of n)
|
|
1224
|
-
this.addFrame(i, o, s);
|
|
1225
|
-
return this.parse(), this;
|
|
1226
|
-
}
|
|
1227
|
-
fromString(t, s) {
|
|
1228
|
-
this.unflatten = s != null, s ??= this.transform.bind(this);
|
|
1229
|
-
const n = Zt(t);
|
|
1230
|
-
for (const [i, o] of n.entries()) {
|
|
1231
|
-
const r = Object.fromEntries(
|
|
1232
|
-
Object.entries(o).map(([c, l]) => [
|
|
1233
|
-
c,
|
|
1234
|
-
Ce(l) ? l.clone() : l
|
|
1235
|
-
])
|
|
1236
|
-
), a = r.animationTimingFunction ?? r.timingFunction;
|
|
1237
|
-
delete r.animationTimingFunction, delete r.timingFunction;
|
|
1238
|
-
const u = a ? M(a.toString()) : void 0;
|
|
1239
|
-
this.addFrame(i, r, s, u);
|
|
1240
|
-
}
|
|
1241
|
-
return this.parse(), this;
|
|
1242
|
-
}
|
|
1243
|
-
transform(t) {
|
|
1244
|
-
ht(t, this.targets);
|
|
1245
|
-
}
|
|
861
|
+
async function ke(e) {
|
|
862
|
+
let t = Te(e), n = Oe(e), r = e.targets.map((e) => e.animate(t, n)), i = !1, a = (t) => {
|
|
863
|
+
if (!(i || e.done)) {
|
|
864
|
+
if (e.tick(t), e.paused) for (let e of r) e.pause();
|
|
865
|
+
else for (let e of r) e.playState === "paused" && e.play();
|
|
866
|
+
e.handleId = requestAnimationFrame(a);
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
e.handleId = requestAnimationFrame(a);
|
|
870
|
+
try {
|
|
871
|
+
await Promise.all(r.map((e) => e.finished));
|
|
872
|
+
} finally {
|
|
873
|
+
i = !0;
|
|
874
|
+
}
|
|
1246
875
|
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
876
|
+
//#endregion
|
|
877
|
+
//#region src/animation/index.ts
|
|
878
|
+
var Ae = (e) => typeof e != "object" || !e ? !1 : typeof e.clone == "function", Q = (e) => typeof e == "string" ? e : e.name ?? String(e.id), je = 0, $ = class {
|
|
879
|
+
id = je++;
|
|
880
|
+
name;
|
|
881
|
+
superKey;
|
|
882
|
+
targets;
|
|
883
|
+
options;
|
|
884
|
+
templateFrames = [];
|
|
885
|
+
parsedVars = [];
|
|
886
|
+
frameId = 0;
|
|
887
|
+
frames = [];
|
|
888
|
+
handleId = void 0;
|
|
889
|
+
startTime = void 0;
|
|
890
|
+
pausedTime = 0;
|
|
891
|
+
t = 0;
|
|
892
|
+
iteration = 0;
|
|
893
|
+
started = !1;
|
|
894
|
+
done = !1;
|
|
895
|
+
reversed = !1;
|
|
896
|
+
paused = !1;
|
|
897
|
+
managed = !1;
|
|
898
|
+
waapiIneligibleReason = void 0;
|
|
899
|
+
unflatten = !0;
|
|
900
|
+
resolvePromise = null;
|
|
901
|
+
_playingPromise = null;
|
|
902
|
+
_boundDraw = this.draw.bind(this);
|
|
903
|
+
dispatchAnimationEvent(e) {
|
|
904
|
+
if (!(typeof AnimationEvent > "u")) for (let t of this.targets) typeof t?.dispatchEvent == "function" && t.dispatchEvent(new AnimationEvent(e, {
|
|
905
|
+
animationName: this.name ?? "",
|
|
906
|
+
elapsedTime: this.t / 1e3
|
|
907
|
+
}));
|
|
908
|
+
}
|
|
909
|
+
constructor(e, t, n, r) {
|
|
910
|
+
this.options = {}, this.setOptions({
|
|
911
|
+
...k,
|
|
912
|
+
...e ?? {}
|
|
913
|
+
}), this.targets = t == null ? [] : Array.isArray(t) ? t : [t], this.name = n, this.superKey = r;
|
|
914
|
+
}
|
|
915
|
+
convertFrameStart(e) {
|
|
916
|
+
if (e.start.unit === "s" || e.start.unit === "ms" || !e.start.unit) {
|
|
917
|
+
let t = e.start.unit === "s" ? "s" : "ms", n = l(e.start.value, t);
|
|
918
|
+
e.start.value = n / this.options.duration * 100, e.start.unit = "%";
|
|
919
|
+
}
|
|
920
|
+
return e.start.value = c(e.start.value, 0, 100), e;
|
|
921
|
+
}
|
|
922
|
+
addFrame(e, t, n, r) {
|
|
923
|
+
typeof e == "number" ? e = String(e) + "%" : typeof e == "string" ? e = e : e instanceof o && (e = String(e));
|
|
924
|
+
let i = ne(e), a = {
|
|
925
|
+
id: this.frameId,
|
|
926
|
+
start: i,
|
|
927
|
+
vars: t,
|
|
928
|
+
transform: n,
|
|
929
|
+
timingFunction: L(r) ?? this.options.timingFunction
|
|
930
|
+
};
|
|
931
|
+
return this.convertFrameStart(a), this.templateFrames.push(a), this.frameId += 1, this;
|
|
932
|
+
}
|
|
933
|
+
createFrame(e, t) {
|
|
934
|
+
let n = this.templateFrames[e], r = this.templateFrames[t], i = {
|
|
935
|
+
start: e,
|
|
936
|
+
stop: t
|
|
937
|
+
}, a = V(n, r, this.options.duration), o = n.transform;
|
|
938
|
+
if (o == null) {
|
|
939
|
+
let t = x(e, this.frames, (e) => e.transform != null);
|
|
940
|
+
o = this.frames[t].transform;
|
|
941
|
+
}
|
|
942
|
+
let s = n.timingFunction;
|
|
943
|
+
if (s == null) {
|
|
944
|
+
let t = x(e, this.frames, (e) => e.timingFunction != null);
|
|
945
|
+
s = this.frames[t].timingFunction;
|
|
946
|
+
}
|
|
947
|
+
return {
|
|
948
|
+
id: this.frameId++,
|
|
949
|
+
ixs: i,
|
|
950
|
+
start: n.start,
|
|
951
|
+
time: a,
|
|
952
|
+
vars: void 0,
|
|
953
|
+
flatVars: void 0,
|
|
954
|
+
interpVars: {},
|
|
955
|
+
allInterpVars: [],
|
|
956
|
+
transform: o,
|
|
957
|
+
timingFunction: s
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
buildVarIndex() {
|
|
961
|
+
let e = /* @__PURE__ */ new Map();
|
|
962
|
+
for (let t = 0; t < this.parsedVars.length; t++) for (let n of Object.keys(this.parsedVars[t])) {
|
|
963
|
+
let r = e.get(n);
|
|
964
|
+
r || (r = [], e.set(n, r)), r.push(t);
|
|
965
|
+
}
|
|
966
|
+
return e;
|
|
967
|
+
}
|
|
968
|
+
reconcileVars(e, t) {
|
|
969
|
+
let n = this.parsedVars[e];
|
|
970
|
+
if (n) for (let r of Object.keys(n)) {
|
|
971
|
+
let n = t.get(r);
|
|
972
|
+
if (!n) continue;
|
|
973
|
+
let i = -1;
|
|
974
|
+
for (let t of n) if (t > e) {
|
|
975
|
+
i = t;
|
|
976
|
+
break;
|
|
977
|
+
}
|
|
978
|
+
if (i === -1) continue;
|
|
979
|
+
let [a, o] = [e, i], s = this.frames.findIndex((e) => e.ixs.start === a && e.ixs.stop === o), c = s === -1 ? this.createFrame(a, o) : this.frames[s];
|
|
980
|
+
c.interpVars[r] = B(r, a, o, this.parsedVars, this.options.colorSpace, this.options.hueMethod), s === -1 && this.frames.push(c);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
parse() {
|
|
984
|
+
this.frames = [], this.templateFrames.sort((e, t) => e.start.value - t.start.value), this.parsedVars = this.templateFrames.map((e) => {
|
|
985
|
+
let t = z(e.vars);
|
|
986
|
+
return Object.values(t).forEach((e) => {
|
|
987
|
+
e.setTargets(this.targets);
|
|
988
|
+
}), t;
|
|
989
|
+
});
|
|
990
|
+
for (let e = 0; e < this.templateFrames.length - 1; e++) this.frames.push(this.createFrame(e, e + 1));
|
|
991
|
+
let e = this.buildVarIndex();
|
|
992
|
+
return this.frames.forEach((t, n) => this.reconcileVars(n, e)), this.frames.sort((e, t) => e.time.start === t.time.start ? e.time.stop - t.time.stop : e.time.start - t.time.start), this.frames = this.frames.filter((e) => e.interpVars != null && Object.keys(e.interpVars).length > 0), this.frames.forEach((e) => {
|
|
993
|
+
e.flatVars = Object.entries(e.interpVars).reduce((e, [t, n]) => (e[t] = n.map((e) => e.value), e), {}), e.vars = oe(e.flatVars), e.allInterpVars = Object.values(e.interpVars).flat();
|
|
994
|
+
}), this;
|
|
995
|
+
}
|
|
996
|
+
setTimingFunction(e) {
|
|
997
|
+
return this.options.timingFunction = L(e) ?? u, this;
|
|
998
|
+
}
|
|
999
|
+
setIterationCount(e) {
|
|
1000
|
+
if (!e || e === "infinite" || e === "∞" || e === "Infinity") this.options.iterationCount = Infinity;
|
|
1001
|
+
else if (typeof e == "string") {
|
|
1002
|
+
let t = parseFloat(e.trim());
|
|
1003
|
+
if (isNaN(t) || t < 0) return this;
|
|
1004
|
+
this.options.iterationCount = t;
|
|
1005
|
+
} else {
|
|
1006
|
+
if (isNaN(e) || e < 0) return this;
|
|
1007
|
+
this.options.iterationCount = e;
|
|
1008
|
+
}
|
|
1009
|
+
return this;
|
|
1010
|
+
}
|
|
1011
|
+
setDuration(e) {
|
|
1012
|
+
typeof e == "string" && (e = v(e));
|
|
1013
|
+
let t = e ?? this.options.duration;
|
|
1014
|
+
if (!isFinite(t) || t <= 0) return this;
|
|
1015
|
+
let n = t / this.options.duration;
|
|
1016
|
+
for (let e = 0; e < this.frames.length; e++) {
|
|
1017
|
+
let t = this.frames[e];
|
|
1018
|
+
t.time.start *= n, t.time.stop *= n;
|
|
1019
|
+
}
|
|
1020
|
+
return this.options.duration = t, this;
|
|
1021
|
+
}
|
|
1022
|
+
setDelay(e) {
|
|
1023
|
+
return typeof e == "string" && (e = v(e)), this.options.delay = e ?? 0, this;
|
|
1024
|
+
}
|
|
1025
|
+
setDirection(e) {
|
|
1026
|
+
return this.options.direction = e ?? "normal", this.reversed = !1, (this.options.direction === "reverse" || this.options.direction === "alternate-reverse" && this.iteration % 2 == 0 || this.options.direction === "alternate" && this.iteration % 2 == 1) && (this.reversed = !0), this;
|
|
1027
|
+
}
|
|
1028
|
+
setFillMode(e) {
|
|
1029
|
+
return this.options.fillMode = e ?? "forwards", this;
|
|
1030
|
+
}
|
|
1031
|
+
setUseWAAPI(e) {
|
|
1032
|
+
return this.options.useWAAPI = e ?? !0, this;
|
|
1033
|
+
}
|
|
1034
|
+
setColorSpace(e) {
|
|
1035
|
+
return this.options.colorSpace = e ?? "oklab", this;
|
|
1036
|
+
}
|
|
1037
|
+
setHueMethod(e) {
|
|
1038
|
+
return e !== void 0 && (this.options.hueMethod = e), this;
|
|
1039
|
+
}
|
|
1040
|
+
setOptions(e) {
|
|
1041
|
+
return this.setTimingFunction(e.timingFunction), this.setDuration(e.duration), this.setIterationCount(e.iterationCount), this.setDelay(e.delay), this.setDirection(e.direction), this.setFillMode(e.fillMode), this.setUseWAAPI(e.useWAAPI), this.setColorSpace(e.colorSpace), this.setHueMethod(e.hueMethod), this;
|
|
1042
|
+
}
|
|
1043
|
+
reverse() {
|
|
1044
|
+
if (this.startTime !== void 0) {
|
|
1045
|
+
let e = this.t, t = this.options.duration - 2 * e;
|
|
1046
|
+
this.startTime -= t;
|
|
1047
|
+
}
|
|
1048
|
+
return this.reversed = !this.reversed, this;
|
|
1049
|
+
}
|
|
1050
|
+
fillForwards() {
|
|
1051
|
+
this.interpFrames(this.options.duration, !0);
|
|
1052
|
+
}
|
|
1053
|
+
fillBackwards() {
|
|
1054
|
+
this.interpFrames(0, !0);
|
|
1055
|
+
}
|
|
1056
|
+
at(e, t = !1) {
|
|
1057
|
+
let n = this.reversed;
|
|
1058
|
+
this.reversed = !1;
|
|
1059
|
+
let r = c(e, 0, 1) * this.options.duration, i = this.interpFrames(r, t);
|
|
1060
|
+
return this.reversed = n, i;
|
|
1061
|
+
}
|
|
1062
|
+
interpFrames(e, t = !1, n = {}) {
|
|
1063
|
+
e = this.reversed ? this.options.duration - e : e;
|
|
1064
|
+
let r = n;
|
|
1065
|
+
for (let e in r) delete r[e];
|
|
1066
|
+
let i = this.frames, a = i.length, o = w(i, e, (e) => e.time.start, (e) => e.time.stop);
|
|
1067
|
+
if (o === -1) return r;
|
|
1068
|
+
let s = (n) => {
|
|
1069
|
+
let { start: i, stop: a } = n.time, o = b(e, i, a, 0, 1), s = n.timingFunction(o);
|
|
1070
|
+
for (let e of n.allInterpVars) te(s, e);
|
|
1071
|
+
t && n.transform(this.unflatten ? n.vars : n.flatVars, e), Object.assign(r, n.flatVars);
|
|
1072
|
+
};
|
|
1073
|
+
for (let t = o; t >= 0; t--) {
|
|
1074
|
+
let n = i[t];
|
|
1075
|
+
if (e < n.time.start || e > n.time.stop) break;
|
|
1076
|
+
s(n);
|
|
1077
|
+
}
|
|
1078
|
+
for (let t = o + 1; t < a; t++) {
|
|
1079
|
+
let n = i[t];
|
|
1080
|
+
if (e < n.time.start || e > n.time.stop) break;
|
|
1081
|
+
s(n);
|
|
1082
|
+
}
|
|
1083
|
+
return r;
|
|
1084
|
+
}
|
|
1085
|
+
async onStart() {
|
|
1086
|
+
this.reversed = !1, (this.options.direction === "reverse" || this.options.direction === "alternate-reverse" && this.iteration % 2 == 0 || this.options.direction === "alternate" && this.iteration % 2 == 1) && this.reverse(), (this.options.fillMode === "backwards" || this.options.fillMode === "both") && this.fillBackwards(), this.options.delay > 0 && (this.paused = !0, await ie(this.options.delay), this.paused = !1), this.started = !0;
|
|
1087
|
+
}
|
|
1088
|
+
async onEnd() {
|
|
1089
|
+
this.options.fillMode === "forwards" || this.options.fillMode === "both" ? this.fillForwards() : (this.options.fillMode === "none" || this.options.fillMode === "backwards") && this.fillBackwards(), this.startTime = void 0, this.iteration >= this.options.iterationCount - 1 ? (this.done = !0, this.iteration = 0, this.dispatchAnimationEvent("animationend")) : (this.iteration += 1, this.dispatchAnimationEvent("animationiteration"));
|
|
1090
|
+
}
|
|
1091
|
+
async tick(e) {
|
|
1092
|
+
if (this.startTime === void 0 && (await this.onStart(), this.startTime = e + this.options.delay, this.dispatchAnimationEvent("animationstart")), this.paused && this.pausedTime === 0) return this.pausedTime = e, this.t;
|
|
1093
|
+
if (this.pausedTime > 0 && !this.paused) {
|
|
1094
|
+
let t = e - this.pausedTime;
|
|
1095
|
+
this.startTime += t, this.pausedTime = 0;
|
|
1096
|
+
}
|
|
1097
|
+
return this.t = e - this.startTime, this.t >= this.options.duration && (await this.onEnd(), this.t = this.options.duration), this.t;
|
|
1098
|
+
}
|
|
1099
|
+
async draw(e) {
|
|
1100
|
+
if (this.managed) throw Error("Animation.draw() called on a managed animation — the AnimationGroup owns the rAF loop. Call group.play()/pause()/stop() instead.");
|
|
1101
|
+
e = await this.tick(e), !this.paused && (this.interpFrames(e, !0), this.done ? (this.reset(), this.resolvePromise && this.resolvePromise()) : this.handleId = y(this._boundDraw));
|
|
1102
|
+
}
|
|
1103
|
+
_playRAF() {
|
|
1104
|
+
return new Promise((e) => {
|
|
1105
|
+
this.resolvePromise = e, this.handleId = y(this._boundDraw);
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
async _playWAAPI() {
|
|
1109
|
+
await ke(this), this.reset();
|
|
1110
|
+
}
|
|
1111
|
+
async play() {
|
|
1112
|
+
if (this.managed) throw Error("Animation.play() called on a managed animation — the AnimationGroup owns the rAF loop. Call group.play() instead.");
|
|
1113
|
+
if (this._playingPromise) return this._playingPromise;
|
|
1114
|
+
let e;
|
|
1115
|
+
if (this.options.useWAAPI) {
|
|
1116
|
+
let t = we(this);
|
|
1117
|
+
t.eligible ? (this.waapiIneligibleReason = void 0, e = this._playWAAPI()) : (this.waapiIneligibleReason = t.reason, e = this._playRAF());
|
|
1118
|
+
} else this.waapiIneligibleReason = void 0, e = this._playRAF();
|
|
1119
|
+
return this._playingPromise = e, e.finally(() => {
|
|
1120
|
+
this._playingPromise = null;
|
|
1121
|
+
}), e;
|
|
1122
|
+
}
|
|
1123
|
+
pause(e = !0) {
|
|
1124
|
+
return this.paused && e ? this.resume() : (this.started && (this.paused = !0), this);
|
|
1125
|
+
}
|
|
1126
|
+
resume() {
|
|
1127
|
+
return this.started && this.paused && (this.paused = !1, this.handleId = y(this._boundDraw)), this;
|
|
1128
|
+
}
|
|
1129
|
+
stop() {
|
|
1130
|
+
s(this.handleId), this.reset();
|
|
1131
|
+
}
|
|
1132
|
+
playing() {
|
|
1133
|
+
return !(!this.started || this.paused);
|
|
1134
|
+
}
|
|
1135
|
+
get effectiveT() {
|
|
1136
|
+
return this.reversed ? this.options.duration - this.t : this.t;
|
|
1137
|
+
}
|
|
1138
|
+
reset() {
|
|
1139
|
+
return this.done = !1, this.started = !1, this.paused = !1, this.reversed = !1, this.iteration = 0, this.startTime = void 0, this.pausedTime = 0, this.t = 0, this;
|
|
1140
|
+
}
|
|
1141
|
+
setTargets(...e) {
|
|
1142
|
+
return this.targets = e, this.frames.forEach((e) => {
|
|
1143
|
+
Object.values(e.interpVars).forEach((e) => {
|
|
1144
|
+
e.forEach(({ start: e, stop: t, value: n }) => {
|
|
1145
|
+
e.setTargets(this.targets), t.setTargets(this.targets), n.setTargets(this.targets);
|
|
1146
|
+
});
|
|
1147
|
+
});
|
|
1148
|
+
}), this;
|
|
1149
|
+
}
|
|
1150
|
+
group(...e) {
|
|
1151
|
+
return new M(this, ...e);
|
|
1152
|
+
}
|
|
1153
|
+
}, Me = class extends $ {
|
|
1154
|
+
constructor(e, ...t) {
|
|
1155
|
+
super(e, t), this.unflatten = !1;
|
|
1156
|
+
}
|
|
1157
|
+
fromVars(e, t) {
|
|
1158
|
+
this.unflatten = t != null, t ??= this.transform.bind(this);
|
|
1159
|
+
for (let n = 0; n < e.length; n++) {
|
|
1160
|
+
let r = e[n], i = Math.round(n / (e.length - 1) * 100);
|
|
1161
|
+
this.addFrame(i, r, t);
|
|
1162
|
+
}
|
|
1163
|
+
return this.parse(), this;
|
|
1164
|
+
}
|
|
1165
|
+
fromKeyframes(e, t) {
|
|
1166
|
+
this.unflatten = t != null, t ??= this.transform.bind(this), ee(e) && (e = new Map(Object.entries(e)));
|
|
1167
|
+
let n = e instanceof Map ? e.entries() : Object.entries(e);
|
|
1168
|
+
for (let [e, r] of n) this.addFrame(e, r, t);
|
|
1169
|
+
return this.parse(), this;
|
|
1170
|
+
}
|
|
1171
|
+
propertyRegistry = /* @__PURE__ */ new Map();
|
|
1172
|
+
fromString(e, t) {
|
|
1173
|
+
this.unflatten = t != null, t ??= this.transform.bind(this);
|
|
1174
|
+
let n = O(e);
|
|
1175
|
+
this.propertyRegistry = n.properties;
|
|
1176
|
+
for (let [e, r] of n.keyframes.entries()) {
|
|
1177
|
+
let i = Object.fromEntries(Object.entries(r).map(([e, t]) => [e, Ae(t) ? t.clone() : t])), a = n.timingFunctions.get(e), o = a ? L(a) : void 0;
|
|
1178
|
+
this.addFrame(e, i, t, o);
|
|
1179
|
+
}
|
|
1180
|
+
return this.parse(), this;
|
|
1181
|
+
}
|
|
1182
|
+
transform(e) {
|
|
1183
|
+
H(e, this.targets);
|
|
1184
|
+
}
|
|
1288
1185
|
};
|
|
1186
|
+
//#endregion
|
|
1187
|
+
export { $ as Animation, M as AnimationGroup, Me as CSSKeyframesAnimation, le as DIRECTIONS, ve as ElementMorph, ue as FILL_MODES, Se as ManualTimeline, U as NumericAnimation, xe as ScrollTimeline, G as SmoothProgress, q as SpringProgress, Y as Timeline, A as defaultLayerConfig, k as defaultOptions, Q as getAnimationId, L as getTimingFunction, O as resolveKeyframes, ge as springLinearStops, _e as springTimingFunction };
|