@mkbabb/keyframes.js 1.2.0 → 1.2.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/keyframes.d.ts +221 -4
- package/dist/keyframes.js +883 -632
- package/package.json +5 -8
package/dist/keyframes.js
CHANGED
|
@@ -1,113 +1,123 @@
|
|
|
1
|
-
import { CSSFunction as
|
|
2
|
-
import { CSSCubicBezier as
|
|
3
|
-
import { string as g, all as
|
|
4
|
-
|
|
1
|
+
import { CSSFunction as tt, ValueUnit as f, CSSValueUnit as A, identifier as j, hyphenToCamelCase as yt, ValueArray as T, number as wt, camelCaseToHyphen as Vt, memoize as V, tryParse as F, FunctionValue as U, easeInOutCubic as et, lerp as I, requestAnimationFrame as w, cancelAnimationFrame as k, parseCSSValueUnit as st, unpackMatrixValues as Tt, normalizeColorUnits as bt, COMPUTED_UNITS as $, convertToDPI as St, convertToMs as it, convertToDegrees as vt, convertToPixels as Ft, RESOLUTION_UNITS as It, TIME_UNITS as Pt, ANGLE_UNITS as Et, LENGTH_UNITS as Ct, timingFunctions as rt, flattenObject as nt, unflattenObjectToString as ot, clamp as E, scale as at, seekPreviousValue as B, unflattenObject as Ot, sleep as _t, isObject as kt } from "@mkbabb/value.js";
|
|
2
|
+
import { CSSCubicBezier as Ye, bezierPresets as Be, bounceInEase as Re, bounceInEaseHalf as We, bounceInOutEase as Le, bounceOutEase as Xe, bounceOutEaseHalf as He, cancelAnimationFrame as Ge, clamp as qe, cubicBezier as Ze, cubicBezierToSVG as Qe, cubicBezierToString as Je, deCasteljau as ts, easeInBounce as es, easeInCirc as ss, easeInCubic as is, easeInExpo as rs, easeInOutCirc as ns, easeInOutCubic as os, easeInOutExpo as as, easeInOutQuad as us, easeInOutSine as ls, easeInQuad as cs, easeInSine as hs, easeOutCirc as fs, easeOutCubic as ps, easeOutExpo as ms, easeOutQuad as ds, easeOutSine as gs, interpBezier as ys, jumpTerms as ws, lerp as Vs, linear as Ts, logerp as bs, requestAnimationFrame as Ss, scale as vs, sleep as Fs, smoothStep3 as Is, stepEnd as Ps, stepStart as Es, steppedEase as Cs, timingFunctions as Os } from "@mkbabb/value.js";
|
|
3
|
+
import { string as g, all as D, regex as ut, any as C, whitespace as Mt } from "@mkbabb/parse-that";
|
|
4
|
+
function lt(s, t, e, i) {
|
|
5
|
+
let r = 0, o = s.length - 1;
|
|
6
|
+
for (; r <= o; ) {
|
|
7
|
+
const n = r + o >> 1, u = s[n];
|
|
8
|
+
if (t < e(u)) o = n - 1;
|
|
9
|
+
else if (t > i(u)) r = n + 1;
|
|
10
|
+
else return n;
|
|
11
|
+
}
|
|
12
|
+
return -1;
|
|
13
|
+
}
|
|
14
|
+
const At = (s) => s.replace(/\/\*[\s\S]*?\*\//g, ""), xt = (s) => s.replace(/\s*!important/gi, ""), N = (s) => xt(At(s));
|
|
5
15
|
g("(");
|
|
6
16
|
g(")");
|
|
7
|
-
const
|
|
17
|
+
const jt = g(";"), Ut = g(":"), K = g("{"), z = g("}"), $t = g(","), Dt = g("."), d = Mt, Nt = (s) => {
|
|
8
18
|
const t = [];
|
|
9
|
-
for (const
|
|
10
|
-
if (
|
|
11
|
-
t.push(
|
|
19
|
+
for (const e of s.flat(1 / 0)) {
|
|
20
|
+
if (e instanceof f || e instanceof U) {
|
|
21
|
+
t.push(e);
|
|
12
22
|
continue;
|
|
13
23
|
}
|
|
14
24
|
throw new TypeError(
|
|
15
|
-
`Expected parsed CSS value node, got ${typeof
|
|
25
|
+
`Expected parsed CSS value node, got ${typeof e}.`
|
|
16
26
|
);
|
|
17
27
|
}
|
|
18
28
|
return t;
|
|
19
|
-
},
|
|
20
|
-
(
|
|
21
|
-
const t =
|
|
22
|
-
`),
|
|
23
|
-
return new f(
|
|
29
|
+
}, Kt = tt.Function, zt = D(K, ut(/[^{}]+/), z).map(
|
|
30
|
+
(s) => {
|
|
31
|
+
const t = s.join(`
|
|
32
|
+
`), e = JSON.parse(t);
|
|
33
|
+
return new f(e, "json");
|
|
24
34
|
}
|
|
25
|
-
), Y =
|
|
35
|
+
), Y = C(
|
|
26
36
|
A.Value,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
ut(/[^\(\)\{\}\s,;]+/).map((
|
|
30
|
-
).trim(
|
|
31
|
-
j.skip(
|
|
32
|
-
|
|
33
|
-
).map((
|
|
34
|
-
const [t,
|
|
35
|
-
return
|
|
36
|
-
[t]:
|
|
37
|
+
Kt,
|
|
38
|
+
zt,
|
|
39
|
+
ut(/[^\(\)\{\}\s,;]+/).map((s) => new f(s))
|
|
40
|
+
).trim(d), Yt = Y.sepBy(d), Bt = D(
|
|
41
|
+
j.skip(Ut).trim(d).map((s) => yt(s)),
|
|
42
|
+
Yt.skip(jt.opt()).trim(d)
|
|
43
|
+
).map((s) => {
|
|
44
|
+
const [t, e] = s, i = new T(...Nt(e));
|
|
45
|
+
return i.setProperty(t), {
|
|
46
|
+
[t]: i
|
|
37
47
|
};
|
|
38
|
-
}), Rt =
|
|
39
|
-
A.TimePercentage.trim(
|
|
40
|
-
|
|
41
|
-
), Wt = Rt.sepBy(
|
|
42
|
-
([
|
|
43
|
-
),
|
|
44
|
-
Lt.next(
|
|
45
|
-
|
|
46
|
-
).map((
|
|
47
|
-
(t,
|
|
48
|
-
for (const [
|
|
49
|
-
t.has(
|
|
48
|
+
}), Rt = C(
|
|
49
|
+
A.TimePercentage.trim(d).map((s) => s.toString()),
|
|
50
|
+
wt.map((s) => `${s}%`)
|
|
51
|
+
), Wt = Rt.sepBy($t).trim(d), ct = Bt.many().trim(d).wrap(K, z).map((s) => Object.assign({}, ...s)), Lt = g("@keyframes").trim(d).next(j), R = D(Wt, ct).map(
|
|
52
|
+
([s, t]) => s.reduce((e, i) => (e.set(i, t), e), /* @__PURE__ */ new Map())
|
|
53
|
+
), ht = C(
|
|
54
|
+
Lt.next(R.many(1).trim(d).wrap(K, z).trim(d)),
|
|
55
|
+
R.many(1).trim(d)
|
|
56
|
+
).map((s) => s.reduce(
|
|
57
|
+
(t, e) => {
|
|
58
|
+
for (const [i, r] of e)
|
|
59
|
+
t.has(i) ? t.set(i, { ...t.get(i), ...r }) : t.set(i, r);
|
|
50
60
|
return t;
|
|
51
61
|
},
|
|
52
62
|
/* @__PURE__ */ new Map()
|
|
53
|
-
)),
|
|
63
|
+
)), Xt = Dt.trim(d).next(j).trim(d), Ht = ct.map((s) => {
|
|
54
64
|
const t = {};
|
|
55
|
-
for (const [
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
58
|
-
t[
|
|
65
|
+
for (const [e, i] of Object.entries(s))
|
|
66
|
+
if (e.includes("animation")) {
|
|
67
|
+
const r = e.replace(/^animation/i, "").replace(/^\w/, (n) => n.toLowerCase()), o = Vt(i.toString());
|
|
68
|
+
t[r] = o, delete s[e];
|
|
59
69
|
}
|
|
60
70
|
return {
|
|
61
71
|
options: t,
|
|
62
|
-
values:
|
|
72
|
+
values: s
|
|
63
73
|
};
|
|
64
|
-
}),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
keyframes:
|
|
74
|
+
}), Gt = Xt.next(Ht), qt = C(
|
|
75
|
+
Gt.map((s) => s),
|
|
76
|
+
ht.map((s) => ({
|
|
77
|
+
keyframes: s
|
|
68
78
|
}))
|
|
69
|
-
),
|
|
79
|
+
), Zt = qt.sepBy(d).map((s) => Object.assign({}, ...s)), W = {
|
|
70
80
|
Value: Y,
|
|
71
|
-
FunctionArgs:
|
|
72
|
-
},
|
|
73
|
-
(
|
|
74
|
-
),
|
|
75
|
-
(
|
|
81
|
+
FunctionArgs: tt.FunctionArgs
|
|
82
|
+
}, Qt = V(
|
|
83
|
+
(s) => F(Y, N(s))
|
|
84
|
+
), Jt = V(
|
|
85
|
+
(s) => F(ht, N(s))
|
|
76
86
|
);
|
|
77
|
-
|
|
87
|
+
V((s) => {
|
|
78
88
|
const t = F(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
),
|
|
89
|
+
Zt,
|
|
90
|
+
N(s)
|
|
91
|
+
), e = {
|
|
82
92
|
keyframes: t.keyframes
|
|
83
93
|
};
|
|
84
|
-
return t.options != null && (
|
|
94
|
+
return t.options != null && (e.options = t.options), t.values != null && (e.values = t.values), e;
|
|
85
95
|
});
|
|
86
|
-
|
|
87
|
-
(
|
|
96
|
+
V(
|
|
97
|
+
(s) => F(A.Percentage, String(s)).valueOf()
|
|
88
98
|
);
|
|
89
|
-
const
|
|
99
|
+
const L = V((s) => F(
|
|
90
100
|
A.Time.map((t) => t.unit === "ms" ? t.value : t.unit === "s" ? t.value * 1e3 : t.value),
|
|
91
|
-
|
|
101
|
+
s
|
|
92
102
|
));
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
103
|
+
V((s) => s >= 5e3 ? `${s / 1e3}s` : `${s}ms`);
|
|
104
|
+
V((s) => s === 1 / 0 ? "infinite" : String(s));
|
|
105
|
+
const te = {
|
|
96
106
|
duration: 1e3,
|
|
97
107
|
delay: 0,
|
|
98
108
|
iterationCount: 1,
|
|
99
109
|
direction: "normal",
|
|
100
110
|
fillMode: "forwards",
|
|
101
|
-
timingFunction:
|
|
111
|
+
timingFunction: et,
|
|
102
112
|
useWAAPI: !0,
|
|
103
113
|
colorSpace: "oklab"
|
|
104
|
-
},
|
|
114
|
+
}, ee = {
|
|
105
115
|
zIndex: 0,
|
|
106
116
|
weight: 1,
|
|
107
117
|
blendMode: "replace",
|
|
108
118
|
enabled: !0
|
|
109
|
-
},
|
|
110
|
-
class
|
|
119
|
+
}, _ = (s) => typeof s != "object" || s == null ? !1 : "value" in s && typeof s.value == "number";
|
|
120
|
+
class se {
|
|
111
121
|
animations = {};
|
|
112
122
|
transform;
|
|
113
123
|
superKey;
|
|
@@ -118,160 +128,239 @@ class Jt {
|
|
|
118
128
|
lastTickTime = 0;
|
|
119
129
|
handleId = void 0;
|
|
120
130
|
resolvePromise = null;
|
|
131
|
+
/**
|
|
132
|
+
* Pre-bound draw callback — allocated once in constructor to avoid
|
|
133
|
+
* creating a new closure on every requestAnimationFrame reschedule.
|
|
134
|
+
*/
|
|
135
|
+
_boundDraw;
|
|
136
|
+
/**
|
|
137
|
+
* Cached entries array, sorted by layer zIndex. Rebuilt on demand
|
|
138
|
+
* via dirty flag to avoid Object.values() allocation on every frame.
|
|
139
|
+
*/
|
|
140
|
+
_entries = [];
|
|
141
|
+
_entriesDirty = !0;
|
|
121
142
|
constructor(...t) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
143
|
+
this._boundDraw = this.draw.bind(this);
|
|
144
|
+
const e = [];
|
|
145
|
+
for (const i of t) {
|
|
146
|
+
let r, o;
|
|
147
|
+
i instanceof gt ? r = i : (r = i.animation, o = i.layer), this.transform ??= r.frames[0].transform;
|
|
148
|
+
const n = x(r);
|
|
149
|
+
this.animations[n] = {
|
|
128
150
|
values: {},
|
|
129
|
-
animation:
|
|
130
|
-
layer: { ...
|
|
131
|
-
},
|
|
151
|
+
animation: r,
|
|
152
|
+
layer: { ...ee, ...o }
|
|
153
|
+
}, r.managed = !0, e.push(r);
|
|
132
154
|
}
|
|
133
|
-
this.singleTarget =
|
|
134
|
-
(
|
|
135
|
-
);
|
|
155
|
+
this.singleTarget = e.every(
|
|
156
|
+
(i) => i.targets[0] === e[0]?.targets[0]
|
|
157
|
+
), this.invalidateEntries();
|
|
158
|
+
}
|
|
159
|
+
// ── Entry cache ──────────────────────────────────────────────────
|
|
160
|
+
/**
|
|
161
|
+
* Returns the animation entries sorted by layer zIndex.
|
|
162
|
+
* Uses dirty-flag caching — only rebuilds when the animations object
|
|
163
|
+
* or layer configs are mutated. All hot-path iteration (tick, draw,
|
|
164
|
+
* transformFramesGrouped) uses this instead of Object.values().
|
|
165
|
+
*/
|
|
166
|
+
getEntries() {
|
|
167
|
+
return this._entriesDirty && (this._entries = Object.values(this.animations), this._entries.sort((t, e) => t.layer.zIndex - e.layer.zIndex), this._entriesDirty = !1), this._entries;
|
|
136
168
|
}
|
|
169
|
+
/** Mark entries cache stale. Called at all mutation boundaries. */
|
|
170
|
+
invalidateEntries() {
|
|
171
|
+
this._entriesDirty = !0;
|
|
172
|
+
}
|
|
173
|
+
// ── Setup ────────────────────────────────────────────────────────
|
|
137
174
|
setSuperKey(t) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
175
|
+
this.superKey = t;
|
|
176
|
+
for (const e of this.getEntries())
|
|
177
|
+
e.animation.superKey = t;
|
|
178
|
+
return this;
|
|
141
179
|
}
|
|
142
180
|
setTargets(...t) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
(
|
|
148
|
-
);
|
|
149
|
-
return this.singleTarget = s.every(
|
|
150
|
-
(n) => n.targets[0] === s[0]?.targets[0]
|
|
181
|
+
const e = this.getEntries();
|
|
182
|
+
for (const i of e)
|
|
183
|
+
i.animation.setTargets(...t);
|
|
184
|
+
return this.singleTarget = e.every(
|
|
185
|
+
(i) => i.animation.targets[0] === e[0]?.animation.targets[0]
|
|
151
186
|
), this;
|
|
152
187
|
}
|
|
188
|
+
// ── Lifecycle hooks ──────────────────────────────────────────────
|
|
153
189
|
onStart() {
|
|
154
190
|
return this.started = !0, this;
|
|
155
191
|
}
|
|
156
192
|
onEnd() {
|
|
157
193
|
return this;
|
|
158
194
|
}
|
|
195
|
+
// ── Frame rendering ──────────────────────────────────────────────
|
|
196
|
+
/**
|
|
197
|
+
* Composite all animation values into a single grouped transform.
|
|
198
|
+
* Called per-frame for single-target groups. Applies layer blending
|
|
199
|
+
* (replace / add / weighted) in zIndex order, then calls the group
|
|
200
|
+
* transform function with the merged values.
|
|
201
|
+
*/
|
|
159
202
|
transformFramesGrouped(t) {
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
Object.assign(a, l);
|
|
203
|
+
const e = {}, i = this.getEntries();
|
|
204
|
+
let r = !0;
|
|
205
|
+
for (const o of i) {
|
|
206
|
+
const { animation: n, values: u, layer: a } = o;
|
|
207
|
+
if (r = r && n.done, !a.enabled) continue;
|
|
208
|
+
if (!(n.done || n.paused)) {
|
|
209
|
+
const l = n.interpFrames(n.t, !1);
|
|
210
|
+
Object.assign(u, l);
|
|
169
211
|
}
|
|
170
|
-
const c =
|
|
171
|
-
Object.entries(
|
|
172
|
-
([l]) =>
|
|
212
|
+
const c = a.properties ? Object.fromEntries(
|
|
213
|
+
Object.entries(u).filter(
|
|
214
|
+
([l]) => a.properties.has(l)
|
|
173
215
|
)
|
|
174
|
-
) :
|
|
175
|
-
switch (
|
|
216
|
+
) : u;
|
|
217
|
+
switch (a.blendMode) {
|
|
176
218
|
case "replace":
|
|
177
|
-
Object.assign(
|
|
219
|
+
Object.assign(e, c);
|
|
178
220
|
break;
|
|
179
221
|
case "add":
|
|
180
222
|
for (const [l, h] of Object.entries(c))
|
|
181
|
-
if (l in
|
|
182
|
-
const
|
|
183
|
-
|
|
223
|
+
if (l in e) {
|
|
224
|
+
const m = e[l], p = h;
|
|
225
|
+
_(m) && _(p) ? m.value = m.value + p.value : e[l] = h;
|
|
184
226
|
} else
|
|
185
|
-
|
|
227
|
+
e[l] = h;
|
|
186
228
|
break;
|
|
187
229
|
case "weighted":
|
|
188
230
|
for (const [l, h] of Object.entries(c))
|
|
189
|
-
if (l in
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
231
|
+
if (l in e && a.weight < 1) {
|
|
232
|
+
const m = e[l], p = h;
|
|
233
|
+
_(m) && _(p) ? m.value = I(
|
|
234
|
+
a.weight,
|
|
235
|
+
m.value,
|
|
194
236
|
p.value
|
|
195
|
-
) :
|
|
237
|
+
) : e[l] = h;
|
|
196
238
|
} else
|
|
197
|
-
|
|
239
|
+
e[l] = h;
|
|
198
240
|
break;
|
|
199
241
|
}
|
|
200
242
|
}
|
|
201
|
-
return this.done =
|
|
243
|
+
return this.done = r, this.transform(e, t), e;
|
|
202
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* Render the current animation state as a static frame.
|
|
247
|
+
* Called on pause to ensure the visual matches the exact pause moment.
|
|
248
|
+
* Handles both single-target (grouped blending) and multi-target
|
|
249
|
+
* (per-child interpFrames) paths.
|
|
250
|
+
*/
|
|
251
|
+
renderPauseFrame() {
|
|
252
|
+
const t = this.getEntries(), e = this.lastTickTime || performance.now();
|
|
253
|
+
for (const i of t) {
|
|
254
|
+
const r = i.animation.interpFrames(i.animation.t, !1);
|
|
255
|
+
this.singleTarget && Object.assign(i.values, r);
|
|
256
|
+
}
|
|
257
|
+
if (this.singleTarget)
|
|
258
|
+
this.transformFramesGrouped(e);
|
|
259
|
+
else
|
|
260
|
+
for (const i of t)
|
|
261
|
+
i.animation.interpFrames(i.animation.t, !0);
|
|
262
|
+
}
|
|
263
|
+
// ── Playback loop ────────────────────────────────────────────────
|
|
264
|
+
/**
|
|
265
|
+
* Advance all child animations to timestamp `t`.
|
|
266
|
+
* Awaits all child tick() promises so deferred state updates
|
|
267
|
+
* (startTime, this.t) resolve before interpFrames reads them.
|
|
268
|
+
*/
|
|
203
269
|
async tick(t) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
270
|
+
this.lastTickTime = t, this.started || this.onStart();
|
|
271
|
+
const e = [];
|
|
272
|
+
for (const i of this.getEntries()) {
|
|
273
|
+
const r = i.animation;
|
|
274
|
+
(!r.paused || r.pausedTime === 0) && e.push(r.tick(t));
|
|
275
|
+
}
|
|
276
|
+
return await Promise.all(e), this.done && this.onEnd(), this;
|
|
209
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Main animation frame callback. Ticks all children, then renders
|
|
280
|
+
* (single-target: grouped blending; multi-target: per-child).
|
|
281
|
+
* Reschedules itself via rAF until done.
|
|
282
|
+
*/
|
|
210
283
|
async draw(t) {
|
|
211
|
-
await this.tick(t), !this.paused
|
|
284
|
+
if (await this.tick(t), !this.paused) {
|
|
285
|
+
if (this.singleTarget)
|
|
286
|
+
this.transformFramesGrouped(t);
|
|
287
|
+
else {
|
|
288
|
+
let e = !0;
|
|
289
|
+
for (const i of this.getEntries())
|
|
290
|
+
i.animation.interpFrames(i.animation.t, !0), e = e && i.animation.done;
|
|
291
|
+
this.done = e;
|
|
292
|
+
}
|
|
293
|
+
this.done ? (this.reset(), this.resolvePromise && this.resolvePromise()) : this.handleId = w(this._boundDraw);
|
|
294
|
+
}
|
|
212
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* Start the animation group. Returns a promise that resolves
|
|
298
|
+
* when all child animations complete (or on explicit stop/reset).
|
|
299
|
+
*/
|
|
213
300
|
async play() {
|
|
214
301
|
return new Promise((t) => {
|
|
215
|
-
this.resolvePromise = t, this.handleId =
|
|
302
|
+
this.resolvePromise = t, this.handleId = w(this._boundDraw);
|
|
216
303
|
});
|
|
217
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Toggle pause state. Calling pause() when playing pauses; calling
|
|
307
|
+
* pause() when paused resumes. (Toggle semantics preserved for
|
|
308
|
+
* backward compatibility with demo's toggleAnimationGroup.)
|
|
309
|
+
*
|
|
310
|
+
* On pause: explicitly cancels the rAF loop and renders a final
|
|
311
|
+
* frame snapshot so the visual matches the exact pause moment.
|
|
312
|
+
* On resume: re-registers the rAF loop.
|
|
313
|
+
*/
|
|
218
314
|
pause() {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
}
|
|
315
|
+
if (!this.started) return this;
|
|
316
|
+
this.paused = !this.paused;
|
|
317
|
+
const t = this.lastTickTime || performance.now();
|
|
318
|
+
for (const e of this.getEntries()) {
|
|
319
|
+
const i = e.animation;
|
|
320
|
+
this.paused ? (i.pause(!1), i.pausedTime === 0 && (i.pausedTime = t)) : i.paused = !1;
|
|
233
321
|
}
|
|
234
|
-
return
|
|
322
|
+
return this.paused ? (k(this.handleId), this.handleId = void 0, this.renderPauseFrame()) : this.handleId = w(this._boundDraw), this;
|
|
235
323
|
}
|
|
236
324
|
reset() {
|
|
237
|
-
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
}
|
|
325
|
+
for (const t of this.getEntries()) {
|
|
326
|
+
const e = t.animation;
|
|
327
|
+
e.started && e.frames.length > 0 && e.interpFrames(0, !0), e.managed = !1, e.reset();
|
|
328
|
+
}
|
|
329
|
+
return this.started = !1, this.done = !1, this.paused = !1, this.lastTickTime = 0, this;
|
|
241
330
|
}
|
|
242
331
|
stop() {
|
|
243
|
-
return
|
|
332
|
+
return k(this.handleId), this.handleId = void 0, this.reset(), this;
|
|
244
333
|
}
|
|
245
334
|
playing() {
|
|
246
335
|
return !(!this.started || this.paused);
|
|
247
336
|
}
|
|
248
337
|
forcePause() {
|
|
249
|
-
this.paused = !0
|
|
338
|
+
this.paused = !0;
|
|
339
|
+
for (const t of this.getEntries())
|
|
250
340
|
t.animation.paused = !0;
|
|
251
|
-
});
|
|
252
341
|
}
|
|
253
342
|
forcePlay() {
|
|
254
|
-
this.paused = !1
|
|
343
|
+
this.paused = !1;
|
|
344
|
+
for (const t of this.getEntries())
|
|
255
345
|
t.animation.paused = !1;
|
|
256
|
-
});
|
|
257
346
|
}
|
|
258
|
-
//
|
|
347
|
+
// ── Layer management API ─────────────────────────────────────────
|
|
259
348
|
/** Set layer config for an animation by name or reference. Chainable. */
|
|
260
|
-
setLayerConfig(t,
|
|
261
|
-
const
|
|
262
|
-
return
|
|
349
|
+
setLayerConfig(t, e) {
|
|
350
|
+
const i = typeof t == "string" ? t : x(t), r = this.animations[i];
|
|
351
|
+
return r && (Object.assign(r.layer, e), this.invalidateEntries()), this;
|
|
263
352
|
}
|
|
264
353
|
/** Convenience toggle for enabling/disabling a layer. Chainable. */
|
|
265
|
-
setLayerEnabled(t,
|
|
266
|
-
return this.setLayerConfig(t, { enabled:
|
|
354
|
+
setLayerEnabled(t, e) {
|
|
355
|
+
return this.setLayerConfig(t, { enabled: e });
|
|
267
356
|
}
|
|
268
357
|
/** Read the layer config for an animation. */
|
|
269
358
|
getLayerConfig(t) {
|
|
270
|
-
const
|
|
271
|
-
return this.animations[
|
|
359
|
+
const e = typeof t == "string" ? t : x(t);
|
|
360
|
+
return this.animations[e]?.layer;
|
|
272
361
|
}
|
|
273
362
|
}
|
|
274
|
-
const
|
|
363
|
+
const ie = /* @__PURE__ */ new Set([
|
|
275
364
|
"scaleX",
|
|
276
365
|
"scaleY",
|
|
277
366
|
"scaleZ",
|
|
@@ -288,47 +377,47 @@ const te = /* @__PURE__ */ new Set([
|
|
|
288
377
|
"perspectiveY",
|
|
289
378
|
"perspectiveZ",
|
|
290
379
|
"perspectiveW"
|
|
291
|
-
]),
|
|
292
|
-
|
|
293
|
-
),
|
|
294
|
-
if (typeof
|
|
380
|
+
]), re = (s) => typeof s == "string" && Ct.includes(s), ne = (s) => typeof s == "string" && Et.includes(s), oe = (s) => typeof s == "string" && Pt.includes(s), ae = (s) => typeof s == "string" && It.includes(s), X = (s) => typeof s == "string" && $.includes(s), ue = (s) => ie.has(
|
|
381
|
+
s
|
|
382
|
+
), le = (s, t) => {
|
|
383
|
+
if (typeof s != "number" || !Number.isFinite(s))
|
|
295
384
|
throw new TypeError(
|
|
296
|
-
`Expected numeric ${t}, got ${String(
|
|
385
|
+
`Expected numeric ${t}, got ${String(s)}.`
|
|
297
386
|
);
|
|
298
|
-
return
|
|
299
|
-
}, H = (
|
|
300
|
-
if (
|
|
387
|
+
return s;
|
|
388
|
+
}, H = (s) => {
|
|
389
|
+
if (s.unit !== "color")
|
|
301
390
|
throw new TypeError("Expected a color ValueUnit.");
|
|
302
|
-
return
|
|
303
|
-
},
|
|
304
|
-
let
|
|
305
|
-
const
|
|
306
|
-
let t =
|
|
307
|
-
return t === void 0 && (t =
|
|
308
|
-
},
|
|
309
|
-
(
|
|
391
|
+
return s;
|
|
392
|
+
}, ce = (s) => s, G = /* @__PURE__ */ new WeakMap();
|
|
393
|
+
let he = 0;
|
|
394
|
+
const fe = (s) => {
|
|
395
|
+
let t = G.get(s);
|
|
396
|
+
return t === void 0 && (t = he++, G.set(s, t)), t;
|
|
397
|
+
}, q = V(
|
|
398
|
+
(s, t) => (() => {
|
|
310
399
|
if (!t)
|
|
311
|
-
return
|
|
312
|
-
if (
|
|
313
|
-
const
|
|
314
|
-
|
|
400
|
+
return s;
|
|
401
|
+
if (s.unit === "var") {
|
|
402
|
+
const r = getComputedStyle(t).getPropertyValue(
|
|
403
|
+
s.value
|
|
315
404
|
);
|
|
316
|
-
return st(
|
|
405
|
+
return st(r);
|
|
317
406
|
}
|
|
318
|
-
if (
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
const
|
|
322
|
-
|
|
407
|
+
if (s.unit === "calc" && s.property && s.subProperty && s.value && t) {
|
|
408
|
+
const r = ce(t.style), o = r[s.property] ?? "", n = s.subProperty ? `${s.subProperty}(${s.toString()})` : s.toString();
|
|
409
|
+
r[s.property] = n;
|
|
410
|
+
const u = getComputedStyle(t).getPropertyValue(
|
|
411
|
+
s.property
|
|
323
412
|
);
|
|
324
|
-
|
|
325
|
-
const
|
|
326
|
-
if (
|
|
327
|
-
return
|
|
328
|
-
if (
|
|
329
|
-
const c =
|
|
330
|
-
if (
|
|
331
|
-
const l = c[
|
|
413
|
+
r[s.property] = o;
|
|
414
|
+
const a = Qt(u);
|
|
415
|
+
if (a instanceof f)
|
|
416
|
+
return a;
|
|
417
|
+
if (a.name.startsWith("matrix")) {
|
|
418
|
+
const c = Tt(a);
|
|
419
|
+
if (ue(s.subProperty)) {
|
|
420
|
+
const l = c[s.subProperty];
|
|
332
421
|
if (l != null)
|
|
333
422
|
return new f(l, "px", [
|
|
334
423
|
"length",
|
|
@@ -337,79 +426,79 @@ const le = (e) => {
|
|
|
337
426
|
}
|
|
338
427
|
}
|
|
339
428
|
}
|
|
340
|
-
return
|
|
341
|
-
})().coalesce(
|
|
429
|
+
return s;
|
|
430
|
+
})().coalesce(s),
|
|
342
431
|
{
|
|
343
|
-
keyFn: (
|
|
432
|
+
keyFn: (s, t) => `${s.toString()}-${t ? fe(t) : "null"}`,
|
|
344
433
|
// Don't cache when the element is disconnected (e.g. inside a Teleport
|
|
345
434
|
// defer DocumentFragment). Layout-dependent units like cqw/vh resolve
|
|
346
435
|
// to 0 without a live DOM context.
|
|
347
|
-
shouldCache: (
|
|
348
|
-
}
|
|
349
|
-
),
|
|
350
|
-
if (
|
|
351
|
-
return
|
|
352
|
-
const
|
|
353
|
-
const
|
|
354
|
-
switch (
|
|
436
|
+
shouldCache: (s, t, e) => !e || e.isConnected
|
|
437
|
+
}
|
|
438
|
+
), pe = (s, t, e = !1) => {
|
|
439
|
+
if (s?.superType?.[0] !== t?.superType?.[0])
|
|
440
|
+
return e ? [s, t] : [s.clone(), t.clone()];
|
|
441
|
+
const i = (n) => {
|
|
442
|
+
const u = n?.superType?.[0], a = le(n.value, "ValueUnit");
|
|
443
|
+
switch (u) {
|
|
355
444
|
case "length":
|
|
356
|
-
if (!
|
|
445
|
+
if (!re(n.unit))
|
|
357
446
|
throw new TypeError(
|
|
358
|
-
`Unsupported length unit: ${String(
|
|
447
|
+
`Unsupported length unit: ${String(n.unit)}`
|
|
359
448
|
);
|
|
360
449
|
return {
|
|
361
|
-
value:
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
450
|
+
value: Ft(
|
|
451
|
+
a,
|
|
452
|
+
n.unit,
|
|
453
|
+
n.targets?.[0]
|
|
365
454
|
),
|
|
366
455
|
unit: "px"
|
|
367
456
|
};
|
|
368
457
|
case "angle":
|
|
369
|
-
if (!
|
|
458
|
+
if (!ne(n.unit))
|
|
370
459
|
throw new TypeError(
|
|
371
|
-
`Unsupported angle unit: ${String(
|
|
460
|
+
`Unsupported angle unit: ${String(n.unit)}`
|
|
372
461
|
);
|
|
373
462
|
return {
|
|
374
|
-
value:
|
|
463
|
+
value: vt(a, n.unit),
|
|
375
464
|
unit: "deg"
|
|
376
465
|
};
|
|
377
466
|
case "time":
|
|
378
|
-
if (!
|
|
467
|
+
if (!oe(n.unit))
|
|
379
468
|
throw new TypeError(
|
|
380
|
-
`Unsupported time unit: ${String(
|
|
469
|
+
`Unsupported time unit: ${String(n.unit)}`
|
|
381
470
|
);
|
|
382
471
|
return {
|
|
383
|
-
value:
|
|
472
|
+
value: it(a, n.unit),
|
|
384
473
|
unit: "ms"
|
|
385
474
|
};
|
|
386
475
|
case "resolution":
|
|
387
|
-
if (!
|
|
476
|
+
if (!ae(n.unit))
|
|
388
477
|
throw new TypeError(
|
|
389
|
-
`Unsupported resolution unit: ${String(
|
|
478
|
+
`Unsupported resolution unit: ${String(n.unit)}`
|
|
390
479
|
);
|
|
391
480
|
return {
|
|
392
|
-
value:
|
|
481
|
+
value: St(a, n.unit),
|
|
393
482
|
unit: "dpi"
|
|
394
483
|
};
|
|
395
484
|
default:
|
|
396
485
|
return {
|
|
397
|
-
value:
|
|
398
|
-
unit: typeof
|
|
486
|
+
value: a,
|
|
487
|
+
unit: typeof n.unit == "string" ? n.unit : ""
|
|
399
488
|
};
|
|
400
489
|
}
|
|
401
|
-
}, [
|
|
402
|
-
|
|
403
|
-
|
|
490
|
+
}, [r, o] = [
|
|
491
|
+
i(s),
|
|
492
|
+
i(t)
|
|
404
493
|
];
|
|
405
|
-
return
|
|
494
|
+
return e ? (s.value = r.value, s.unit = r.unit, t.value = o.value, t.unit = o.unit, [s, t]) : [
|
|
406
495
|
new f(
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
496
|
+
r.value,
|
|
497
|
+
r.unit,
|
|
498
|
+
s.superType,
|
|
499
|
+
s.subProperty,
|
|
500
|
+
s.property,
|
|
501
|
+
s.targets
|
|
413
502
|
),
|
|
414
503
|
new f(
|
|
415
504
|
o.value,
|
|
@@ -421,268 +510,321 @@ const le = (e) => {
|
|
|
421
510
|
)
|
|
422
511
|
];
|
|
423
512
|
};
|
|
424
|
-
function
|
|
425
|
-
|
|
426
|
-
const
|
|
427
|
-
start:
|
|
513
|
+
function me(s, t, e = "oklab", i) {
|
|
514
|
+
s = s.coalesce(t), t = t.coalesce(s);
|
|
515
|
+
const r = {
|
|
516
|
+
start: s,
|
|
428
517
|
stop: t,
|
|
429
|
-
value:
|
|
518
|
+
value: s.clone(),
|
|
430
519
|
computed: !1
|
|
431
520
|
};
|
|
432
|
-
if (
|
|
433
|
-
const [o,
|
|
434
|
-
H(
|
|
521
|
+
if (s.unit === "color" && t.unit === "color") {
|
|
522
|
+
const [o, n] = bt(
|
|
523
|
+
H(s),
|
|
435
524
|
H(t),
|
|
436
|
-
|
|
525
|
+
e,
|
|
437
526
|
!1,
|
|
438
527
|
!0,
|
|
439
528
|
!1,
|
|
440
|
-
|
|
529
|
+
i
|
|
441
530
|
);
|
|
442
|
-
|
|
531
|
+
r.start = o, r.stop = n, r.value = o.clone();
|
|
443
532
|
}
|
|
444
|
-
if (
|
|
445
|
-
const [o,
|
|
446
|
-
|
|
533
|
+
if (s.unit !== t.unit) {
|
|
534
|
+
const [o, n] = pe(
|
|
535
|
+
s,
|
|
447
536
|
t,
|
|
448
537
|
!0
|
|
449
538
|
);
|
|
450
|
-
|
|
539
|
+
r.start = o, r.stop = n, r.value = o.clone();
|
|
451
540
|
}
|
|
452
|
-
return
|
|
541
|
+
return r.computed = X(s.unit) || X(t.unit), r;
|
|
453
542
|
}
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
return [
|
|
457
|
-
if (
|
|
458
|
-
return
|
|
459
|
-
if (
|
|
460
|
-
return
|
|
543
|
+
const v = (s) => {
|
|
544
|
+
if (s instanceof f)
|
|
545
|
+
return [s.clone()];
|
|
546
|
+
if (s instanceof U)
|
|
547
|
+
return s.values.flatMap((t) => v(t));
|
|
548
|
+
if (s instanceof T)
|
|
549
|
+
return s.flatMap((t) => v(t));
|
|
461
550
|
throw new TypeError(
|
|
462
|
-
`Expected ValueUnit/FunctionValue/ValueArray, got ${typeof
|
|
551
|
+
`Expected ValueUnit/FunctionValue/ValueArray, got ${typeof s}`
|
|
463
552
|
);
|
|
464
|
-
},
|
|
465
|
-
const t =
|
|
466
|
-
if (!t || !
|
|
467
|
-
throw new Error(`Invalid flattened key: ${
|
|
468
|
-
return { mainKey:
|
|
469
|
-
}, P = (
|
|
470
|
-
if (typeof
|
|
471
|
-
const t =
|
|
553
|
+
}, de = (s) => {
|
|
554
|
+
const t = s.split(".").pop(), e = s.split(".").shift();
|
|
555
|
+
if (!t || !e)
|
|
556
|
+
throw new Error(`Invalid flattened key: ${s}`);
|
|
557
|
+
return { mainKey: e, childKey: t };
|
|
558
|
+
}, P = (s, t, e) => (s.setProperty(t), e !== t && s.setSubProperty(e), s), M = (s) => {
|
|
559
|
+
if (typeof s == "string") {
|
|
560
|
+
const t = rt[s];
|
|
472
561
|
return typeof t == "function" && t.length <= 1 ? t : void 0;
|
|
473
|
-
} else if (
|
|
562
|
+
} else if (s == null)
|
|
474
563
|
return;
|
|
475
|
-
return
|
|
564
|
+
return s;
|
|
476
565
|
};
|
|
477
|
-
function
|
|
478
|
-
const
|
|
479
|
-
if (!
|
|
566
|
+
function ft(s, { start: t, stop: e, value: i }) {
|
|
567
|
+
const r = t.targets?.[0] ?? e.targets?.[0];
|
|
568
|
+
if (!r)
|
|
480
569
|
throw new Error(
|
|
481
570
|
"Cannot interpolate computed values without a target element."
|
|
482
571
|
);
|
|
483
|
-
const o =
|
|
484
|
-
return
|
|
572
|
+
const o = q(t, r), n = q(e, r), u = $.includes(o.unit) ? n.unit : o.unit, a = I(s, o.value, n.value);
|
|
573
|
+
return i.value = a, i.unit = u, i;
|
|
485
574
|
}
|
|
486
|
-
function
|
|
487
|
-
return t.value.keys().forEach((
|
|
488
|
-
const o = t.value[
|
|
489
|
-
l instanceof f ? l.value = c :
|
|
490
|
-
}),
|
|
575
|
+
function pt(s, { start: t, stop: e, value: i }) {
|
|
576
|
+
return t.value.keys().forEach((r) => {
|
|
577
|
+
const o = t.value[r], n = e.value[r], u = o instanceof f ? o.value : o, a = n instanceof f ? n.value : n, c = I(s, u, a), l = i.value[r];
|
|
578
|
+
l instanceof f ? l.value = c : i.value[r] = c;
|
|
579
|
+
}), i;
|
|
491
580
|
}
|
|
492
|
-
function
|
|
493
|
-
|
|
494
|
-
return typeof s.value == "number" && typeof n.value == "number" ? t.value.value = E(e, s.value, n.value) : s.unit === "color" ? me(e, t) : i && pe(e, t), t;
|
|
581
|
+
function ge(s, { start: t, stop: e, value: i }) {
|
|
582
|
+
return i.value = I(s, t.value, e.value), i;
|
|
495
583
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
584
|
+
function ye(s, t) {
|
|
585
|
+
const e = t._lerp;
|
|
586
|
+
if (e)
|
|
587
|
+
return e(s, t), t;
|
|
588
|
+
const { start: i, stop: r, computed: o } = t;
|
|
589
|
+
return typeof i.value == "number" && typeof r.value == "number" ? t.value.value = I(s, i.value, r.value) : i.unit === "color" ? pt(s, t) : o && ft(s, t), t;
|
|
590
|
+
}
|
|
591
|
+
const Z = /* @__PURE__ */ new Map();
|
|
592
|
+
function we(s) {
|
|
593
|
+
const t = nt(s), e = (r, o) => {
|
|
594
|
+
const { childKey: n, mainKey: u } = de(r);
|
|
500
595
|
if (o instanceof f)
|
|
501
596
|
return P(
|
|
502
|
-
new
|
|
503
|
-
|
|
504
|
-
|
|
597
|
+
new T(...v(o)),
|
|
598
|
+
u,
|
|
599
|
+
n
|
|
505
600
|
);
|
|
506
|
-
if (o instanceof
|
|
601
|
+
if (o instanceof U) {
|
|
507
602
|
const p = o.values.flatMap(
|
|
508
|
-
(y) =>
|
|
603
|
+
(y) => v(e(r, y))
|
|
509
604
|
);
|
|
510
605
|
return P(
|
|
511
|
-
new
|
|
512
|
-
|
|
513
|
-
|
|
606
|
+
new T(...p),
|
|
607
|
+
u,
|
|
608
|
+
n
|
|
514
609
|
);
|
|
515
|
-
} else if (o instanceof
|
|
610
|
+
} else if (o instanceof T) {
|
|
516
611
|
const p = o.flatMap(
|
|
517
|
-
(y) =>
|
|
612
|
+
(y) => v(e(r, y))
|
|
518
613
|
);
|
|
519
614
|
return P(
|
|
520
|
-
new
|
|
521
|
-
|
|
522
|
-
|
|
615
|
+
new T(...p),
|
|
616
|
+
u,
|
|
617
|
+
n
|
|
523
618
|
);
|
|
524
619
|
}
|
|
525
|
-
const
|
|
620
|
+
const a = String(o), c = `${n}:${a}`, l = Z.get(c);
|
|
526
621
|
if (l)
|
|
527
|
-
return P(l.clone(),
|
|
622
|
+
return P(l.clone(), u, n);
|
|
528
623
|
const h = F(
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
624
|
+
C(
|
|
625
|
+
W.FunctionArgs.map((p) => (p.setSubProperty(n), p)),
|
|
626
|
+
W.Value
|
|
532
627
|
),
|
|
533
|
-
|
|
534
|
-
),
|
|
535
|
-
new
|
|
536
|
-
|
|
537
|
-
|
|
628
|
+
a
|
|
629
|
+
), m = P(
|
|
630
|
+
new T(...v(h)),
|
|
631
|
+
u,
|
|
632
|
+
n
|
|
538
633
|
);
|
|
539
|
-
return
|
|
634
|
+
return Z.set(c, m.clone()), m;
|
|
540
635
|
};
|
|
541
636
|
return Object.entries(t).reduce(
|
|
542
|
-
(
|
|
637
|
+
(r, [o, n]) => (r[o] = e(o, n), r),
|
|
543
638
|
{}
|
|
544
639
|
);
|
|
545
640
|
}
|
|
546
|
-
const
|
|
547
|
-
const
|
|
548
|
-
if (!
|
|
641
|
+
const Ve = (s, t, e, i, r = "oklab", o) => {
|
|
642
|
+
const n = i[t], u = i[e];
|
|
643
|
+
if (!n || !u)
|
|
549
644
|
throw new Error(
|
|
550
|
-
`Invalid interpolation frame bounds (${t} -> ${
|
|
645
|
+
`Invalid interpolation frame bounds (${t} -> ${e}).`
|
|
551
646
|
);
|
|
552
|
-
const
|
|
553
|
-
if (!
|
|
554
|
-
throw new Error(`Missing variable "${
|
|
555
|
-
const l = Math.max(
|
|
556
|
-
const
|
|
557
|
-
if (!(
|
|
647
|
+
const a = n[s], c = u[s];
|
|
648
|
+
if (!a || !c)
|
|
649
|
+
throw new Error(`Missing variable "${s}" in interpolation bounds.`);
|
|
650
|
+
const l = Math.max(a.length, c.length), h = (y) => {
|
|
651
|
+
const b = y.map((S) => {
|
|
652
|
+
if (!(S instanceof f))
|
|
558
653
|
throw new TypeError(
|
|
559
|
-
`Interpolation for "${
|
|
654
|
+
`Interpolation for "${s}" requires ValueUnit leaves.`
|
|
560
655
|
);
|
|
561
|
-
return
|
|
656
|
+
return S;
|
|
562
657
|
});
|
|
563
|
-
for (;
|
|
564
|
-
|
|
565
|
-
return
|
|
566
|
-
},
|
|
567
|
-
return
|
|
568
|
-
const
|
|
569
|
-
if (!
|
|
658
|
+
for (; b.length < l; )
|
|
659
|
+
b.push(new f(0));
|
|
660
|
+
return b;
|
|
661
|
+
}, m = h(a), p = h(c);
|
|
662
|
+
return m.map((y, b) => {
|
|
663
|
+
const S = p[b];
|
|
664
|
+
if (!S)
|
|
570
665
|
throw new Error(
|
|
571
|
-
`Missing right-hand interpolation value at index ${
|
|
666
|
+
`Missing right-hand interpolation value at index ${b}.`
|
|
572
667
|
);
|
|
573
|
-
if (!(y instanceof f) || !(
|
|
668
|
+
if (!(y instanceof f) || !(S instanceof f))
|
|
574
669
|
throw new TypeError(
|
|
575
|
-
`Interpolation for "${
|
|
670
|
+
`Interpolation for "${s}" requires ValueUnit leaves.`
|
|
576
671
|
);
|
|
577
|
-
|
|
672
|
+
const O = me(y, S, r, o);
|
|
673
|
+
return O._lerp = O.computed ? ft : O.start.unit === "color" ? pt : ge, O;
|
|
578
674
|
});
|
|
579
675
|
};
|
|
580
|
-
function
|
|
581
|
-
const [
|
|
676
|
+
function Te(s, t, e) {
|
|
677
|
+
const [i, r] = [s.start, t.start];
|
|
582
678
|
return {
|
|
583
|
-
start:
|
|
584
|
-
stop:
|
|
679
|
+
start: i.value * e / 100,
|
|
680
|
+
stop: r.value * e / 100
|
|
585
681
|
};
|
|
586
682
|
}
|
|
587
|
-
function
|
|
588
|
-
|
|
589
|
-
const
|
|
590
|
-
t.forEach((
|
|
591
|
-
Object.entries(
|
|
592
|
-
|
|
683
|
+
function mt(s, t, e = !0) {
|
|
684
|
+
s = e ? s : nt(s);
|
|
685
|
+
const i = ot(s);
|
|
686
|
+
t.forEach((r) => {
|
|
687
|
+
Object.entries(i).forEach(([o, n]) => {
|
|
688
|
+
r.style.setProperty(o, n);
|
|
593
689
|
});
|
|
594
690
|
});
|
|
595
691
|
}
|
|
596
|
-
const
|
|
692
|
+
const be = (s) => s;
|
|
597
693
|
class Se {
|
|
598
694
|
keyframes;
|
|
599
695
|
segments;
|
|
600
696
|
positions;
|
|
601
697
|
timingFn;
|
|
602
698
|
result;
|
|
603
|
-
|
|
699
|
+
_duration;
|
|
700
|
+
// Playback state
|
|
701
|
+
_rafId = null;
|
|
702
|
+
_resolve = null;
|
|
703
|
+
_startTime = void 0;
|
|
704
|
+
constructor(t, e) {
|
|
604
705
|
if (t.length < 2)
|
|
605
706
|
throw new Error(
|
|
606
707
|
"NumericAnimation requires at least 2 keyframes."
|
|
607
708
|
);
|
|
608
|
-
if (this.keyframes = t.map((
|
|
609
|
-
if (
|
|
709
|
+
if (this.keyframes = t.map((i) => ({ ...i })), this._duration = e?.duration ?? 0, this.timingFn = (e?.timingFunction ? M(e.timingFunction) : void 0) ?? be, e?.positions) {
|
|
710
|
+
if (e.positions.length !== t.length)
|
|
610
711
|
throw new Error(
|
|
611
712
|
"positions length must match keyframes length."
|
|
612
713
|
);
|
|
613
|
-
this.positions =
|
|
714
|
+
this.positions = e.positions;
|
|
614
715
|
} else
|
|
615
716
|
this.positions = t.map(
|
|
616
|
-
(
|
|
717
|
+
(i, r) => r / (t.length - 1) * 100
|
|
617
718
|
);
|
|
618
719
|
this.result = { ...t[0] }, this.segments = this.buildSegments();
|
|
619
720
|
}
|
|
620
721
|
buildSegments() {
|
|
621
722
|
const t = [];
|
|
622
|
-
for (let
|
|
623
|
-
t.push(this.buildSegment(
|
|
723
|
+
for (let e = 0; e < this.keyframes.length - 1; e++)
|
|
724
|
+
t.push(this.buildSegment(e));
|
|
624
725
|
return t;
|
|
625
726
|
}
|
|
626
727
|
buildSegment(t) {
|
|
627
|
-
const
|
|
728
|
+
const e = this.keyframes[t], i = this.keyframes[t + 1], r = Object.keys(e);
|
|
628
729
|
return {
|
|
629
730
|
startPos: this.positions[t],
|
|
630
731
|
stopPos: this.positions[t + 1],
|
|
631
|
-
keys:
|
|
632
|
-
startVals:
|
|
633
|
-
stopVals:
|
|
732
|
+
keys: r,
|
|
733
|
+
startVals: r.map((o) => e[o]),
|
|
734
|
+
stopVals: r.map((o) => i[o]),
|
|
634
735
|
timingFunction: this.timingFn
|
|
635
736
|
};
|
|
636
737
|
}
|
|
637
|
-
/**
|
|
738
|
+
/**
|
|
739
|
+
* Map [0, 1] progress to interpolated values. Zero allocation —
|
|
740
|
+
* returns the same pre-allocated result object on every call.
|
|
741
|
+
*
|
|
742
|
+
* Uses O(log N) binary search over segments. Falls back to the
|
|
743
|
+
* last segment if progress is past the final stop position.
|
|
744
|
+
*/
|
|
638
745
|
at(t) {
|
|
639
|
-
const
|
|
640
|
-
let
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
n.startPos,
|
|
652
|
-
n.stopPos,
|
|
746
|
+
const e = E(t, 0, 1) * 100;
|
|
747
|
+
let i = lt(
|
|
748
|
+
this.segments,
|
|
749
|
+
e,
|
|
750
|
+
(u) => u.startPos,
|
|
751
|
+
(u) => u.stopPos
|
|
752
|
+
);
|
|
753
|
+
i === -1 && (i = this.segments.length - 1);
|
|
754
|
+
const r = this.segments[i], o = at(
|
|
755
|
+
E(e, r.startPos, r.stopPos),
|
|
756
|
+
r.startPos,
|
|
757
|
+
r.stopPos,
|
|
653
758
|
0,
|
|
654
759
|
1
|
|
655
|
-
),
|
|
656
|
-
for (let
|
|
657
|
-
this.result[
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
760
|
+
), n = r.timingFunction(o);
|
|
761
|
+
for (let u = 0; u < r.keys.length; u++)
|
|
762
|
+
this.result[r.keys[u]] = I(
|
|
763
|
+
n,
|
|
764
|
+
r.startVals[u],
|
|
765
|
+
r.stopVals[u]
|
|
661
766
|
);
|
|
662
767
|
return this.result;
|
|
663
768
|
}
|
|
664
769
|
/** Update a keyframe's values in-place, recomputing adjacent segments. */
|
|
665
|
-
updateKeyframe(t,
|
|
770
|
+
updateKeyframe(t, e) {
|
|
666
771
|
if (t < 0 || t >= this.keyframes.length)
|
|
667
772
|
throw new RangeError(
|
|
668
773
|
`Keyframe index ${t} out of range [0, ${this.keyframes.length - 1}].`
|
|
669
774
|
);
|
|
670
|
-
return Object.assign(this.keyframes[t],
|
|
775
|
+
return Object.assign(this.keyframes[t], e), t > 0 && (this.segments[t - 1] = this.buildSegment(t - 1)), t < this.keyframes.length - 1 && (this.segments[t] = this.buildSegment(t)), this;
|
|
776
|
+
}
|
|
777
|
+
// ── Playback ─────────────────────────────────────────────────────
|
|
778
|
+
/**
|
|
779
|
+
* Play the animation over its duration using requestAnimationFrame.
|
|
780
|
+
*
|
|
781
|
+
* Calls `onFrame` each frame with the interpolated values (the same
|
|
782
|
+
* zero-allocation object returned by `.at()`). Returns a Promise that
|
|
783
|
+
* resolves when the animation completes or is stopped.
|
|
784
|
+
*
|
|
785
|
+
* @param onFrame — optional per-frame callback receiving interpolated values
|
|
786
|
+
* @param duration — override the duration set in constructor options (ms)
|
|
787
|
+
*/
|
|
788
|
+
play(t, e) {
|
|
789
|
+
const i = e ?? this._duration;
|
|
790
|
+
if (i <= 0)
|
|
791
|
+
throw new Error(
|
|
792
|
+
"NumericAnimation.play() requires a duration > 0. Pass it in the constructor options or as a parameter to play()."
|
|
793
|
+
);
|
|
794
|
+
return this.stop(), new Promise((r) => {
|
|
795
|
+
this._resolve = r, this._startTime = void 0;
|
|
796
|
+
const o = (n) => {
|
|
797
|
+
this._startTime === void 0 && (this._startTime = n);
|
|
798
|
+
const u = E((n - this._startTime) / i, 0, 1), a = this.at(u);
|
|
799
|
+
t?.(a), u < 1 ? this._rafId = w(o) : this._cleanup();
|
|
800
|
+
};
|
|
801
|
+
this._rafId = w(o);
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
/** Cancel a running `.play()` animation. The play promise resolves immediately. */
|
|
805
|
+
stop() {
|
|
806
|
+
this._rafId !== null && k(this._rafId), this._cleanup();
|
|
807
|
+
}
|
|
808
|
+
_cleanup() {
|
|
809
|
+
this._rafId = null, this._startTime = void 0;
|
|
810
|
+
const t = this._resolve;
|
|
811
|
+
this._resolve = null, t?.();
|
|
671
812
|
}
|
|
672
813
|
}
|
|
673
|
-
const
|
|
814
|
+
const ve = {
|
|
674
815
|
damping: 0.1,
|
|
675
816
|
snapThreshold: 1e-3,
|
|
817
|
+
targetEpsilon: 0,
|
|
676
818
|
initial: 0,
|
|
677
819
|
clamp: !0
|
|
678
820
|
};
|
|
679
|
-
class
|
|
821
|
+
class Fe {
|
|
680
822
|
options;
|
|
681
823
|
targetValue;
|
|
682
824
|
currentValue;
|
|
683
825
|
isSettled;
|
|
684
826
|
constructor(t) {
|
|
685
|
-
this.options = { ...
|
|
827
|
+
this.options = { ...ve, ...t }, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
|
|
686
828
|
}
|
|
687
829
|
get target() {
|
|
688
830
|
return this.targetValue;
|
|
@@ -694,7 +836,9 @@ class be {
|
|
|
694
836
|
return this.isSettled;
|
|
695
837
|
}
|
|
696
838
|
setTarget(t) {
|
|
697
|
-
this.options.clamp && (t = Math.max(0, Math.min(1, t)))
|
|
839
|
+
this.options.clamp && (t = Math.max(0, Math.min(1, t)));
|
|
840
|
+
const e = Math.abs(t - this.targetValue);
|
|
841
|
+
e > 0 && e >= this.options.targetEpsilon && (this.targetValue = t, this.isSettled = !1);
|
|
698
842
|
}
|
|
699
843
|
/** Advance one step using fixed damping. Returns current value. */
|
|
700
844
|
tick() {
|
|
@@ -706,8 +850,8 @@ class be {
|
|
|
706
850
|
/** Frame-rate independent tick. dt is in milliseconds. */
|
|
707
851
|
tickDt(t) {
|
|
708
852
|
if (this.isSettled) return this.currentValue;
|
|
709
|
-
const
|
|
710
|
-
return this.currentValue += (this.targetValue - this.currentValue) *
|
|
853
|
+
const e = 1 - Math.exp(-this.options.damping * t / 16.667);
|
|
854
|
+
return this.currentValue += (this.targetValue - this.currentValue) * e, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = Math.max(
|
|
711
855
|
0,
|
|
712
856
|
Math.min(1, this.currentValue)
|
|
713
857
|
)), this.currentValue;
|
|
@@ -718,33 +862,34 @@ class be {
|
|
|
718
862
|
}
|
|
719
863
|
/** Reset to a specific value (default 0). */
|
|
720
864
|
reset(t) {
|
|
721
|
-
const
|
|
722
|
-
this.targetValue =
|
|
865
|
+
const e = t ?? 0;
|
|
866
|
+
this.targetValue = e, this.currentValue = e, this.isSettled = !0;
|
|
723
867
|
}
|
|
724
868
|
}
|
|
725
|
-
const
|
|
726
|
-
if (
|
|
727
|
-
const t =
|
|
869
|
+
const Q = (s) => {
|
|
870
|
+
if (s instanceof HTMLElement) {
|
|
871
|
+
const t = s.getBoundingClientRect();
|
|
728
872
|
return { x: t.x, y: t.y, width: t.width, height: t.height };
|
|
729
873
|
}
|
|
730
|
-
return
|
|
874
|
+
return s;
|
|
731
875
|
};
|
|
732
|
-
class
|
|
876
|
+
class Ue {
|
|
733
877
|
animation;
|
|
734
878
|
transformOrigin;
|
|
735
879
|
timingFunction;
|
|
736
|
-
|
|
737
|
-
|
|
880
|
+
duration;
|
|
881
|
+
constructor(t, e, i) {
|
|
882
|
+
this.transformOrigin = i?.transformOrigin ?? "top left", this.timingFunction = i?.timingFunction, this.duration = i?.duration ?? 0, this.measure(t, e);
|
|
738
883
|
}
|
|
739
884
|
/** Re-measure source and destination, rebuilding the internal animation. */
|
|
740
|
-
measure(t,
|
|
741
|
-
const
|
|
885
|
+
measure(t, e) {
|
|
886
|
+
const i = Q(t), r = Q(e), o = r.x - i.x, n = r.y - i.y, u = i.width === 0 ? 1 : r.width / i.width, a = i.height === 0 ? 1 : r.height / i.height;
|
|
742
887
|
return this.animation = new Se(
|
|
743
888
|
[
|
|
744
889
|
{ translateX: 0, translateY: 0, scaleX: 1, scaleY: 1 },
|
|
745
|
-
{ translateX: o, translateY:
|
|
890
|
+
{ translateX: o, translateY: n, scaleX: u, scaleY: a }
|
|
746
891
|
],
|
|
747
|
-
{ timingFunction: this.timingFunction }
|
|
892
|
+
{ timingFunction: this.timingFunction, duration: this.duration }
|
|
748
893
|
), this;
|
|
749
894
|
}
|
|
750
895
|
/** Get raw transform values at the given progress [0, 1]. */
|
|
@@ -753,38 +898,74 @@ class je {
|
|
|
753
898
|
}
|
|
754
899
|
/** Get a CSS transform string at the given progress [0, 1]. */
|
|
755
900
|
toCSSTransform(t) {
|
|
756
|
-
const { translateX:
|
|
757
|
-
return `translate(${
|
|
901
|
+
const { translateX: e, translateY: i, scaleX: r, scaleY: o } = this.animation.at(t);
|
|
902
|
+
return `translate(${e}px, ${i}px) scale(${r}, ${o})`;
|
|
758
903
|
}
|
|
759
904
|
/** Apply the morph transform to an element at the given progress [0, 1]. */
|
|
760
|
-
apply(t,
|
|
761
|
-
t.style.transform = this.toCSSTransform(
|
|
905
|
+
apply(t, e) {
|
|
906
|
+
t.style.transform = this.toCSSTransform(e), t.style.transformOrigin = this.transformOrigin;
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Animate an element from source to destination over the configured duration.
|
|
910
|
+
*
|
|
911
|
+
* @param element — the element to apply transforms to
|
|
912
|
+
* @param duration — override the duration set in constructor options (ms)
|
|
913
|
+
*/
|
|
914
|
+
play(t, e) {
|
|
915
|
+
return this.animation.play((i) => {
|
|
916
|
+
const { translateX: r, translateY: o, scaleX: n, scaleY: u } = i;
|
|
917
|
+
t.style.transform = `translate(${r}px, ${o}px) scale(${n}, ${u})`, t.style.transformOrigin = this.transformOrigin;
|
|
918
|
+
}, e ?? this.duration);
|
|
919
|
+
}
|
|
920
|
+
/** Cancel a running `.play()` animation. */
|
|
921
|
+
stop() {
|
|
922
|
+
this.animation.stop();
|
|
762
923
|
}
|
|
763
924
|
}
|
|
764
|
-
const
|
|
765
|
-
if (
|
|
766
|
-
if (typeof
|
|
767
|
-
const t =
|
|
925
|
+
const Ie = (s) => {
|
|
926
|
+
if (s == null) return null;
|
|
927
|
+
if (typeof s == "function") return s;
|
|
928
|
+
const t = rt[s];
|
|
768
929
|
return typeof t == "function" && t.length <= 1 ? t : null;
|
|
769
|
-
},
|
|
770
|
-
class
|
|
930
|
+
}, Pe = (s) => Math.max(0, Math.min(1, s));
|
|
931
|
+
class dt {
|
|
771
932
|
smoother;
|
|
772
933
|
easingFn;
|
|
773
934
|
currentProgress = 0;
|
|
935
|
+
boundaryEpsilon;
|
|
774
936
|
constructor(t) {
|
|
775
|
-
this.easingFn =
|
|
937
|
+
this.easingFn = Ie(t?.easing), this.boundaryEpsilon = t?.boundaryEpsilon ?? 5e-3, t?.smoothing === !1 ? this.smoother = null : this.smoother = new Fe(
|
|
776
938
|
t?.smoothing
|
|
777
939
|
);
|
|
778
940
|
}
|
|
779
|
-
/**
|
|
941
|
+
/**
|
|
942
|
+
* Shared progress pipeline: sample → clamp → easing → boundary snap.
|
|
943
|
+
* Returns the processed raw value. Does NOT advance the smoother —
|
|
944
|
+
* the caller (tick or tickDt) drives the smoother with the appropriate
|
|
945
|
+
* time-step method.
|
|
946
|
+
*/
|
|
947
|
+
applyPipeline() {
|
|
948
|
+
let t = Pe(this.sample());
|
|
949
|
+
this.easingFn && (t = this.easingFn(t));
|
|
950
|
+
const e = this.boundaryEpsilon;
|
|
951
|
+
return t <= e ? t = 0 : t >= 1 - e && (t = 1), t;
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Finalize progress after the smoother has been advanced (or bypassed).
|
|
955
|
+
* Snaps the smoother at boundaries [0, 1] for instant convergence.
|
|
956
|
+
*/
|
|
957
|
+
finalizeProgress(t) {
|
|
958
|
+
return this.smoother && (this.smoother.setTarget(t), (t <= 0 || t >= 1) && this.smoother.snap()), this.currentProgress = this.smoother ? this.smoother.current : t, this.currentProgress;
|
|
959
|
+
}
|
|
960
|
+
/** Advance one frame. Applies easing → boundary snap → smoothing. */
|
|
780
961
|
tick() {
|
|
781
|
-
|
|
782
|
-
return this.
|
|
962
|
+
const t = this.applyPipeline();
|
|
963
|
+
return this.smoother && t > 0 && t < 1 ? (this.smoother.setTarget(t), this.smoother.tick(), this.currentProgress = this.smoother.current) : this.finalizeProgress(t), this.currentProgress;
|
|
783
964
|
}
|
|
784
|
-
/** Frame-rate independent variant. dt in
|
|
965
|
+
/** Frame-rate independent variant. `dt` in milliseconds. */
|
|
785
966
|
tickDt(t) {
|
|
786
|
-
|
|
787
|
-
return this.
|
|
967
|
+
const e = this.applyPipeline();
|
|
968
|
+
return this.smoother && e > 0 && e < 1 ? (this.smoother.setTarget(e), this.smoother.tickDt(t), this.currentProgress = this.smoother.current) : this.finalizeProgress(e), this.currentProgress;
|
|
788
969
|
}
|
|
789
970
|
get progress() {
|
|
790
971
|
return this.currentProgress;
|
|
@@ -799,11 +980,11 @@ class ft {
|
|
|
799
980
|
}
|
|
800
981
|
/** Reset progress to a specific value (default 0). */
|
|
801
982
|
reset(t) {
|
|
802
|
-
const
|
|
803
|
-
this.smoother && this.smoother.reset(
|
|
983
|
+
const e = t ?? 0;
|
|
984
|
+
this.smoother && this.smoother.reset(e), this.currentProgress = e;
|
|
804
985
|
}
|
|
805
986
|
}
|
|
806
|
-
class
|
|
987
|
+
class $e extends dt {
|
|
807
988
|
threshold;
|
|
808
989
|
getScrollY;
|
|
809
990
|
getViewportHeight;
|
|
@@ -815,7 +996,7 @@ class xe extends ft {
|
|
|
815
996
|
return t <= 0 ? 0 : this.getScrollY() / t;
|
|
816
997
|
}
|
|
817
998
|
}
|
|
818
|
-
class
|
|
999
|
+
class De extends dt {
|
|
819
1000
|
value = 0;
|
|
820
1001
|
constructor(t) {
|
|
821
1002
|
super({ smoothing: !1, ...t });
|
|
@@ -828,59 +1009,59 @@ class Ue extends ft {
|
|
|
828
1009
|
return this.value;
|
|
829
1010
|
}
|
|
830
1011
|
}
|
|
831
|
-
const
|
|
832
|
-
function
|
|
833
|
-
if (!
|
|
1012
|
+
const Ee = (s) => typeof s.transform == "function", J = (s) => typeof s == "string" && $.includes(s);
|
|
1013
|
+
function Ce(s) {
|
|
1014
|
+
if (!s.targets || s.targets.length === 0)
|
|
834
1015
|
return !1;
|
|
835
|
-
const t =
|
|
836
|
-
for (const
|
|
837
|
-
const
|
|
838
|
-
if (
|
|
1016
|
+
const t = Ee(s) ? s.transform : void 0;
|
|
1017
|
+
for (const e of s.frames) {
|
|
1018
|
+
const i = e.transform;
|
|
1019
|
+
if (i !== mt && i !== t)
|
|
839
1020
|
return !1;
|
|
840
1021
|
}
|
|
841
|
-
if (
|
|
842
|
-
const
|
|
843
|
-
for (let
|
|
844
|
-
if (
|
|
1022
|
+
if (s.frames.length > 1) {
|
|
1023
|
+
const e = s.frames[0].timingFunction;
|
|
1024
|
+
for (let i = 1; i < s.frames.length; i++)
|
|
1025
|
+
if (s.frames[i].timingFunction !== e)
|
|
845
1026
|
return !1;
|
|
846
1027
|
}
|
|
847
|
-
for (const
|
|
848
|
-
for (const
|
|
849
|
-
for (const
|
|
850
|
-
const o =
|
|
851
|
-
if (
|
|
1028
|
+
for (const e of s.frames)
|
|
1029
|
+
for (const i of Object.values(e.interpVars))
|
|
1030
|
+
for (const r of i) {
|
|
1031
|
+
const o = r.start?.unit, n = r.stop?.unit;
|
|
1032
|
+
if (J(o) || J(n))
|
|
852
1033
|
return !1;
|
|
853
1034
|
}
|
|
854
|
-
for (const
|
|
855
|
-
for (const
|
|
856
|
-
for (const
|
|
857
|
-
if (
|
|
1035
|
+
for (const e of s.frames)
|
|
1036
|
+
for (const i of Object.values(e.interpVars))
|
|
1037
|
+
for (const r of i)
|
|
1038
|
+
if (r.start?.unit === "color" || r.stop?.unit === "color")
|
|
858
1039
|
return !1;
|
|
859
1040
|
return !0;
|
|
860
1041
|
}
|
|
861
|
-
function
|
|
862
|
-
const t =
|
|
863
|
-
for (const o of
|
|
864
|
-
|
|
865
|
-
const
|
|
866
|
-
for (const o of
|
|
867
|
-
const
|
|
868
|
-
if (Object.keys(
|
|
869
|
-
const
|
|
1042
|
+
function Oe(s) {
|
|
1043
|
+
const t = s.options.duration, e = [], i = /* @__PURE__ */ new Set();
|
|
1044
|
+
for (const o of s.frames)
|
|
1045
|
+
i.add(o.time.start), i.add(o.time.stop);
|
|
1046
|
+
const r = [...i].sort((o, n) => o - n);
|
|
1047
|
+
for (const o of r) {
|
|
1048
|
+
const n = s.interpFrames(o, !1);
|
|
1049
|
+
if (Object.keys(n).length === 0) continue;
|
|
1050
|
+
const u = ot(n), a = {
|
|
870
1051
|
offset: Math.max(0, Math.min(1, o / t)),
|
|
871
|
-
...
|
|
1052
|
+
...u
|
|
872
1053
|
};
|
|
873
|
-
|
|
1054
|
+
e.push(a);
|
|
874
1055
|
}
|
|
875
|
-
return
|
|
1056
|
+
return e;
|
|
876
1057
|
}
|
|
877
|
-
function
|
|
878
|
-
const t =
|
|
1058
|
+
function _e(s) {
|
|
1059
|
+
const t = s.options, e = {
|
|
879
1060
|
normal: "normal",
|
|
880
1061
|
reverse: "reverse",
|
|
881
1062
|
alternate: "alternate",
|
|
882
1063
|
"alternate-reverse": "alternate-reverse"
|
|
883
|
-
},
|
|
1064
|
+
}, i = {
|
|
884
1065
|
none: "none",
|
|
885
1066
|
forwards: "forwards",
|
|
886
1067
|
backwards: "backwards",
|
|
@@ -891,25 +1072,25 @@ function Ie(e) {
|
|
|
891
1072
|
delay: t.delay,
|
|
892
1073
|
iterations: t.iterationCount === 1 / 0 ? 1 / 0 : t.iterationCount,
|
|
893
1074
|
// TODO(HIGH): Remove enum fallbacks; throw when direction/fill values are outside supported WAAPI maps.
|
|
894
|
-
direction:
|
|
895
|
-
fill:
|
|
1075
|
+
direction: e[t.direction] ?? "normal",
|
|
1076
|
+
fill: i[t.fillMode] ?? "forwards",
|
|
896
1077
|
// WAAPI easing is set per-animation — we use the frame's timing function name
|
|
897
1078
|
// For custom functions we fall back to linear (the JS interpolation handles easing)
|
|
898
1079
|
easing: "linear"
|
|
899
1080
|
};
|
|
900
1081
|
}
|
|
901
|
-
async function
|
|
902
|
-
const t =
|
|
903
|
-
for (const
|
|
904
|
-
const o =
|
|
905
|
-
|
|
1082
|
+
async function ke(s) {
|
|
1083
|
+
const t = Oe(s), e = _e(s), i = [];
|
|
1084
|
+
for (const r of s.targets) {
|
|
1085
|
+
const o = r.animate(t, e);
|
|
1086
|
+
i.push(o);
|
|
906
1087
|
}
|
|
907
|
-
return await Promise.all(
|
|
1088
|
+
return await Promise.all(i.map((r) => r.finished)), i;
|
|
908
1089
|
}
|
|
909
|
-
const
|
|
910
|
-
let
|
|
911
|
-
class
|
|
912
|
-
id =
|
|
1090
|
+
const Me = (s) => typeof s != "object" || s == null ? !1 : typeof s.clone == "function", x = (s) => typeof s == "string" ? s : s.name ?? String(s.id);
|
|
1091
|
+
let Ae = 0;
|
|
1092
|
+
class gt {
|
|
1093
|
+
id = Ae++;
|
|
913
1094
|
name;
|
|
914
1095
|
superKey;
|
|
915
1096
|
targets;
|
|
@@ -933,126 +1114,160 @@ class pt {
|
|
|
933
1114
|
unflatten = !0;
|
|
934
1115
|
resolvePromise = null;
|
|
935
1116
|
_playingPromise = null;
|
|
1117
|
+
/**
|
|
1118
|
+
* Pre-bound draw callback — allocated once to avoid creating a new
|
|
1119
|
+
* closure on every requestAnimationFrame reschedule.
|
|
1120
|
+
*/
|
|
1121
|
+
_boundDraw = this.draw.bind(this);
|
|
936
1122
|
dispatchAnimationEvent(t) {
|
|
937
1123
|
if (!(typeof AnimationEvent > "u"))
|
|
938
|
-
for (const
|
|
939
|
-
typeof
|
|
1124
|
+
for (const e of this.targets)
|
|
1125
|
+
typeof e?.dispatchEvent == "function" && e.dispatchEvent(
|
|
940
1126
|
new AnimationEvent(t, {
|
|
941
1127
|
animationName: this.name ?? "",
|
|
942
1128
|
elapsedTime: this.t / 1e3
|
|
943
1129
|
})
|
|
944
1130
|
);
|
|
945
1131
|
}
|
|
946
|
-
constructor(t,
|
|
947
|
-
this.options = {}, this.setOptions({ ...
|
|
1132
|
+
constructor(t, e, i, r) {
|
|
1133
|
+
this.options = {}, this.setOptions({ ...te, ...t ?? {} }), this.targets = e == null ? [] : Array.isArray(e) ? e : [e], this.name = i, this.superKey = r;
|
|
948
1134
|
}
|
|
949
1135
|
convertFrameStart(t) {
|
|
950
1136
|
if (t.start.unit === "s" || t.start.unit === "ms" || !t.start.unit) {
|
|
951
|
-
const
|
|
952
|
-
t.start.value =
|
|
1137
|
+
const e = t.start.unit === "s" ? "s" : "ms", i = it(t.start.value, e);
|
|
1138
|
+
t.start.value = i / this.options.duration * 100, t.start.unit = "%";
|
|
953
1139
|
}
|
|
954
|
-
return t.start.value =
|
|
1140
|
+
return t.start.value = E(t.start.value, 0, 100), t;
|
|
955
1141
|
}
|
|
956
|
-
addFrame(t,
|
|
1142
|
+
addFrame(t, e, i, r) {
|
|
957
1143
|
typeof t == "number" ? t = String(t) + "%" : typeof t == "string" ? t = t : t instanceof f && (t = String(t));
|
|
958
1144
|
const o = st(t);
|
|
959
|
-
let
|
|
1145
|
+
let n = {
|
|
960
1146
|
id: this.frameId,
|
|
961
1147
|
start: o,
|
|
962
|
-
vars:
|
|
963
|
-
transform:
|
|
964
|
-
timingFunction: M(
|
|
1148
|
+
vars: e,
|
|
1149
|
+
transform: i,
|
|
1150
|
+
timingFunction: M(r) ?? this.options.timingFunction
|
|
965
1151
|
};
|
|
966
1152
|
return this.convertFrameStart(
|
|
967
|
-
|
|
1153
|
+
n
|
|
968
1154
|
), this.templateFrames.push(
|
|
969
|
-
|
|
1155
|
+
n
|
|
970
1156
|
), this.frameId += 1, this;
|
|
971
1157
|
}
|
|
972
|
-
createFrame(t,
|
|
973
|
-
const
|
|
1158
|
+
createFrame(t, e) {
|
|
1159
|
+
const i = this.templateFrames[t], r = this.templateFrames[e], o = {
|
|
974
1160
|
start: t,
|
|
975
|
-
stop:
|
|
976
|
-
},
|
|
977
|
-
let
|
|
978
|
-
if (
|
|
979
|
-
const l =
|
|
1161
|
+
stop: e
|
|
1162
|
+
}, n = Te(i, r, this.options.duration);
|
|
1163
|
+
let u = i.transform;
|
|
1164
|
+
if (u == null) {
|
|
1165
|
+
const l = B(
|
|
980
1166
|
t,
|
|
981
1167
|
this.frames,
|
|
982
1168
|
(h) => h.transform != null
|
|
983
1169
|
);
|
|
984
|
-
|
|
1170
|
+
u = this.frames[l].transform;
|
|
985
1171
|
}
|
|
986
|
-
let
|
|
987
|
-
if (
|
|
988
|
-
const l =
|
|
1172
|
+
let a = i.timingFunction;
|
|
1173
|
+
if (a == null) {
|
|
1174
|
+
const l = B(
|
|
989
1175
|
t,
|
|
990
1176
|
this.frames,
|
|
991
1177
|
(h) => h.timingFunction != null
|
|
992
1178
|
);
|
|
993
|
-
|
|
1179
|
+
a = this.frames[l].timingFunction;
|
|
994
1180
|
}
|
|
995
1181
|
return {
|
|
996
1182
|
id: this.frameId++,
|
|
997
1183
|
ixs: o,
|
|
998
|
-
start:
|
|
999
|
-
time:
|
|
1184
|
+
start: i.start,
|
|
1185
|
+
time: n,
|
|
1000
1186
|
vars: void 0,
|
|
1001
1187
|
flatVars: void 0,
|
|
1002
1188
|
interpVars: {},
|
|
1003
|
-
|
|
1004
|
-
|
|
1189
|
+
allInterpVars: [],
|
|
1190
|
+
transform: u,
|
|
1191
|
+
timingFunction: a
|
|
1005
1192
|
};
|
|
1006
1193
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1194
|
+
/**
|
|
1195
|
+
* Build an index mapping each variable name to the frame indices where
|
|
1196
|
+
* it appears. Used by reconcileVars() for O(1) "next occurrence" lookups
|
|
1197
|
+
* instead of O(N) findIndex scans per variable.
|
|
1198
|
+
*/
|
|
1199
|
+
buildVarIndex() {
|
|
1200
|
+
const t = /* @__PURE__ */ new Map();
|
|
1201
|
+
for (let e = 0; e < this.parsedVars.length; e++)
|
|
1202
|
+
for (const i of Object.keys(this.parsedVars[e])) {
|
|
1203
|
+
let r = t.get(i);
|
|
1204
|
+
r || (r = [], t.set(i, r)), r.push(e);
|
|
1205
|
+
}
|
|
1206
|
+
return t;
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Reconcile interpolation variables across non-adjacent keyframes.
|
|
1210
|
+
* For each variable at frame `ix`, find the next frame that also
|
|
1211
|
+
* defines that variable and create an interpolation segment between them.
|
|
1212
|
+
*
|
|
1213
|
+
* Uses a pre-built variable index (from buildVarIndex) to avoid
|
|
1214
|
+
* O(frames²) findIndex scans.
|
|
1215
|
+
*/
|
|
1216
|
+
reconcileVars(t, e) {
|
|
1217
|
+
const i = this.parsedVars[t];
|
|
1218
|
+
if (i)
|
|
1219
|
+
for (const r of Object.keys(i)) {
|
|
1220
|
+
const o = e.get(r);
|
|
1221
|
+
if (!o) continue;
|
|
1222
|
+
let n = -1;
|
|
1223
|
+
for (const h of o)
|
|
1224
|
+
if (h > t) {
|
|
1225
|
+
n = h;
|
|
1226
|
+
break;
|
|
1227
|
+
}
|
|
1228
|
+
if (n === -1) continue;
|
|
1229
|
+
const [u, a] = [t, n], c = this.frames.findIndex(
|
|
1230
|
+
(h) => h.ixs.start === u && h.ixs.stop === a
|
|
1231
|
+
), l = c !== -1 ? this.frames[c] : this.createFrame(u, a);
|
|
1232
|
+
l.interpVars[r] = Ve(
|
|
1233
|
+
r,
|
|
1234
|
+
u,
|
|
1235
|
+
a,
|
|
1236
|
+
this.parsedVars,
|
|
1237
|
+
this.options.colorSpace,
|
|
1238
|
+
this.options.hueMethod
|
|
1239
|
+
), c === -1 && this.frames.push(l);
|
|
1240
|
+
}
|
|
1027
1241
|
}
|
|
1028
1242
|
parse() {
|
|
1029
|
-
this.frames = [], this.templateFrames.sort((
|
|
1030
|
-
const
|
|
1031
|
-
|
|
1243
|
+
this.frames = [], this.templateFrames.sort((e, i) => e.start.value - i.start.value), this.parsedVars = this.templateFrames.map((e) => {
|
|
1244
|
+
const i = we(
|
|
1245
|
+
e.vars
|
|
1032
1246
|
);
|
|
1033
|
-
return Object.values(
|
|
1034
|
-
|
|
1035
|
-
}),
|
|
1247
|
+
return Object.values(i).forEach((r) => {
|
|
1248
|
+
r.setTargets(this.targets);
|
|
1249
|
+
}), i;
|
|
1036
1250
|
});
|
|
1037
|
-
for (let
|
|
1038
|
-
this.frames.push(this.createFrame(
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1251
|
+
for (let e = 0; e < this.templateFrames.length - 1; e++)
|
|
1252
|
+
this.frames.push(this.createFrame(e, e + 1));
|
|
1253
|
+
const t = this.buildVarIndex();
|
|
1254
|
+
return this.frames.forEach((e, i) => this.reconcileVars(i, t)), this.frames.sort((e, i) => e.time.start === i.time.start ? e.time.stop - i.time.stop : e.time.start - i.time.start), this.frames = this.frames.filter(
|
|
1255
|
+
(e) => e.interpVars != null && Object.keys(e.interpVars).length > 0
|
|
1256
|
+
), this.frames.forEach((e) => {
|
|
1257
|
+
const i = Object.entries(e.interpVars).reduce((r, [o, n]) => (r[o] = n.map((u) => u.value), r), {});
|
|
1258
|
+
e.flatVars = i, e.vars = Ot(e.flatVars), e.allInterpVars = Object.values(e.interpVars).flat();
|
|
1044
1259
|
}), this;
|
|
1045
1260
|
}
|
|
1046
1261
|
setTimingFunction(t) {
|
|
1047
|
-
return this.options.timingFunction = M(t) ??
|
|
1262
|
+
return this.options.timingFunction = M(t) ?? et, this;
|
|
1048
1263
|
}
|
|
1049
1264
|
setIterationCount(t) {
|
|
1050
1265
|
if (!t || t === "infinite" || t === "∞" || t === "Infinity")
|
|
1051
1266
|
this.options.iterationCount = 1 / 0;
|
|
1052
1267
|
else if (typeof t == "string") {
|
|
1053
|
-
const
|
|
1054
|
-
if (isNaN(
|
|
1055
|
-
this.options.iterationCount =
|
|
1268
|
+
const e = parseFloat(t.trim());
|
|
1269
|
+
if (isNaN(e) || e < 0) return this;
|
|
1270
|
+
this.options.iterationCount = e;
|
|
1056
1271
|
} else {
|
|
1057
1272
|
if (isNaN(t) || t < 0) return this;
|
|
1058
1273
|
this.options.iterationCount = t;
|
|
@@ -1060,18 +1275,18 @@ class pt {
|
|
|
1060
1275
|
return this;
|
|
1061
1276
|
}
|
|
1062
1277
|
setDuration(t) {
|
|
1063
|
-
typeof t == "string" && (t =
|
|
1064
|
-
const
|
|
1065
|
-
if (!isFinite(
|
|
1066
|
-
const
|
|
1278
|
+
typeof t == "string" && (t = L(t));
|
|
1279
|
+
const e = t ?? this.options.duration;
|
|
1280
|
+
if (!isFinite(e) || e <= 0) return this;
|
|
1281
|
+
const i = this.options.duration, r = e / i;
|
|
1067
1282
|
for (let o = 0; o < this.frames.length; o++) {
|
|
1068
|
-
const
|
|
1069
|
-
|
|
1283
|
+
const n = this.frames[o];
|
|
1284
|
+
n.time.start *= r, n.time.stop *= r;
|
|
1070
1285
|
}
|
|
1071
|
-
return this.options.duration =
|
|
1286
|
+
return this.options.duration = e, this;
|
|
1072
1287
|
}
|
|
1073
1288
|
setDelay(t) {
|
|
1074
|
-
return typeof t == "string" && (t =
|
|
1289
|
+
return typeof t == "string" && (t = L(t)), this.options.delay = t ?? 0, this;
|
|
1075
1290
|
}
|
|
1076
1291
|
setDirection(t) {
|
|
1077
1292
|
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;
|
|
@@ -1093,8 +1308,8 @@ class pt {
|
|
|
1093
1308
|
}
|
|
1094
1309
|
reverse() {
|
|
1095
1310
|
if (this.startTime !== void 0) {
|
|
1096
|
-
const t = this.t,
|
|
1097
|
-
this.startTime -=
|
|
1311
|
+
const t = this.t, e = this.options.duration - 2 * t;
|
|
1312
|
+
this.startTime -= e;
|
|
1098
1313
|
}
|
|
1099
1314
|
return this.reversed = !this.reversed, this;
|
|
1100
1315
|
}
|
|
@@ -1108,32 +1323,56 @@ class pt {
|
|
|
1108
1323
|
* Stateless progress query. Maps [0,1] from first keyframe to last,
|
|
1109
1324
|
* regardless of playback direction. `apply=true` invokes transform callbacks.
|
|
1110
1325
|
*/
|
|
1111
|
-
at(t,
|
|
1112
|
-
const
|
|
1326
|
+
at(t, e = !1) {
|
|
1327
|
+
const i = this.reversed;
|
|
1113
1328
|
this.reversed = !1;
|
|
1114
|
-
const
|
|
1115
|
-
return this.reversed =
|
|
1329
|
+
const r = E(t, 0, 1) * this.options.duration, o = this.interpFrames(r, e);
|
|
1330
|
+
return this.reversed = i, o;
|
|
1116
1331
|
}
|
|
1117
|
-
|
|
1332
|
+
/**
|
|
1333
|
+
* Interpolate all active frames at time `t`. This is the hot path —
|
|
1334
|
+
* called once per rAF frame during playback.
|
|
1335
|
+
*
|
|
1336
|
+
* Uses binary search (O(log N)) to find the first matching frame,
|
|
1337
|
+
* then scans neighbors to collect all overlapping frames at `t`
|
|
1338
|
+
* (multiple properties may share the same time range).
|
|
1339
|
+
*
|
|
1340
|
+
* @param t - Current animation time in milliseconds
|
|
1341
|
+
* @param transformFrames - If true, applies each frame's transform function to targets
|
|
1342
|
+
* @returns Merged flat vars from all active frames
|
|
1343
|
+
*/
|
|
1344
|
+
interpFrames(t, e = !1) {
|
|
1118
1345
|
t = this.reversed ? this.options.duration - t : t;
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1346
|
+
const i = {}, r = this.frames, o = r.length, n = lt(
|
|
1347
|
+
r,
|
|
1348
|
+
t,
|
|
1349
|
+
(a) => a.time.start,
|
|
1350
|
+
(a) => a.time.stop
|
|
1351
|
+
);
|
|
1352
|
+
if (n === -1) return i;
|
|
1353
|
+
const u = (a) => {
|
|
1354
|
+
const { start: c, stop: l } = a.time, h = at(t, c, l, 0, 1), m = a.timingFunction(h);
|
|
1355
|
+
for (const p of a.allInterpVars)
|
|
1356
|
+
ye(m, p);
|
|
1357
|
+
e && a.transform(
|
|
1358
|
+
this.unflatten ? a.vars : a.flatVars,
|
|
1130
1359
|
t
|
|
1131
|
-
), Object.assign(
|
|
1360
|
+
), Object.assign(i, a.flatVars);
|
|
1361
|
+
};
|
|
1362
|
+
for (let a = n; a >= 0; a--) {
|
|
1363
|
+
const c = r[a];
|
|
1364
|
+
if (t < c.time.start || t > c.time.stop) break;
|
|
1365
|
+
u(c);
|
|
1366
|
+
}
|
|
1367
|
+
for (let a = n + 1; a < o; a++) {
|
|
1368
|
+
const c = r[a];
|
|
1369
|
+
if (t < c.time.start || t > c.time.stop) break;
|
|
1370
|
+
u(c);
|
|
1132
1371
|
}
|
|
1133
|
-
return
|
|
1372
|
+
return i;
|
|
1134
1373
|
}
|
|
1135
1374
|
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
|
|
1375
|
+
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 _t(this.options.delay), this.paused = !1), this.started = !0;
|
|
1137
1376
|
}
|
|
1138
1377
|
async onEnd() {
|
|
1139
1378
|
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"));
|
|
@@ -1142,24 +1381,24 @@ class pt {
|
|
|
1142
1381
|
if (this.startTime === void 0 && (await this.onStart(), this.startTime = t + this.options.delay, this.dispatchAnimationEvent("animationstart")), this.paused && this.pausedTime === 0)
|
|
1143
1382
|
return this.pausedTime = t, this.t;
|
|
1144
1383
|
if (this.pausedTime > 0 && !this.paused) {
|
|
1145
|
-
const
|
|
1146
|
-
this.startTime +=
|
|
1384
|
+
const e = t - this.pausedTime;
|
|
1385
|
+
this.startTime += e, this.pausedTime = 0;
|
|
1147
1386
|
}
|
|
1148
1387
|
return this.t = t - this.startTime, this.t >= this.options.duration && (await this.onEnd(), this.t = this.options.duration), this.t;
|
|
1149
1388
|
}
|
|
1150
1389
|
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 =
|
|
1390
|
+
this.managed || (t = await this.tick(t), !this.paused && (this.interpFrames(t, !0), this.done ? (this.reset(), this.resolvePromise && this.resolvePromise()) : this.handleId = w(this._boundDraw)));
|
|
1152
1391
|
}
|
|
1153
1392
|
/** Internal rAF-based play loop. */
|
|
1154
1393
|
_playRAF() {
|
|
1155
1394
|
return new Promise((t) => {
|
|
1156
|
-
this.resolvePromise = t, this.handleId =
|
|
1395
|
+
this.resolvePromise = t, this.handleId = w(this._boundDraw);
|
|
1157
1396
|
});
|
|
1158
1397
|
}
|
|
1159
1398
|
/** Play via the Web Animations API for compositor-thread execution. */
|
|
1160
1399
|
async _playWAAPI() {
|
|
1161
1400
|
try {
|
|
1162
|
-
await
|
|
1401
|
+
await ke(this), this.reset();
|
|
1163
1402
|
} catch {
|
|
1164
1403
|
return this._playRAF();
|
|
1165
1404
|
}
|
|
@@ -1169,7 +1408,7 @@ class pt {
|
|
|
1169
1408
|
return;
|
|
1170
1409
|
if (this._playingPromise) return this._playingPromise;
|
|
1171
1410
|
let t;
|
|
1172
|
-
return this.options.useWAAPI && this.targets.length > 0 && typeof this.targets[0]?.animate == "function" &&
|
|
1411
|
+
return this.options.useWAAPI && this.targets.length > 0 && typeof this.targets[0]?.animate == "function" && Ce(this) ? t = this._playWAAPI() : t = this._playRAF(), this._playingPromise = t, t.finally(() => {
|
|
1173
1412
|
this._playingPromise = null;
|
|
1174
1413
|
}), t;
|
|
1175
1414
|
}
|
|
@@ -1177,10 +1416,10 @@ class pt {
|
|
|
1177
1416
|
return this.paused && t ? this.resume() : (this.started && (this.paused = !0), this);
|
|
1178
1417
|
}
|
|
1179
1418
|
resume() {
|
|
1180
|
-
return this.started && this.paused && (this.paused = !1, this.handleId =
|
|
1419
|
+
return this.started && this.paused && (this.paused = !1, this.handleId = w(this._boundDraw)), this;
|
|
1181
1420
|
}
|
|
1182
1421
|
stop() {
|
|
1183
|
-
|
|
1422
|
+
k(this.handleId), this.reset();
|
|
1184
1423
|
}
|
|
1185
1424
|
playing() {
|
|
1186
1425
|
return !(!this.started || this.paused);
|
|
@@ -1193,96 +1432,108 @@ class pt {
|
|
|
1193
1432
|
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
1433
|
}
|
|
1195
1434
|
setTargets(...t) {
|
|
1196
|
-
return this.targets = t, this.frames.forEach((
|
|
1197
|
-
Object.values(
|
|
1198
|
-
|
|
1199
|
-
|
|
1435
|
+
return this.targets = t, this.frames.forEach((e) => {
|
|
1436
|
+
Object.values(e.interpVars).forEach((i) => {
|
|
1437
|
+
i.forEach(({ start: r, stop: o, value: n }) => {
|
|
1438
|
+
r.setTargets(this.targets), o.setTargets(this.targets), n.setTargets(this.targets);
|
|
1200
1439
|
});
|
|
1201
1440
|
});
|
|
1202
1441
|
}), this;
|
|
1203
1442
|
}
|
|
1204
1443
|
group(...t) {
|
|
1205
|
-
return new
|
|
1444
|
+
return new se(this, ...t);
|
|
1206
1445
|
}
|
|
1207
1446
|
}
|
|
1208
|
-
class
|
|
1209
|
-
constructor(t, ...
|
|
1210
|
-
super(t,
|
|
1211
|
-
}
|
|
1212
|
-
fromVars(t,
|
|
1213
|
-
this.unflatten =
|
|
1214
|
-
for (let
|
|
1215
|
-
const
|
|
1216
|
-
this.addFrame(o,
|
|
1447
|
+
class Ne extends gt {
|
|
1448
|
+
constructor(t, ...e) {
|
|
1449
|
+
super(t, e), this.unflatten = !1;
|
|
1450
|
+
}
|
|
1451
|
+
fromVars(t, e) {
|
|
1452
|
+
this.unflatten = e != null, e ??= this.transform.bind(this);
|
|
1453
|
+
for (let i = 0; i < t.length; i++) {
|
|
1454
|
+
const r = t[i], o = Math.round(i / (t.length - 1) * 100);
|
|
1455
|
+
this.addFrame(o, r, e);
|
|
1217
1456
|
}
|
|
1218
1457
|
return this.parse(), this;
|
|
1219
1458
|
}
|
|
1220
|
-
fromKeyframes(t,
|
|
1221
|
-
this.unflatten =
|
|
1222
|
-
const
|
|
1223
|
-
for (const [
|
|
1224
|
-
this.addFrame(
|
|
1459
|
+
fromKeyframes(t, e) {
|
|
1460
|
+
this.unflatten = e != null, e ??= this.transform.bind(this), kt(t) && (t = new Map(Object.entries(t)));
|
|
1461
|
+
const i = t instanceof Map ? t.entries() : Object.entries(t);
|
|
1462
|
+
for (const [r, o] of i)
|
|
1463
|
+
this.addFrame(r, o, e);
|
|
1225
1464
|
return this.parse(), this;
|
|
1226
1465
|
}
|
|
1227
|
-
fromString(t,
|
|
1228
|
-
this.unflatten =
|
|
1229
|
-
const
|
|
1230
|
-
for (const [
|
|
1231
|
-
const
|
|
1466
|
+
fromString(t, e) {
|
|
1467
|
+
this.unflatten = e != null, e ??= this.transform.bind(this);
|
|
1468
|
+
const i = Jt(t);
|
|
1469
|
+
for (const [r, o] of i.entries()) {
|
|
1470
|
+
const n = Object.fromEntries(
|
|
1232
1471
|
Object.entries(o).map(([c, l]) => [
|
|
1233
1472
|
c,
|
|
1234
|
-
|
|
1473
|
+
Me(l) ? l.clone() : l
|
|
1235
1474
|
])
|
|
1236
|
-
),
|
|
1237
|
-
delete
|
|
1238
|
-
const
|
|
1239
|
-
this.addFrame(
|
|
1475
|
+
), u = n.animationTimingFunction ?? n.timingFunction;
|
|
1476
|
+
delete n.animationTimingFunction, delete n.timingFunction;
|
|
1477
|
+
const a = u ? M(u.toString()) : void 0;
|
|
1478
|
+
this.addFrame(r, n, e, a);
|
|
1240
1479
|
}
|
|
1241
1480
|
return this.parse(), this;
|
|
1242
1481
|
}
|
|
1243
1482
|
transform(t) {
|
|
1244
|
-
|
|
1483
|
+
mt(t, this.targets);
|
|
1245
1484
|
}
|
|
1246
1485
|
}
|
|
1247
1486
|
export {
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1487
|
+
gt as Animation,
|
|
1488
|
+
se as AnimationGroup,
|
|
1489
|
+
Ye as CSSCubicBezier,
|
|
1490
|
+
Ne as CSSKeyframesAnimation,
|
|
1491
|
+
Ue as ElementMorph,
|
|
1492
|
+
De as ManualTimeline,
|
|
1254
1493
|
Se as NumericAnimation,
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1494
|
+
$e as ScrollTimeline,
|
|
1495
|
+
Fe as SmoothProgress,
|
|
1496
|
+
dt as Timeline,
|
|
1497
|
+
Be as bezierPresets,
|
|
1259
1498
|
Re as bounceInEase,
|
|
1260
1499
|
We as bounceInEaseHalf,
|
|
1261
1500
|
Le as bounceInOutEase,
|
|
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
|
-
|
|
1501
|
+
Xe as bounceOutEase,
|
|
1502
|
+
He as bounceOutEaseHalf,
|
|
1503
|
+
Ge as cancelAnimationFrame,
|
|
1504
|
+
qe as clamp,
|
|
1505
|
+
Ze as cubicBezier,
|
|
1506
|
+
Qe as cubicBezierToSVG,
|
|
1507
|
+
Je as cubicBezierToString,
|
|
1508
|
+
ts as deCasteljau,
|
|
1509
|
+
es as easeInBounce,
|
|
1510
|
+
ss as easeInCirc,
|
|
1511
|
+
is as easeInCubic,
|
|
1512
|
+
rs as easeInExpo,
|
|
1513
|
+
ns as easeInOutCirc,
|
|
1514
|
+
os as easeInOutCubic,
|
|
1515
|
+
as as easeInOutExpo,
|
|
1516
|
+
us as easeInOutQuad,
|
|
1517
|
+
ls as easeInOutSine,
|
|
1518
|
+
cs as easeInQuad,
|
|
1519
|
+
hs as easeInSine,
|
|
1520
|
+
fs as easeOutCirc,
|
|
1521
|
+
ps as easeOutCubic,
|
|
1522
|
+
ms as easeOutExpo,
|
|
1523
|
+
ds as easeOutQuad,
|
|
1524
|
+
gs as easeOutSine,
|
|
1525
|
+
x as getAnimationId,
|
|
1526
|
+
ys as interpBezier,
|
|
1527
|
+
ws as jumpTerms,
|
|
1528
|
+
Vs as lerp,
|
|
1529
|
+
Ts as linear,
|
|
1530
|
+
bs as logerp,
|
|
1531
|
+
Ss as requestAnimationFrame,
|
|
1532
|
+
vs as scale,
|
|
1533
|
+
Fs as sleep,
|
|
1534
|
+
Is as smoothStep3,
|
|
1535
|
+
Ps as stepEnd,
|
|
1536
|
+
Es as stepStart,
|
|
1537
|
+
Cs as steppedEase,
|
|
1538
|
+
Os as timingFunctions
|
|
1288
1539
|
};
|