@mkbabb/keyframes.js 5.0.0 → 5.2.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/README.md +112 -217
- package/dist/backward-color-BtbRcnna.js +108 -0
- package/dist/compile-BHCTPerD.js +30 -0
- package/dist/{waapi-D0ssxKy1.js → delegation-BQYCrP2p.js} +117 -99
- package/dist/{draw-svg-Dat9mHgi.js → draw-svg-CK9Qrly8.js} +18 -26
- package/dist/easing-registry-DHV2-5gA.js +27 -0
- package/dist/easing-registry-y1p9McFy.js +2 -0
- package/dist/easing-serialize-D4LZCB6i.js +21 -0
- package/dist/engine/index.d.ts +3139 -0
- package/dist/engine/index.js +16 -0
- package/dist/engine-CPK_udUQ.js +1172 -0
- package/dist/engine-DlpimZtM.js +3 -0
- package/dist/entry-D82NKUhP.js +148 -0
- package/dist/format-BdIvdLzG.js +114 -0
- package/dist/group-HM7N4uOE.js +390 -0
- package/dist/handle-D4xrf_ya.js +21 -0
- package/dist/{ingest-CU-kdYcM.js → ingest-_g6tfk2e.js} +62 -56
- package/dist/keyframes.d.ts +1156 -1099
- package/dist/keyframes.js +412 -132
- package/dist/morph-svg-KUrH9KnK.js +79 -0
- package/dist/motion-path-wM5tPfrY.js +26 -0
- package/dist/parse-flatten-DRMHFytp.js +2 -0
- package/dist/parse-flatten-ZZUSEQEL.js +63 -0
- package/dist/presets-DeDJYL4G.js +275 -0
- package/dist/{scheduler-7eIr_q1g.js → scheduler-CfGIC3GX.js} +1 -1
- package/dist/scroll-BEyCx0b_.js +287 -0
- package/dist/sequence-s0bL7Uul.js +736 -0
- package/dist/{validate-B1pE-Y_T.js → validate-xFZ_Ld1k.js} +17 -13
- package/dist/view-transition-BPJQxUTC.js +305 -0
- package/package.json +123 -84
- package/dist/animate-CTWr6K7j.js +0 -26
- package/dist/animations-CZxf0rep.js +0 -224
- package/dist/compile-YRJRdpKF.js +0 -251
- package/dist/decay-BvNmFk51.js +0 -25
- package/dist/engine-DQcb7CLW.js +0 -1349
- package/dist/errors-W8zkvPw4.js +0 -21
- package/dist/format-BUgCTjmr.js +0 -123
- package/dist/morph-svg-83uyYxoW.js +0 -84
- package/dist/motion-path-C0OHqcA3.js +0 -31
- package/dist/rolldown-runtime-Dy4uBu1J.js +0 -11
- package/dist/scroll-grammar-B4kPvGh5.js +0 -23
- package/dist/scroll-scene-DQxhxn9I.js +0 -176
- package/dist/sequence-cBr7thU8.js +0 -198
- package/dist/springTimingFunction-D26gPkAy.js +0 -63
- package/dist/timeline-vY3eD3Ax.js +0 -430
- package/dist/utils-BPRImVl5.js +0 -100
|
@@ -0,0 +1,736 @@
|
|
|
1
|
+
import { clamp as e, lerpArray as t, scale as n } from "@mkbabb/value.js/math";
|
|
2
|
+
//#region src/animation/internal/errors.ts
|
|
3
|
+
var r = (e) => typeof e == "string" ? JSON.stringify(e) : typeof e == "function" ? `[function ${e.name || "anonymous"}]` : String(e), i = class extends Error {
|
|
4
|
+
option;
|
|
5
|
+
value;
|
|
6
|
+
code;
|
|
7
|
+
constructor(e, t, n, i) {
|
|
8
|
+
super(`Invalid value for animation option "${e}": ${r(t)} — ${n}`), this.name = "AnimationOptionError", this.option = e, this.value = t, i !== void 0 && (this.code = i);
|
|
9
|
+
}
|
|
10
|
+
}, a = class extends Error {
|
|
11
|
+
easingName;
|
|
12
|
+
constructor(e) {
|
|
13
|
+
super(`Unknown easing name ${r(e)} — not a value.js registry entry or cubic-bezier() literal. Pass a callable TimingFunction (or a typed Easing), or resolve the name first via \`await resolveEasing(name)\`.`), this.name = "UnknownEasingError", this.easingName = e;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
function o(e, t, n, r) {
|
|
17
|
+
let a = n(t);
|
|
18
|
+
if (a === void 0) throw new i(e, t, r);
|
|
19
|
+
return a;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/animation/easing.ts
|
|
23
|
+
var s = (e) => typeof e == "function" ? { fn: e } : e, c = /^(linear|ease|ease-in|ease-out|ease-in-out)$/, l = /^(cubic-bezier\(|steps\(|linear\(|step-start$|step-end$)/, u = (e) => {
|
|
24
|
+
let t = e.trim();
|
|
25
|
+
if (c.test(t) || l.test(t)) return t;
|
|
26
|
+
};
|
|
27
|
+
async function d(e) {
|
|
28
|
+
let t;
|
|
29
|
+
try {
|
|
30
|
+
t = await import("./easing-registry-y1p9McFy.js");
|
|
31
|
+
} catch (t) {
|
|
32
|
+
throw Error(`keyframes: the easing-registry chunk failed to load while resolving easing "${e}" — the easing registry is unreachable.`, { cause: t });
|
|
33
|
+
}
|
|
34
|
+
let n = t.getTimingFunction(e);
|
|
35
|
+
if (!n) throw new a(e);
|
|
36
|
+
let r = { fn: n }, i = u(e);
|
|
37
|
+
return i && (r.css = i), r;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/animation/internal/binarySearch.ts
|
|
41
|
+
function f(e, t, n, r) {
|
|
42
|
+
let i = 0, a = e.length - 1;
|
|
43
|
+
for (; i <= a;) {
|
|
44
|
+
let o = i + a >> 1, s = e[o];
|
|
45
|
+
if (t < n(s)) a = o - 1;
|
|
46
|
+
else if (t > r(s)) i = o + 1;
|
|
47
|
+
else return o;
|
|
48
|
+
}
|
|
49
|
+
return -1;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/animation/internal/leaves.ts
|
|
53
|
+
var p = 1e3 / 60;
|
|
54
|
+
function m(e) {
|
|
55
|
+
if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
|
|
56
|
+
let t = p, n = Date.now();
|
|
57
|
+
return setTimeout(() => {
|
|
58
|
+
let r = Date.now(), i = r - n;
|
|
59
|
+
n = r, t = Math.max(0, p - i), e(r);
|
|
60
|
+
}, t);
|
|
61
|
+
}
|
|
62
|
+
function h(e) {
|
|
63
|
+
if (e != null) {
|
|
64
|
+
if (typeof e == "number" && typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
|
|
65
|
+
clearTimeout(e);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/animation/internal/reduced-motion.ts
|
|
70
|
+
var g = "(prefers-reduced-motion: reduce)", _ = null, v;
|
|
71
|
+
function y() {
|
|
72
|
+
let e = typeof window > "u" ? void 0 : window.matchMedia;
|
|
73
|
+
return typeof e == "function" ? _ !== null && v === e ? _ : (v = e, _ = e.call(window, g), _) : (_ = null, v = e, null);
|
|
74
|
+
}
|
|
75
|
+
function b() {
|
|
76
|
+
return y()?.matches ?? !1;
|
|
77
|
+
}
|
|
78
|
+
function x(e) {
|
|
79
|
+
return e === !1 || e === void 0 || !b() ? 1 : e === !0 || e < 0 ? 0 : e > 1 ? 1 : e;
|
|
80
|
+
}
|
|
81
|
+
function S(e, t, n) {
|
|
82
|
+
return !e && e !== 0 || !b() ? n() : e === !0 || e === 0 ? t() : n();
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/animation/physics/playback.ts
|
|
86
|
+
var C = class {
|
|
87
|
+
_rafId = null;
|
|
88
|
+
_startTime = void 0;
|
|
89
|
+
_lastFrameT = 0;
|
|
90
|
+
_resolve = null;
|
|
91
|
+
_gen = 0;
|
|
92
|
+
get running() {
|
|
93
|
+
return this._rafId !== null;
|
|
94
|
+
}
|
|
95
|
+
_run(e) {
|
|
96
|
+
let t = ++this._gen, n = (e) => {
|
|
97
|
+
t === this._gen && (e ? this._rafId = m(r) : this._cleanup());
|
|
98
|
+
}, r = (t) => {
|
|
99
|
+
let r = e(t);
|
|
100
|
+
r && typeof r.then == "function" ? r.then(n) : n(r);
|
|
101
|
+
};
|
|
102
|
+
this._rafId = m(r);
|
|
103
|
+
}
|
|
104
|
+
play = (t, n, r) => {
|
|
105
|
+
if (t <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
|
|
106
|
+
return this.stop(), S(r?.respectReducedMotion, () => (n(1), Promise.resolve()), () => new Promise((r) => {
|
|
107
|
+
this._resolve = r, this._startTime = void 0, this._run((r) => {
|
|
108
|
+
this._startTime === void 0 && (this._startTime = r);
|
|
109
|
+
let i = e((r - this._startTime) / t, 0, 1);
|
|
110
|
+
return n(i), i < 1;
|
|
111
|
+
});
|
|
112
|
+
}));
|
|
113
|
+
};
|
|
114
|
+
drive = (e, t) => {
|
|
115
|
+
this._rafId === null && (this._lastFrameT = 0, this._run((n) => {
|
|
116
|
+
let r = this._lastFrameT ? n - this._lastFrameT : 16.667;
|
|
117
|
+
return this._lastFrameT = n, e.tickDt(r), t?.(), !e.settled;
|
|
118
|
+
}));
|
|
119
|
+
};
|
|
120
|
+
loop = (e) => {
|
|
121
|
+
this.stop(), this._run(e);
|
|
122
|
+
};
|
|
123
|
+
stop = () => {
|
|
124
|
+
this._gen++, this._rafId !== null && h(this._rafId), this._cleanup();
|
|
125
|
+
};
|
|
126
|
+
_cleanup() {
|
|
127
|
+
this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
|
|
128
|
+
let e = this._resolve;
|
|
129
|
+
this._resolve = null, e?.();
|
|
130
|
+
}
|
|
131
|
+
}, w = {
|
|
132
|
+
damping: .1,
|
|
133
|
+
snapThreshold: .001,
|
|
134
|
+
targetEpsilon: 0,
|
|
135
|
+
initial: 0,
|
|
136
|
+
clamp: !0,
|
|
137
|
+
respectReducedMotion: !1
|
|
138
|
+
}, T = class {
|
|
139
|
+
options;
|
|
140
|
+
targetValue;
|
|
141
|
+
currentValue;
|
|
142
|
+
isSettled;
|
|
143
|
+
_playback = new C();
|
|
144
|
+
_onFrame = void 0;
|
|
145
|
+
constructor(e) {
|
|
146
|
+
this.options = {
|
|
147
|
+
...w,
|
|
148
|
+
...e
|
|
149
|
+
}, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
|
|
150
|
+
}
|
|
151
|
+
get target() {
|
|
152
|
+
return this.targetValue;
|
|
153
|
+
}
|
|
154
|
+
get current() {
|
|
155
|
+
return this.currentValue;
|
|
156
|
+
}
|
|
157
|
+
get settled() {
|
|
158
|
+
return this.isSettled;
|
|
159
|
+
}
|
|
160
|
+
setTarget(t) {
|
|
161
|
+
this.options.clamp && (t = e(t, 0, 1));
|
|
162
|
+
let n = Math.abs(t - this.targetValue);
|
|
163
|
+
n > 0 && n >= this.options.targetEpsilon && (this.targetValue = t, S(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
164
|
+
this.isSettled = !1, this._onFrame && this._startLoop();
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
_snapSettled() {
|
|
168
|
+
this.currentValue = this.targetValue, this.isSettled = !0, this._onFrame?.(this.currentValue), this._playback.stop();
|
|
169
|
+
}
|
|
170
|
+
tickDt(t) {
|
|
171
|
+
if (this.isSettled) return this.currentValue;
|
|
172
|
+
let n = 1 - Math.exp(-this.options.damping * t / 16.667);
|
|
173
|
+
return this.currentValue += (this.targetValue - this.currentValue) * n, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = e(this.currentValue, 0, 1)), this.currentValue;
|
|
174
|
+
}
|
|
175
|
+
snap() {
|
|
176
|
+
this.currentValue = this.targetValue, this.isSettled = !0, this._playback.stop();
|
|
177
|
+
}
|
|
178
|
+
reset(e) {
|
|
179
|
+
let t = e ?? 0;
|
|
180
|
+
this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._playback.stop();
|
|
181
|
+
}
|
|
182
|
+
play(e) {
|
|
183
|
+
this._onFrame = e, S(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
184
|
+
if (this.isSettled) {
|
|
185
|
+
e?.(this.currentValue);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
this._startLoop();
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
stop() {
|
|
192
|
+
this._onFrame = void 0, this._playback.stop();
|
|
193
|
+
}
|
|
194
|
+
_startLoop() {
|
|
195
|
+
this._playback.drive(this, () => this._onFrame?.(this.currentValue));
|
|
196
|
+
}
|
|
197
|
+
}, E = {
|
|
198
|
+
response: .5,
|
|
199
|
+
dampingFraction: .86,
|
|
200
|
+
initial: 0,
|
|
201
|
+
initialVelocity: 0,
|
|
202
|
+
settleThreshold: .001,
|
|
203
|
+
velocitySettleThreshold: .001,
|
|
204
|
+
respectReducedMotion: !1
|
|
205
|
+
};
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/animation/physics/spring/managed-play.ts
|
|
208
|
+
function D(e) {
|
|
209
|
+
e._playback.drive(e, () => e._onFrame?.(e.value, e.velocity));
|
|
210
|
+
}
|
|
211
|
+
function O(e, t) {
|
|
212
|
+
e.disposed || (e._onFrame = t, S(e.respectReducedMotion, () => e.snap(), () => {
|
|
213
|
+
if (e.settled) {
|
|
214
|
+
t?.(e.value, e.velocity);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
D(e);
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
function k(e) {
|
|
221
|
+
e._onFrame = void 0, e._playback.stop();
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/animation/physics/spring/duration.ts
|
|
225
|
+
function A(t) {
|
|
226
|
+
let { visualDuration: n, duration: r, bounce: i = 0, ...a } = t, o = n ?? r ?? .5, s = 1 - e(i, -1, 1);
|
|
227
|
+
return {
|
|
228
|
+
...a,
|
|
229
|
+
response: o,
|
|
230
|
+
dampingFraction: s
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/animation/physics/spring/vector.ts
|
|
235
|
+
var j = new Float64Array(), M = class {
|
|
236
|
+
vecOrigin = null;
|
|
237
|
+
vecOriginVel = null;
|
|
238
|
+
vecTarget = null;
|
|
239
|
+
vecCurrent = null;
|
|
240
|
+
vecVelocity = null;
|
|
241
|
+
vecElapsed = 0;
|
|
242
|
+
setTargets(e) {
|
|
243
|
+
let t = e.length;
|
|
244
|
+
if (this.vecTarget === null) this.vecOrigin = new Float64Array(t), this.vecOriginVel = new Float64Array(t), this.vecTarget = new Float64Array(t), this.vecCurrent = new Float64Array(t), this.vecVelocity = new Float64Array(t);
|
|
245
|
+
else if (this.vecTarget.length !== t) throw RangeError(`setTargets length ${t} does not match the armed lane count ${this.vecTarget.length}; the lane buffers are stable references — construct a new SpringProgress for a new arity.`);
|
|
246
|
+
this.vecOrigin.set(this.vecCurrent), this.vecOriginVel.set(this.vecVelocity), this.vecTarget.set(e), this.vecElapsed = 0;
|
|
247
|
+
}
|
|
248
|
+
get values() {
|
|
249
|
+
return this.vecCurrent ?? j;
|
|
250
|
+
}
|
|
251
|
+
get velocities() {
|
|
252
|
+
return this.vecVelocity ?? j;
|
|
253
|
+
}
|
|
254
|
+
get armed() {
|
|
255
|
+
return this.vecTarget !== null;
|
|
256
|
+
}
|
|
257
|
+
tick(e, t, n, r) {
|
|
258
|
+
if (this.vecTarget === null || e <= 0) return this.values;
|
|
259
|
+
this.vecElapsed += e / 1e3;
|
|
260
|
+
let i = this.vecElapsed, a = t, o = n, s = r, c = this.vecOrigin, l = this.vecOriginVel, u = this.vecTarget, d = this.vecCurrent, f = this.vecVelocity, p = o < 1 ? Math.exp(-o * a * i) : 0, m = o < 1 ? Math.cos(s * i) : 0, h = o < 1 ? Math.sin(s * i) : 0, g = o === 1 ? Math.exp(-a * i) : 0, _ = 0, v = 0, y = 0, b = 0;
|
|
261
|
+
if (o > 1) {
|
|
262
|
+
let e = a * Math.sqrt(o * o - 1);
|
|
263
|
+
_ = -o * a + e, v = -o * a - e, y = Math.exp(_ * i), b = Math.exp(v * i);
|
|
264
|
+
}
|
|
265
|
+
for (let e = 0; e < d.length; e++) {
|
|
266
|
+
let t = c[e] - u[e], n = l[e], r, x;
|
|
267
|
+
if (o < 1) {
|
|
268
|
+
let e = t, i = (n + o * a * t) / s;
|
|
269
|
+
r = p * (e * m + i * h), x = p * ((i * s - e * o * a) * m - (e * s + i * o * a) * h);
|
|
270
|
+
} else if (o === 1) {
|
|
271
|
+
let e = t, o = n + a * t;
|
|
272
|
+
r = g * (e + o * i), x = g * (o - a * (e + o * i));
|
|
273
|
+
} else {
|
|
274
|
+
let e = (n - v * t) / (_ - v), i = t - e;
|
|
275
|
+
r = e * y + i * b, x = e * _ * y + i * v * b;
|
|
276
|
+
}
|
|
277
|
+
d[e] = u[e] + r, f[e] = x;
|
|
278
|
+
}
|
|
279
|
+
return d;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/animation/physics/spring/solver.ts
|
|
284
|
+
function N(e, t, n, r, i, a) {
|
|
285
|
+
let o = n, s = r;
|
|
286
|
+
if (s < 1) {
|
|
287
|
+
let n = i, r = Math.exp(-s * o * a), c = e, l = (t + s * o * e) / n, u = Math.cos(n * a), d = Math.sin(n * a);
|
|
288
|
+
return {
|
|
289
|
+
x: r * (c * u + l * d),
|
|
290
|
+
v: r * ((l * n - c * s * o) * u - (c * n + l * s * o) * d)
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
if (s === 1) {
|
|
294
|
+
let n = Math.exp(-o * a), r = e, i = t + o * e;
|
|
295
|
+
return {
|
|
296
|
+
x: n * (r + i * a),
|
|
297
|
+
v: n * (i - o * (r + i * a))
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
let c = o * Math.sqrt(s * s - 1), l = -s * o + c, u = -s * o - c, d = (t - u * e) / (l - u), f = e - d, p = Math.exp(l * a), m = Math.exp(u * a);
|
|
301
|
+
return {
|
|
302
|
+
x: d * p + f * m,
|
|
303
|
+
v: d * l * p + f * u * m
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/animation/physics/spring/progress.ts
|
|
308
|
+
var P = class e {
|
|
309
|
+
options;
|
|
310
|
+
get respectReducedMotion() {
|
|
311
|
+
return this.options.respectReducedMotion;
|
|
312
|
+
}
|
|
313
|
+
targetValue;
|
|
314
|
+
currentValue;
|
|
315
|
+
currentVelocity;
|
|
316
|
+
isSettled;
|
|
317
|
+
elapsed;
|
|
318
|
+
originValue;
|
|
319
|
+
originVelocity;
|
|
320
|
+
amplitudeScale = 1;
|
|
321
|
+
omega;
|
|
322
|
+
zeta;
|
|
323
|
+
omegaD;
|
|
324
|
+
subscribers = /* @__PURE__ */ new Set();
|
|
325
|
+
disposed = !1;
|
|
326
|
+
vectorLanes = null;
|
|
327
|
+
_playback = new C();
|
|
328
|
+
_onFrame = void 0;
|
|
329
|
+
constructor(e) {
|
|
330
|
+
this.options = {
|
|
331
|
+
...E,
|
|
332
|
+
...e
|
|
333
|
+
}, 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.amplitudeScale = x(this.options.respectReducedMotion), 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;
|
|
334
|
+
}
|
|
335
|
+
static fromDuration(t) {
|
|
336
|
+
return new e(A(t ?? {}));
|
|
337
|
+
}
|
|
338
|
+
get target() {
|
|
339
|
+
return this.targetValue;
|
|
340
|
+
}
|
|
341
|
+
get value() {
|
|
342
|
+
return this.currentValue;
|
|
343
|
+
}
|
|
344
|
+
get velocity() {
|
|
345
|
+
return this.currentVelocity;
|
|
346
|
+
}
|
|
347
|
+
get settled() {
|
|
348
|
+
return this.isSettled;
|
|
349
|
+
}
|
|
350
|
+
set target(e) {
|
|
351
|
+
e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
|
|
352
|
+
}
|
|
353
|
+
reseatTarget(e) {
|
|
354
|
+
this.targetValue = e, S(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
355
|
+
this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale = x(this.options.respectReducedMotion), this._onFrame && D(this);
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
_snapSettled() {
|
|
359
|
+
this.currentValue = this.targetValue, this.currentVelocity = 0, this.originValue = this.targetValue, this.originVelocity = 0, this.elapsed = 0, this.isSettled = !0, this.emit(), this._playback.stop();
|
|
360
|
+
}
|
|
361
|
+
tickDt(e) {
|
|
362
|
+
return this._stepSeconds(e / 1e3);
|
|
363
|
+
}
|
|
364
|
+
_stepSeconds(e) {
|
|
365
|
+
return this.disposed || this.isSettled || e <= 0 ? this.currentValue : (this.elapsed += e, this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
|
|
366
|
+
}
|
|
367
|
+
tickToTime(e) {
|
|
368
|
+
return this.disposed || this.isSettled ? this.currentValue : (this.elapsed = Math.max(0, e), this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
|
|
369
|
+
}
|
|
370
|
+
evaluateAt(e) {
|
|
371
|
+
let t = this.amplitudeScale, n = this.originValue + t * (this.targetValue - this.originValue), r = this.originValue - n, i = this.originVelocity, { x: a, v: o } = N(r, i, this.omega, this.zeta, this.omegaD, e);
|
|
372
|
+
this.currentValue = n + a, this.currentVelocity = o;
|
|
373
|
+
}
|
|
374
|
+
checkSettled() {
|
|
375
|
+
let e = this.amplitudeScale, t = this.originValue + e * (this.targetValue - this.originValue), n = Math.abs(this.currentValue - t), r = Math.abs(this.currentVelocity);
|
|
376
|
+
n < this.options.settleThreshold && r < this.options.velocitySettleThreshold && (this.currentValue = t, this.currentVelocity = 0, this.isSettled = !0);
|
|
377
|
+
}
|
|
378
|
+
snap() {
|
|
379
|
+
this._snapSettled();
|
|
380
|
+
}
|
|
381
|
+
reset(e, t) {
|
|
382
|
+
let n = e ?? 0, r = t ?? 0;
|
|
383
|
+
this.targetValue = n, this.currentValue = n, this.currentVelocity = r, this.originValue = n, this.originVelocity = r, this.elapsed = 0, this.amplitudeScale = x(this.options.respectReducedMotion), this.isSettled = r === 0, this.emit(), this._playback.stop();
|
|
384
|
+
}
|
|
385
|
+
setTargets(e) {
|
|
386
|
+
(this.vectorLanes ??= new M()).setTargets(e);
|
|
387
|
+
}
|
|
388
|
+
get values() {
|
|
389
|
+
return this.vectorLanes?.values ?? j;
|
|
390
|
+
}
|
|
391
|
+
get velocities() {
|
|
392
|
+
return this.vectorLanes?.velocities ?? j;
|
|
393
|
+
}
|
|
394
|
+
tickVector(e) {
|
|
395
|
+
return this.disposed || this.vectorLanes === null || e <= 0 ? this.values : this.vectorLanes.tick(e, this.omega, this.zeta, this.omegaD);
|
|
396
|
+
}
|
|
397
|
+
subscribe(e) {
|
|
398
|
+
return this.subscribers.add(e), () => {
|
|
399
|
+
this.subscribers.delete(e);
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
emit() {
|
|
403
|
+
if (this.subscribers.size !== 0) for (let e of this.subscribers) e(this.currentValue, this.currentVelocity);
|
|
404
|
+
}
|
|
405
|
+
dispose() {
|
|
406
|
+
this.disposed = !0, this._playback.stop(), this.subscribers.clear();
|
|
407
|
+
}
|
|
408
|
+
play(e) {
|
|
409
|
+
O(this, e);
|
|
410
|
+
}
|
|
411
|
+
stop() {
|
|
412
|
+
k(this);
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
//#endregion
|
|
416
|
+
//#region src/animation/physics/spring/sample.ts
|
|
417
|
+
function F(e) {
|
|
418
|
+
let t = new P({
|
|
419
|
+
response: e.response,
|
|
420
|
+
dampingFraction: e.dampingFraction,
|
|
421
|
+
initial: 0,
|
|
422
|
+
settleThreshold: e.settleThreshold,
|
|
423
|
+
velocitySettleThreshold: e.settleThreshold
|
|
424
|
+
});
|
|
425
|
+
t.target = 1;
|
|
426
|
+
let n = [];
|
|
427
|
+
for (let r = 1; r <= e.sampleCount; r++) t._stepSeconds(e.dt), n.push(t.settled ? 1 : t.value);
|
|
428
|
+
return t.dispose(), n;
|
|
429
|
+
}
|
|
430
|
+
//#endregion
|
|
431
|
+
//#region src/animation/physics/spring/linear-stops.ts
|
|
432
|
+
function I(e) {
|
|
433
|
+
let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = F({
|
|
434
|
+
response: e.response,
|
|
435
|
+
dampingFraction: e.dampingFraction,
|
|
436
|
+
sampleCount: t,
|
|
437
|
+
settleThreshold: n,
|
|
438
|
+
dt: r / (t + 1)
|
|
439
|
+
}), a = ["0"];
|
|
440
|
+
for (let e = 1; e <= t; e++) {
|
|
441
|
+
let n = e / (t + 1) * 100, r = i[e - 1];
|
|
442
|
+
a.push(`${r.toFixed(5)} ${n.toFixed(3)}%`);
|
|
443
|
+
}
|
|
444
|
+
return a.push("1"), `linear(${a.join(", ")})`;
|
|
445
|
+
}
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region src/animation/physics/spring/timing-function.ts
|
|
448
|
+
function L(e) {
|
|
449
|
+
let t = e.sampleCount ?? 64, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = F({
|
|
450
|
+
response: e.response,
|
|
451
|
+
dampingFraction: e.dampingFraction,
|
|
452
|
+
sampleCount: t,
|
|
453
|
+
settleThreshold: n,
|
|
454
|
+
dt: r / t
|
|
455
|
+
}), a = new Float64Array(t + 1);
|
|
456
|
+
a[0] = 0;
|
|
457
|
+
for (let e = 1; e <= t; e++) a[e] = i[e - 1];
|
|
458
|
+
a[t] = 1;
|
|
459
|
+
let o = (e) => {
|
|
460
|
+
if (e <= 0) return 0;
|
|
461
|
+
if (e >= 1) return 1;
|
|
462
|
+
let n = e * t, r = Math.floor(n), i = n - r, o = a[r];
|
|
463
|
+
return o + (a[r + 1] - o) * i;
|
|
464
|
+
}, s = {
|
|
465
|
+
response: e.response,
|
|
466
|
+
dampingFraction: e.dampingFraction
|
|
467
|
+
};
|
|
468
|
+
return e.settleThreshold !== void 0 && (s.settleThreshold = e.settleThreshold), e.maxDuration !== void 0 && (s.maxDuration = e.maxDuration), {
|
|
469
|
+
fn: o,
|
|
470
|
+
css: I(s)
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
//#endregion
|
|
474
|
+
//#region src/animation/orchestration/timeline/native.ts
|
|
475
|
+
function R(e) {
|
|
476
|
+
if (typeof window > "u") return null;
|
|
477
|
+
if (e.kind === "scroll") {
|
|
478
|
+
if (globalThis.ScrollTimeline === void 0) return null;
|
|
479
|
+
let t = {};
|
|
480
|
+
return e.source !== void 0 && (t.source = e.source), e.axis !== void 0 && (t.axis = e.axis), new globalThis.ScrollTimeline(t);
|
|
481
|
+
}
|
|
482
|
+
if (globalThis.ViewTimeline === void 0) return null;
|
|
483
|
+
let t = { subject: e.subject };
|
|
484
|
+
return e.axis !== void 0 && (t.axis = e.axis), e.inset !== void 0 && (t.inset = e.inset), new globalThis.ViewTimeline(t);
|
|
485
|
+
}
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/animation/physics/decay.ts
|
|
488
|
+
var z = 5;
|
|
489
|
+
function B(e) {
|
|
490
|
+
let t = e.initial ?? 0, n = e.velocity, r = e.friction ?? z;
|
|
491
|
+
if (r <= 0) throw Error("decay() requires a friction coefficient > 0.");
|
|
492
|
+
let i = t + n / r;
|
|
493
|
+
return (e) => {
|
|
494
|
+
if (e <= 0) return {
|
|
495
|
+
value: t,
|
|
496
|
+
velocity: n
|
|
497
|
+
};
|
|
498
|
+
let a = Math.exp(-r * e);
|
|
499
|
+
return {
|
|
500
|
+
value: i - n / r * a,
|
|
501
|
+
velocity: n * a
|
|
502
|
+
};
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
function V(e) {
|
|
506
|
+
let t = e.friction ?? z;
|
|
507
|
+
if (t <= 0) throw Error("decayRest() requires a friction coefficient > 0.");
|
|
508
|
+
return (e.initial ?? 0) + e.velocity / t;
|
|
509
|
+
}
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region src/animation/orchestration/sequence/transport.ts
|
|
512
|
+
function H(t, n) {
|
|
513
|
+
for (let { animation: r, at: i } of t) {
|
|
514
|
+
let t = e(n - i, 0, r.options.duration);
|
|
515
|
+
r.interpFrames(t, !0);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
function U(e, t, n, r) {
|
|
519
|
+
e.fire(t, n, r);
|
|
520
|
+
}
|
|
521
|
+
function W(e, t, n) {
|
|
522
|
+
if (e === void 0) return t;
|
|
523
|
+
if (typeof e == "number") return e;
|
|
524
|
+
let r = /^([+-])=(\d*\.?\d+)$/.exec(e);
|
|
525
|
+
if (r) return t + (r[1] === "+" ? 1 : -1) * Number.parseFloat(r[2]);
|
|
526
|
+
let i = n.get(e);
|
|
527
|
+
if (i === void 0) throw Error(`Sequence: unknown position "${e}". Register it with .label("${e}", at) first, or pass a number / "+=n" / "-=n".`);
|
|
528
|
+
return i;
|
|
529
|
+
}
|
|
530
|
+
function G(t, n, r, i) {
|
|
531
|
+
if (n <= 0) return 0;
|
|
532
|
+
let a = e(t, 0, n * r), o = Math.floor(a / n), s = a - o * n;
|
|
533
|
+
return s === 0 && o > 0 && (--o, s = n), i && o % 2 == 1 ? n - s : s;
|
|
534
|
+
}
|
|
535
|
+
function K(e, t, n) {
|
|
536
|
+
return n && (t - 1) % 2 == 1 ? 0 : e;
|
|
537
|
+
}
|
|
538
|
+
function q(e, t, n) {
|
|
539
|
+
return e === 1 && t === 1 && !n;
|
|
540
|
+
}
|
|
541
|
+
function J(e, t, n) {
|
|
542
|
+
return n === 0 ? e : e - t / n;
|
|
543
|
+
}
|
|
544
|
+
async function Y(e, t) {
|
|
545
|
+
e._playOrigin === void 0 && (e._playOrigin = J(t, e._time, e._rate)), e._lastClock = t;
|
|
546
|
+
let n = (t - e._playOrigin) * e._rate, r = e.duration * e._repeatCount, i = e._rate >= 0 ? n >= r : n <= 0, a = i ? e._rate >= 0 ? K(e.duration, e._repeatCount, e._yoyoOn) : 0 : G(n, e.duration, e._repeatCount, e._yoyoOn);
|
|
547
|
+
if (e._time = a, q(e._rate, e._repeatCount, e._yoyoOn)) for (let { animation: t, at: n } of e.entries) a >= n && a - n < t.options.duration && await t.advanceTo(a);
|
|
548
|
+
if (U(e.events, e.entries, e.labels, a), H(e.entries, a), i) {
|
|
549
|
+
X(e);
|
|
550
|
+
let t = e._resolvePlay;
|
|
551
|
+
return e._resolvePlay = null, t?.(), !1;
|
|
552
|
+
}
|
|
553
|
+
return !0;
|
|
554
|
+
}
|
|
555
|
+
function X(e) {
|
|
556
|
+
for (let { animation: t } of e.entries) t.managed = !1, t.started = !1, t.startTime = void 0;
|
|
557
|
+
e._playOrigin = void 0, e._lastClock = void 0, e._paused = !1;
|
|
558
|
+
}
|
|
559
|
+
function Z(e, t) {
|
|
560
|
+
if (!t) return;
|
|
561
|
+
let n = e._lastClock;
|
|
562
|
+
if (n === void 0) {
|
|
563
|
+
e._playOrigin = void 0;
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
e._playOrigin = J(n, e._time, e._rate);
|
|
567
|
+
}
|
|
568
|
+
//#endregion
|
|
569
|
+
//#region src/animation/orchestration/sequence/lifecycle.ts
|
|
570
|
+
function Q(e) {
|
|
571
|
+
if (e._playingPromise) return e._playingPromise;
|
|
572
|
+
if (e.respectReducedMotion && b()) return e.seek(e.duration), Promise.resolve();
|
|
573
|
+
for (let { animation: t, at: n } of e.entries) t.startTime = n, t.started = !0, t.managed = !0;
|
|
574
|
+
e._time = 0, e._paused = !1, e._playOrigin = void 0, e._lastClock = void 0;
|
|
575
|
+
let t = new Promise((t) => {
|
|
576
|
+
e._resolvePlay = t, e.playback.loop(e._boundFrame);
|
|
577
|
+
});
|
|
578
|
+
return e._playingPromise = t, t.finally(() => {
|
|
579
|
+
e._playingPromise = null;
|
|
580
|
+
}), t;
|
|
581
|
+
}
|
|
582
|
+
function $(e) {
|
|
583
|
+
e.playback.stop(), X(e);
|
|
584
|
+
let t = e._resolvePlay;
|
|
585
|
+
e._resolvePlay = null, t?.();
|
|
586
|
+
}
|
|
587
|
+
function ee(e) {
|
|
588
|
+
!e._playingPromise || e._paused || (e._paused = !0, e.playback.stop(), e._playOrigin = void 0);
|
|
589
|
+
}
|
|
590
|
+
function te(e) {
|
|
591
|
+
!e._playingPromise || !e._paused || (e._paused = !1, e._playOrigin = void 0, e._lastClock = void 0, e.playback.loop(e._boundFrame));
|
|
592
|
+
}
|
|
593
|
+
function ne(e, t) {
|
|
594
|
+
if (!Number.isFinite(t)) throw Error(`Sequence.timeScale(n): n must be a finite number, got ${t}.`);
|
|
595
|
+
e._rate = t, Z(e, e._playingPromise != null);
|
|
596
|
+
}
|
|
597
|
+
function re(e) {
|
|
598
|
+
e._rate = -e._rate, Z(e, e._playingPromise != null);
|
|
599
|
+
}
|
|
600
|
+
function ie(e, t) {
|
|
601
|
+
if (t !== Infinity && (!Number.isInteger(t) || t < 1)) throw Error(`Sequence.repeat(count): count must be a positive integer or Infinity, got ${t}.`);
|
|
602
|
+
e._repeatCount = t;
|
|
603
|
+
}
|
|
604
|
+
function ae(e, t) {
|
|
605
|
+
e._yoyoOn = t;
|
|
606
|
+
}
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region src/animation/orchestration/sequence/events.ts
|
|
609
|
+
var oe = class {
|
|
610
|
+
subscribers = new Map([
|
|
611
|
+
["segment:enter", /* @__PURE__ */ new Set()],
|
|
612
|
+
["segment:leave", /* @__PURE__ */ new Set()],
|
|
613
|
+
["label", /* @__PURE__ */ new Set()]
|
|
614
|
+
]);
|
|
615
|
+
_activeSegments = /* @__PURE__ */ new Set();
|
|
616
|
+
_prevPhase = void 0;
|
|
617
|
+
subscribe(e, t) {
|
|
618
|
+
let n = this.subscribers.get(e);
|
|
619
|
+
return n.add(t), () => n.delete(t);
|
|
620
|
+
}
|
|
621
|
+
fire(e, t, n) {
|
|
622
|
+
let r = this.subscribers.get("segment:enter"), i = this.subscribers.get("segment:leave"), a = this.subscribers.get("label");
|
|
623
|
+
if (r.size === 0 && i.size === 0 && a.size === 0) {
|
|
624
|
+
this._prevPhase = n;
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
let o = this._prevPhase;
|
|
628
|
+
if (r.size > 0 || i.size > 0) for (let t of e) {
|
|
629
|
+
let e = n >= t.at && n < t.at + t.animation.options.duration, a = this._activeSegments.has(t);
|
|
630
|
+
if (e && !a) {
|
|
631
|
+
this._activeSegments.add(t);
|
|
632
|
+
for (let e of r) e(t.animation, n);
|
|
633
|
+
} else if (!e && a) {
|
|
634
|
+
this._activeSegments.delete(t);
|
|
635
|
+
for (let e of i) e(t.animation, n);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (a.size > 0 && o !== void 0 && o !== n) {
|
|
639
|
+
let e = Math.min(o, n), r = Math.max(o, n);
|
|
640
|
+
for (let [i, o] of t) if (o > e && o <= r) for (let e of a) e(i, n);
|
|
641
|
+
}
|
|
642
|
+
this._prevPhase = n;
|
|
643
|
+
}
|
|
644
|
+
}, se = class {
|
|
645
|
+
entries = [];
|
|
646
|
+
labels = /* @__PURE__ */ new Map();
|
|
647
|
+
events = new oe();
|
|
648
|
+
cursor = 0;
|
|
649
|
+
_time = 0;
|
|
650
|
+
respectReducedMotion;
|
|
651
|
+
playback = new C();
|
|
652
|
+
_boundFrame;
|
|
653
|
+
_resolvePlay = null;
|
|
654
|
+
_playOrigin = void 0;
|
|
655
|
+
_playingPromise = null;
|
|
656
|
+
_rate = 1;
|
|
657
|
+
_repeatCount = 1;
|
|
658
|
+
_yoyoOn = !1;
|
|
659
|
+
_paused = !1;
|
|
660
|
+
_lastClock = void 0;
|
|
661
|
+
constructor(e) {
|
|
662
|
+
this.respectReducedMotion = e?.respectReducedMotion ?? !1, this._boundFrame = this._frame.bind(this);
|
|
663
|
+
}
|
|
664
|
+
get duration() {
|
|
665
|
+
let e = 0;
|
|
666
|
+
for (let t of this.entries) {
|
|
667
|
+
let n = t.at + t.animation.options.duration;
|
|
668
|
+
n > e && (e = n);
|
|
669
|
+
}
|
|
670
|
+
return e;
|
|
671
|
+
}
|
|
672
|
+
get time() {
|
|
673
|
+
return this._time;
|
|
674
|
+
}
|
|
675
|
+
get progress() {
|
|
676
|
+
return this.duration === 0 ? 0 : this._time / this.duration;
|
|
677
|
+
}
|
|
678
|
+
set progress(t) {
|
|
679
|
+
this.seek(e(t, 0, 1) * this.duration);
|
|
680
|
+
}
|
|
681
|
+
get rate() {
|
|
682
|
+
return this._rate;
|
|
683
|
+
}
|
|
684
|
+
label(e, t) {
|
|
685
|
+
return this.labels.set(e, W(t, this.cursor, this.labels)), this;
|
|
686
|
+
}
|
|
687
|
+
on(e, t) {
|
|
688
|
+
return this.events.subscribe(e, t);
|
|
689
|
+
}
|
|
690
|
+
add(e, t) {
|
|
691
|
+
let n = W(t, this.cursor, this.labels);
|
|
692
|
+
return this.entries.push({
|
|
693
|
+
animation: e,
|
|
694
|
+
at: n
|
|
695
|
+
}), this.entries.sort((e, t) => e.at - t.at), this.cursor = n + e.options.duration, this;
|
|
696
|
+
}
|
|
697
|
+
seek(e) {
|
|
698
|
+
return this._time = e, U(this.events, this.entries, this.labels, e), H(this.entries, e), this;
|
|
699
|
+
}
|
|
700
|
+
setTargets(...e) {
|
|
701
|
+
for (let { animation: t } of this.entries) t.setTargets(...e);
|
|
702
|
+
return this;
|
|
703
|
+
}
|
|
704
|
+
get finished() {
|
|
705
|
+
return this._playingPromise ?? Promise.resolve();
|
|
706
|
+
}
|
|
707
|
+
play() {
|
|
708
|
+
return Q(this);
|
|
709
|
+
}
|
|
710
|
+
async _frame(e) {
|
|
711
|
+
return Y(this, e);
|
|
712
|
+
}
|
|
713
|
+
stop() {
|
|
714
|
+
return $(this), this;
|
|
715
|
+
}
|
|
716
|
+
pause() {
|
|
717
|
+
return ee(this), this;
|
|
718
|
+
}
|
|
719
|
+
resume() {
|
|
720
|
+
return te(this), this;
|
|
721
|
+
}
|
|
722
|
+
timeScale(e) {
|
|
723
|
+
return ne(this, e), this;
|
|
724
|
+
}
|
|
725
|
+
reverse() {
|
|
726
|
+
return re(this), this;
|
|
727
|
+
}
|
|
728
|
+
repeat(e) {
|
|
729
|
+
return ie(this, e), this;
|
|
730
|
+
}
|
|
731
|
+
yoyo(e = !0) {
|
|
732
|
+
return ae(this, e), this;
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
//#endregion
|
|
736
|
+
export { d as _, L as a, a as b, T as c, S as d, e as f, u as g, f as h, R as i, C as l, n as m, B as n, I as o, t as p, V as r, P as s, se as t, x as u, s as v, o as x, i as y };
|