@mkbabb/keyframes.js 2.1.1 → 3.0.0
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/LICENSE +1 -1
- package/README.md +36 -1
- package/dist/css-easing-DoPNckiS.js +55 -0
- package/dist/engine-B7JGZTdU.js +742 -0
- package/dist/keyframes.d.ts +213 -38
- package/dist/keyframes.js +108 -787
- package/package.json +10 -4
- package/dist/_redirects +0 -1
package/dist/keyframes.js
CHANGED
|
@@ -1,353 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return -1;
|
|
13
|
-
}
|
|
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;
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s } from "./css-easing-DoPNckiS.js";
|
|
2
|
+
//#region src/animation/internal/easing-resolvable.ts
|
|
3
|
+
var c = (e) => e, l = class {
|
|
4
|
+
_fn;
|
|
5
|
+
_pendingName = null;
|
|
6
|
+
_ready = null;
|
|
7
|
+
_onResolved;
|
|
8
|
+
_warned = !1;
|
|
9
|
+
constructor(e, t) {
|
|
10
|
+
this._onResolved = t, typeof e == "function" ? this._fn = e : typeof e == "string" ? (this._fn = c, this._pendingName = e, this.ready()) : this._fn = c;
|
|
216
11
|
}
|
|
217
|
-
|
|
218
|
-
this.
|
|
219
|
-
for (let e of this.getEntries()) e.animation.paused = !1;
|
|
12
|
+
get fn() {
|
|
13
|
+
return this._fn;
|
|
220
14
|
}
|
|
221
|
-
|
|
222
|
-
|
|
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;
|
|
15
|
+
get pending() {
|
|
16
|
+
return this._pendingName !== null;
|
|
225
17
|
}
|
|
226
|
-
|
|
227
|
-
|
|
18
|
+
ready() {
|
|
19
|
+
if (this._pendingName === null) return Promise.resolve();
|
|
20
|
+
if (this._ready) return this._ready;
|
|
21
|
+
let e = this._pendingName;
|
|
22
|
+
return this._ready = import("./engine-B7JGZTdU.js").then((t) => {
|
|
23
|
+
let n = t.getTimingFunction(e);
|
|
24
|
+
n && (this._fn = n, this._onResolved?.(n)), this._pendingName = null;
|
|
25
|
+
}), this._ready;
|
|
228
26
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
return this.animations[t]?.layer;
|
|
27
|
+
warnIfPending(e) {
|
|
28
|
+
this._pendingName !== null && !this._warned && (this._warned = !0, console.warn(`[keyframes] ${e}: easing "${this._pendingName}" is still resolving — interpolating with the identity fallback until it lands. \`await .ready()\` before the first synchronous \`.at()\` to interpolate with the named curve from the first frame.`));
|
|
232
29
|
}
|
|
233
|
-
},
|
|
30
|
+
}, u = class {
|
|
234
31
|
_rafId = null;
|
|
235
32
|
_startTime = void 0;
|
|
236
33
|
_resolve = null;
|
|
237
|
-
play(
|
|
238
|
-
if (
|
|
239
|
-
return this.stop(), new Promise((
|
|
240
|
-
this._resolve =
|
|
241
|
-
let
|
|
242
|
-
this._startTime === void 0 && (this._startTime =
|
|
243
|
-
let
|
|
244
|
-
|
|
34
|
+
play(t, n, r) {
|
|
35
|
+
if (t <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
|
|
36
|
+
return this.stop(), r?.respectReducedMotion && o() ? (n(1), Promise.resolve()) : new Promise((r) => {
|
|
37
|
+
this._resolve = r, this._startTime = void 0;
|
|
38
|
+
let i = (r) => {
|
|
39
|
+
this._startTime === void 0 && (this._startTime = r);
|
|
40
|
+
let a = e((r - this._startTime) / t, 0, 1);
|
|
41
|
+
n(a), a < 1 ? this._rafId = s(i) : this._cleanup();
|
|
245
42
|
};
|
|
246
|
-
this._rafId =
|
|
43
|
+
this._rafId = s(i);
|
|
247
44
|
});
|
|
248
45
|
}
|
|
249
46
|
stop() {
|
|
250
|
-
this._rafId !== null &&
|
|
47
|
+
this._rafId !== null && n(this._rafId), this._cleanup();
|
|
251
48
|
}
|
|
252
49
|
_cleanup() {
|
|
253
50
|
this._rafId = null, this._startTime = void 0;
|
|
254
51
|
let e = this._resolve;
|
|
255
52
|
this._resolve = null, e?.();
|
|
256
53
|
}
|
|
257
|
-
},
|
|
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), {});
|
|
295
|
-
}
|
|
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
|
-
});
|
|
316
|
-
};
|
|
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
|
-
};
|
|
323
|
-
}
|
|
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
|
-
});
|
|
332
|
-
}
|
|
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;
|
|
338
|
-
}
|
|
339
|
-
var pe = (e) => e, U = class {
|
|
54
|
+
}, d = class {
|
|
340
55
|
keyframes;
|
|
341
56
|
segments;
|
|
342
57
|
positions;
|
|
343
|
-
timingFn;
|
|
344
58
|
result;
|
|
345
59
|
_duration;
|
|
346
60
|
_respectReducedMotion;
|
|
347
|
-
|
|
61
|
+
_easing;
|
|
62
|
+
_playback = new u();
|
|
348
63
|
constructor(e, t) {
|
|
349
64
|
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.
|
|
65
|
+
if (this.keyframes = e.map((e) => ({ ...e })), this._duration = t?.duration ?? 0, this._respectReducedMotion = t?.respectReducedMotion ?? !1, this._easing = new l(t?.timingFunction, () => {
|
|
66
|
+
this.segments = this.buildSegments();
|
|
67
|
+
}), t?.positions) {
|
|
351
68
|
if (t.positions.length !== e.length) throw Error("positions length must match keyframes length.");
|
|
352
69
|
this.positions = t.positions;
|
|
353
70
|
} else this.positions = e.map((t, n) => n / (e.length - 1) * 100);
|
|
@@ -366,46 +83,43 @@ var pe = (e) => e, U = class {
|
|
|
366
83
|
keys: r,
|
|
367
84
|
startVals: r.map((e) => t[e]),
|
|
368
85
|
stopVals: r.map((e) => n[e]),
|
|
369
|
-
timingFunction: this.
|
|
86
|
+
timingFunction: this._easing.fn
|
|
370
87
|
};
|
|
371
88
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
89
|
+
ready() {
|
|
90
|
+
return this._easing.ready();
|
|
91
|
+
}
|
|
92
|
+
at(n) {
|
|
93
|
+
this._easing.warnIfPending("NumericAnimation.at()");
|
|
94
|
+
let i = e(n, 0, 1) * 100, o = r(this.segments, i, (e) => e.startPos, (e) => e.stopPos);
|
|
95
|
+
o === -1 && (o = this.segments.length - 1);
|
|
96
|
+
let s = this.segments[o], c = t(e(i, s.startPos, s.stopPos), s.startPos, s.stopPos, 0, 1), l = s.timingFunction(c);
|
|
97
|
+
for (let e = 0; e < s.keys.length; e++) this.result[s.keys[e]] = a(s.startVals[e], s.stopVals[e], l);
|
|
377
98
|
return this.result;
|
|
378
99
|
}
|
|
379
100
|
updateKeyframe(e, t) {
|
|
380
101
|
if (e < 0 || e >= this.keyframes.length) throw RangeError(`Keyframe index ${e} out of range [0, ${this.keyframes.length - 1}].`);
|
|
381
102
|
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
103
|
}
|
|
383
|
-
play(e, t) {
|
|
104
|
+
async play(e, t) {
|
|
105
|
+
await this.ready();
|
|
384
106
|
let n = t ?? this._duration;
|
|
385
|
-
|
|
386
|
-
let t = this.at(1);
|
|
387
|
-
return e?.(t), Promise.resolve();
|
|
388
|
-
}
|
|
389
|
-
return this._playback.play(n, (t) => {
|
|
107
|
+
await this._playback.play(n, (t) => {
|
|
390
108
|
let n = this.at(t);
|
|
391
109
|
e?.(n);
|
|
392
|
-
});
|
|
110
|
+
}, { respectReducedMotion: this._respectReducedMotion });
|
|
393
111
|
}
|
|
394
112
|
stop() {
|
|
395
113
|
this._playback.stop();
|
|
396
114
|
}
|
|
397
|
-
},
|
|
115
|
+
}, f = {
|
|
398
116
|
damping: .1,
|
|
399
117
|
snapThreshold: .001,
|
|
400
118
|
targetEpsilon: 0,
|
|
401
119
|
initial: 0,
|
|
402
120
|
clamp: !0,
|
|
403
121
|
respectReducedMotion: !1
|
|
404
|
-
}
|
|
405
|
-
function W() {
|
|
406
|
-
return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
407
|
-
}
|
|
408
|
-
var G = class {
|
|
122
|
+
}, p = class {
|
|
409
123
|
options;
|
|
410
124
|
targetValue;
|
|
411
125
|
currentValue;
|
|
@@ -415,7 +129,7 @@ var G = class {
|
|
|
415
129
|
_onFrame = void 0;
|
|
416
130
|
constructor(e) {
|
|
417
131
|
this.options = {
|
|
418
|
-
...
|
|
132
|
+
...f,
|
|
419
133
|
...e
|
|
420
134
|
}, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
|
|
421
135
|
}
|
|
@@ -432,7 +146,7 @@ var G = class {
|
|
|
432
146
|
this.options.clamp && (e = Math.max(0, Math.min(1, e)));
|
|
433
147
|
let t = Math.abs(e - this.targetValue);
|
|
434
148
|
if (t > 0 && t >= this.options.targetEpsilon) {
|
|
435
|
-
if (this.targetValue = e, this.options.respectReducedMotion &&
|
|
149
|
+
if (this.targetValue = e, this.options.respectReducedMotion && o()) {
|
|
436
150
|
this.currentValue = e, this.isSettled = !0, this._onFrame?.(e);
|
|
437
151
|
return;
|
|
438
152
|
}
|
|
@@ -455,7 +169,7 @@ var G = class {
|
|
|
455
169
|
this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._stopLoop();
|
|
456
170
|
}
|
|
457
171
|
play(e) {
|
|
458
|
-
if (this._onFrame = e, this.options.respectReducedMotion &&
|
|
172
|
+
if (this._onFrame = e, this.options.respectReducedMotion && o()) {
|
|
459
173
|
this.currentValue = this.targetValue, this.isSettled = !0, e?.(this.currentValue);
|
|
460
174
|
return;
|
|
461
175
|
}
|
|
@@ -479,14 +193,14 @@ var G = class {
|
|
|
479
193
|
this._stopLoop();
|
|
480
194
|
return;
|
|
481
195
|
}
|
|
482
|
-
this._rafId =
|
|
196
|
+
this._rafId = s(e);
|
|
483
197
|
};
|
|
484
|
-
this._rafId =
|
|
198
|
+
this._rafId = s(e);
|
|
485
199
|
}
|
|
486
200
|
_stopLoop() {
|
|
487
|
-
this._rafId !== null && (
|
|
201
|
+
this._rafId !== null && (n(this._rafId), this._rafId = null), this._lastFrameT = 0;
|
|
488
202
|
}
|
|
489
|
-
},
|
|
203
|
+
}, m = {
|
|
490
204
|
response: .5,
|
|
491
205
|
dampingFraction: .86,
|
|
492
206
|
initial: 0,
|
|
@@ -494,11 +208,7 @@ var G = class {
|
|
|
494
208
|
settleThreshold: .001,
|
|
495
209
|
velocitySettleThreshold: .001,
|
|
496
210
|
respectReducedMotion: !1
|
|
497
|
-
}
|
|
498
|
-
function K() {
|
|
499
|
-
return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
500
|
-
}
|
|
501
|
-
var q = class {
|
|
211
|
+
}, h = class {
|
|
502
212
|
options;
|
|
503
213
|
targetValue;
|
|
504
214
|
currentValue;
|
|
@@ -517,7 +227,7 @@ var q = class {
|
|
|
517
227
|
_onFrame = void 0;
|
|
518
228
|
constructor(e) {
|
|
519
229
|
this.options = {
|
|
520
|
-
...
|
|
230
|
+
...m,
|
|
521
231
|
...e
|
|
522
232
|
}, 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
233
|
}
|
|
@@ -537,7 +247,7 @@ var q = class {
|
|
|
537
247
|
e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
|
|
538
248
|
}
|
|
539
249
|
reseatTarget(e) {
|
|
540
|
-
if (this.targetValue = e, this.options.respectReducedMotion &&
|
|
250
|
+
if (this.targetValue = e, this.options.respectReducedMotion && o()) {
|
|
541
251
|
this.currentValue = e, this.currentVelocity = 0, this.isSettled = !0, this.originValue = e, this.originVelocity = 0, this.elapsed = 0, this.emit(), this._stopLoop();
|
|
542
252
|
return;
|
|
543
253
|
}
|
|
@@ -587,7 +297,7 @@ var q = class {
|
|
|
587
297
|
}
|
|
588
298
|
play(e) {
|
|
589
299
|
if (!this.disposed) {
|
|
590
|
-
if (this._onFrame = e, this.options.respectReducedMotion &&
|
|
300
|
+
if (this._onFrame = e, this.options.respectReducedMotion && o()) {
|
|
591
301
|
this.currentValue = this.targetValue, this.currentVelocity = 0, this.isSettled = !0, e?.(this.currentValue, this.currentVelocity);
|
|
592
302
|
return;
|
|
593
303
|
}
|
|
@@ -610,18 +320,18 @@ var q = class {
|
|
|
610
320
|
this._stopLoop();
|
|
611
321
|
return;
|
|
612
322
|
}
|
|
613
|
-
this._rafId =
|
|
323
|
+
this._rafId = s(e);
|
|
614
324
|
};
|
|
615
|
-
this._rafId =
|
|
325
|
+
this._rafId = s(e);
|
|
616
326
|
}
|
|
617
327
|
_stopLoop() {
|
|
618
|
-
this._rafId !== null && (
|
|
328
|
+
this._rafId !== null && (n(this._rafId), this._rafId = null), this._lastFrameT = 0;
|
|
619
329
|
}
|
|
620
330
|
};
|
|
621
331
|
//#endregion
|
|
622
332
|
//#region src/animation/springLinearStops.ts
|
|
623
|
-
function
|
|
624
|
-
let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = new
|
|
333
|
+
function g(e) {
|
|
334
|
+
let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = new h({
|
|
625
335
|
response: e.response,
|
|
626
336
|
dampingFraction: e.dampingFraction,
|
|
627
337
|
initial: 0,
|
|
@@ -639,29 +349,34 @@ function ge(e) {
|
|
|
639
349
|
}
|
|
640
350
|
//#endregion
|
|
641
351
|
//#region src/animation/springTimingFunction.ts
|
|
642
|
-
function
|
|
643
|
-
let t = e.sampleCount ?? 64, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4,
|
|
352
|
+
function _(e) {
|
|
353
|
+
let t = e.sampleCount ?? 64, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, a = new h({
|
|
644
354
|
response: e.response,
|
|
645
355
|
dampingFraction: e.dampingFraction,
|
|
646
356
|
initial: 0,
|
|
647
357
|
settleThreshold: n,
|
|
648
358
|
velocitySettleThreshold: n
|
|
649
359
|
});
|
|
650
|
-
|
|
651
|
-
let
|
|
652
|
-
|
|
653
|
-
let
|
|
654
|
-
for (let e = 1; e <= t; e++)
|
|
655
|
-
|
|
360
|
+
a.target = 1;
|
|
361
|
+
let o = new Float64Array(t + 1);
|
|
362
|
+
o[0] = 0;
|
|
363
|
+
let s = r / t;
|
|
364
|
+
for (let e = 1; e <= t; e++) a.tick(s), o[e] = a.settled ? 1 : a.value;
|
|
365
|
+
o[t] = 1, a.dispose();
|
|
366
|
+
let c = (e) => {
|
|
656
367
|
if (e <= 0) return 0;
|
|
657
368
|
if (e >= 1) return 1;
|
|
658
|
-
let n = e * t, r = Math.floor(n), i = n - r,
|
|
659
|
-
return
|
|
369
|
+
let n = e * t, r = Math.floor(n), i = n - r, a = o[r];
|
|
370
|
+
return a + (o[r + 1] - a) * i;
|
|
371
|
+
}, l = {
|
|
372
|
+
response: e.response,
|
|
373
|
+
dampingFraction: e.dampingFraction
|
|
660
374
|
};
|
|
375
|
+
return e.settleThreshold !== void 0 && (l.settleThreshold = e.settleThreshold), e.maxDuration !== void 0 && (l.maxDuration = e.maxDuration), i(c, g(l));
|
|
661
376
|
}
|
|
662
377
|
//#endregion
|
|
663
378
|
//#region src/animation/morph.ts
|
|
664
|
-
var
|
|
379
|
+
var v = (e) => {
|
|
665
380
|
if (e instanceof HTMLElement) {
|
|
666
381
|
let t = e.getBoundingClientRect();
|
|
667
382
|
return {
|
|
@@ -672,7 +387,7 @@ var J = (e) => {
|
|
|
672
387
|
};
|
|
673
388
|
}
|
|
674
389
|
return e;
|
|
675
|
-
},
|
|
390
|
+
}, y = class {
|
|
676
391
|
animation;
|
|
677
392
|
transformOrigin;
|
|
678
393
|
timingFunction;
|
|
@@ -681,8 +396,8 @@ var J = (e) => {
|
|
|
681
396
|
this.transformOrigin = n?.transformOrigin ?? "top left", this.timingFunction = n?.timingFunction, this.duration = n?.duration ?? 0, this.measure(e, t);
|
|
682
397
|
}
|
|
683
398
|
measure(e, t) {
|
|
684
|
-
let n =
|
|
685
|
-
return this.animation = new
|
|
399
|
+
let n = v(e), r = v(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;
|
|
400
|
+
return this.animation = new d([{
|
|
686
401
|
translateX: 0,
|
|
687
402
|
translateY: 0,
|
|
688
403
|
scaleX: 1,
|
|
@@ -697,6 +412,9 @@ var J = (e) => {
|
|
|
697
412
|
duration: this.duration
|
|
698
413
|
}), this;
|
|
699
414
|
}
|
|
415
|
+
ready() {
|
|
416
|
+
return this.animation.ready();
|
|
417
|
+
}
|
|
700
418
|
at(e) {
|
|
701
419
|
return this.animation.at(e);
|
|
702
420
|
}
|
|
@@ -716,22 +434,21 @@ var J = (e) => {
|
|
|
716
434
|
stop() {
|
|
717
435
|
this.animation.stop();
|
|
718
436
|
}
|
|
719
|
-
},
|
|
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 {
|
|
437
|
+
}, b = (e) => Math.max(0, Math.min(1, e)), x = class {
|
|
725
438
|
smoother;
|
|
726
|
-
|
|
439
|
+
_easing;
|
|
727
440
|
currentProgress = 0;
|
|
728
441
|
boundaryEpsilon;
|
|
729
442
|
constructor(e) {
|
|
730
|
-
this.
|
|
443
|
+
this.boundaryEpsilon = e?.boundaryEpsilon ?? .005, this._easing = new l(e?.easing), e?.smoothing === !1 ? this.smoother = null : this.smoother = new p(e?.smoothing);
|
|
444
|
+
}
|
|
445
|
+
ready() {
|
|
446
|
+
return this._easing.ready();
|
|
731
447
|
}
|
|
732
448
|
applyPipeline() {
|
|
733
|
-
|
|
734
|
-
|
|
449
|
+
this._easing.warnIfPending("Timeline.tick()");
|
|
450
|
+
let e = b(this.sample());
|
|
451
|
+
e = this._easing.fn(e);
|
|
735
452
|
let t = this.boundaryEpsilon;
|
|
736
453
|
return e <= t ? e = 0 : e >= 1 - t && (e = 1), e;
|
|
737
454
|
}
|
|
@@ -761,7 +478,7 @@ var J = (e) => {
|
|
|
761
478
|
let t = e ?? 0;
|
|
762
479
|
this.smoother && this.smoother.reset(t), this.currentProgress = t;
|
|
763
480
|
}
|
|
764
|
-
},
|
|
481
|
+
}, S = class extends x {
|
|
765
482
|
threshold;
|
|
766
483
|
getScrollY;
|
|
767
484
|
getViewportHeight;
|
|
@@ -772,7 +489,7 @@ var J = (e) => {
|
|
|
772
489
|
let e = this.getViewportHeight() * this.threshold;
|
|
773
490
|
return e <= 0 ? 0 : this.getScrollY() / e;
|
|
774
491
|
}
|
|
775
|
-
},
|
|
492
|
+
}, C = class extends x {
|
|
776
493
|
value = 0;
|
|
777
494
|
constructor(e) {
|
|
778
495
|
super({
|
|
@@ -786,402 +503,6 @@ var J = (e) => {
|
|
|
786
503
|
sample() {
|
|
787
504
|
return this.value;
|
|
788
505
|
}
|
|
789
|
-
},
|
|
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 };
|
|
821
|
-
}
|
|
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;
|
|
836
|
-
}
|
|
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
|
-
};
|
|
860
|
-
}
|
|
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
|
-
}
|
|
875
|
-
}
|
|
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
|
-
}
|
|
1185
|
-
};
|
|
506
|
+
}, w = () => import("./engine-B7JGZTdU.js");
|
|
1186
507
|
//#endregion
|
|
1187
|
-
export {
|
|
508
|
+
export { y as ElementMorph, C as ManualTimeline, d as NumericAnimation, u as RAFPlayback, S as ScrollTimeline, p as SmoothProgress, h as SpringProgress, x as Timeline, w as loadAnimationEngine, g as springLinearStops, _ as springTimingFunction };
|