@mkbabb/keyframes.js 6.4.0 → 6.6.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 +108 -4
- package/dist/engine/index.d.ts +12 -5
- package/dist/engine/index.js +133 -131
- package/dist/keyframes.d.ts +161 -16
- package/dist/keyframes.js +251 -154
- package/dist/{registry-8bG0FhGi.js → registry-BZOrCZZh.js} +1 -1
- package/dist/{registry-Bs7A0T_s.js → registry-D3fj1upb.js} +1 -1
- package/dist/{sequence-CPGHHEVM.js → sequence-BzJ-b_HG.js} +291 -149
- package/package.json +6 -4
|
@@ -27,7 +27,7 @@ var s = (e) => typeof e == "function" ? { fn: e } : e, c = /^(linear|ease|ease-i
|
|
|
27
27
|
async function d(e) {
|
|
28
28
|
let t;
|
|
29
29
|
try {
|
|
30
|
-
t = await import("./registry-
|
|
30
|
+
t = await import("./registry-D3fj1upb.js");
|
|
31
31
|
} catch (t) {
|
|
32
32
|
throw Error(`keyframes: the easing-registry chunk failed to load while resolving easing "${e}" — the easing registry is unreachable.`, { cause: t });
|
|
33
33
|
}
|
|
@@ -42,7 +42,7 @@ async function d(e) {
|
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/animation/internal/binary-search.ts
|
|
45
|
-
function
|
|
45
|
+
function f(e, t, n, r) {
|
|
46
46
|
let i = 0, a = e.length - 1;
|
|
47
47
|
for (; i <= a;) {
|
|
48
48
|
let o = i + a >> 1, s = e[o];
|
|
@@ -54,16 +54,16 @@ function ee(e, t, n, r) {
|
|
|
54
54
|
}
|
|
55
55
|
//#endregion
|
|
56
56
|
//#region src/animation/internal/leaves.ts
|
|
57
|
-
var
|
|
58
|
-
function
|
|
57
|
+
var p = 1e3 / 60;
|
|
58
|
+
function m(e) {
|
|
59
59
|
if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
|
|
60
|
-
let t =
|
|
60
|
+
let t = p, n = Date.now();
|
|
61
61
|
return setTimeout(() => {
|
|
62
62
|
let r = Date.now(), i = r - n;
|
|
63
|
-
n = r, t = Math.max(0,
|
|
63
|
+
n = r, t = Math.max(0, p - i), e(r);
|
|
64
64
|
}, t);
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function h(e) {
|
|
67
67
|
if (e != null) {
|
|
68
68
|
if (typeof e == "number" && typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
|
|
69
69
|
clearTimeout(e);
|
|
@@ -71,23 +71,23 @@ function m(e) {
|
|
|
71
71
|
}
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region src/animation/internal/reduced-motion.ts
|
|
74
|
-
var
|
|
75
|
-
function
|
|
74
|
+
var g = "(prefers-reduced-motion: reduce)", _ = null, v;
|
|
75
|
+
function y() {
|
|
76
76
|
let e = typeof window > "u" ? void 0 : window.matchMedia;
|
|
77
|
-
return typeof e == "function" ?
|
|
77
|
+
return typeof e == "function" ? _ !== null && v === e ? _ : (v = e, _ = e.call(window, g), _) : (_ = null, v = e, null);
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
79
|
+
function b() {
|
|
80
|
+
return y()?.matches ?? !1;
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
return e === !1 || e === void 0 || !
|
|
82
|
+
function x(e) {
|
|
83
|
+
return e === !1 || e === void 0 || !b() ? 1 : e === !0 || e < 0 ? 0 : e > 1 ? 1 : e;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
return !e && e !== 0 || !
|
|
85
|
+
function S(e, t, n) {
|
|
86
|
+
return !e && e !== 0 || !b() ? n() : e === !0 || e === 0 ? t() : n();
|
|
87
87
|
}
|
|
88
88
|
//#endregion
|
|
89
89
|
//#region src/animation/physics/playback.ts
|
|
90
|
-
var
|
|
90
|
+
var C = class {
|
|
91
91
|
_rafId = null;
|
|
92
92
|
_startTime = void 0;
|
|
93
93
|
_lastFrameT = 0;
|
|
@@ -98,7 +98,7 @@ var b = class {
|
|
|
98
98
|
}
|
|
99
99
|
_run(e) {
|
|
100
100
|
let t = ++this._gen, n = (e) => {
|
|
101
|
-
t === this._gen && (e ? this._rafId =
|
|
101
|
+
t === this._gen && (e ? this._rafId = m(i) : this._cleanup());
|
|
102
102
|
}, r = (e) => {
|
|
103
103
|
throw n(!1), e;
|
|
104
104
|
}, i = (t) => {
|
|
@@ -111,11 +111,11 @@ var b = class {
|
|
|
111
111
|
}
|
|
112
112
|
i && typeof i.then == "function" ? i.then(n, r) : n(i);
|
|
113
113
|
};
|
|
114
|
-
this._rafId =
|
|
114
|
+
this._rafId = m(i);
|
|
115
115
|
}
|
|
116
116
|
play = (t, n, r) => {
|
|
117
117
|
if (t <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
|
|
118
|
-
return this.stop(),
|
|
118
|
+
return this.stop(), S(r?.respectReducedMotion, () => (n(1), Promise.resolve()), () => new Promise((r) => {
|
|
119
119
|
this._resolve = r, this._startTime = void 0, this._run((r) => {
|
|
120
120
|
this._startTime === void 0 && (this._startTime = r);
|
|
121
121
|
let i = e((r - this._startTime) / t, 0, 1);
|
|
@@ -124,16 +124,18 @@ var b = class {
|
|
|
124
124
|
}));
|
|
125
125
|
};
|
|
126
126
|
drive = (e, t) => {
|
|
127
|
-
this._rafId
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
if (this._rafId !== null) return;
|
|
128
|
+
let n = !0;
|
|
129
|
+
this._run((r) => {
|
|
130
|
+
let i = n ? 0 : r - this._lastFrameT;
|
|
131
|
+
return n = !1, this._lastFrameT = r, e.tickDt(i), t?.(), !e.settled;
|
|
132
|
+
});
|
|
131
133
|
};
|
|
132
134
|
loop = (e) => {
|
|
133
135
|
this.stop(), this._run(e);
|
|
134
136
|
};
|
|
135
137
|
stop = () => {
|
|
136
|
-
this._gen++, this._rafId !== null &&
|
|
138
|
+
this._gen++, this._rafId !== null && h(this._rafId), this._cleanup();
|
|
137
139
|
};
|
|
138
140
|
_cleanup() {
|
|
139
141
|
this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
|
|
@@ -143,34 +145,34 @@ var b = class {
|
|
|
143
145
|
};
|
|
144
146
|
//#endregion
|
|
145
147
|
//#region src/animation/physics/managed-stepper.ts
|
|
146
|
-
function
|
|
148
|
+
function w(e) {
|
|
147
149
|
e._playback.drive(e, () => e._emitManagedFrame());
|
|
148
150
|
}
|
|
149
|
-
function
|
|
150
|
-
e.disposed || (e._onFrame = t,
|
|
151
|
+
function T(e, t) {
|
|
152
|
+
e.disposed || (e._onFrame = t, S(e.respectReducedMotion, () => {
|
|
151
153
|
e.snap(), e._emitManagedFrame();
|
|
152
154
|
}, () => {
|
|
153
|
-
e.settled ? e._emitManagedFrame() :
|
|
155
|
+
e.settled ? e._emitManagedFrame() : w(e);
|
|
154
156
|
}));
|
|
155
157
|
}
|
|
156
|
-
function
|
|
158
|
+
function E(e) {
|
|
157
159
|
e._onFrame = void 0, e._playback.stop();
|
|
158
160
|
}
|
|
159
161
|
//#endregion
|
|
160
162
|
//#region src/animation/physics/smooth.ts
|
|
161
|
-
var
|
|
163
|
+
var D = {
|
|
162
164
|
damping: .1,
|
|
163
165
|
snapThreshold: .001,
|
|
164
166
|
targetEpsilon: 0,
|
|
165
167
|
initial: 0,
|
|
166
168
|
clamp: !0,
|
|
167
169
|
respectReducedMotion: !1
|
|
168
|
-
},
|
|
170
|
+
}, ee = class {
|
|
169
171
|
options;
|
|
170
172
|
targetValue;
|
|
171
173
|
currentValue;
|
|
172
174
|
isSettled;
|
|
173
|
-
_playback = new
|
|
175
|
+
_playback = new C();
|
|
174
176
|
_onFrame = void 0;
|
|
175
177
|
get respectReducedMotion() {
|
|
176
178
|
return this.options.respectReducedMotion;
|
|
@@ -180,7 +182,7 @@ var w = {
|
|
|
180
182
|
}
|
|
181
183
|
constructor(e) {
|
|
182
184
|
this.options = {
|
|
183
|
-
...
|
|
185
|
+
...D,
|
|
184
186
|
...e
|
|
185
187
|
}, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.isSettled = !0;
|
|
186
188
|
}
|
|
@@ -196,8 +198,8 @@ var w = {
|
|
|
196
198
|
setTarget(t) {
|
|
197
199
|
this.options.clamp && (t = e(t, 0, 1));
|
|
198
200
|
let n = Math.abs(t - this.targetValue);
|
|
199
|
-
n > 0 && n >= this.options.targetEpsilon && (this.targetValue = t,
|
|
200
|
-
this.isSettled = !1, this._onFrame &&
|
|
201
|
+
n > 0 && n >= this.options.targetEpsilon && (this.targetValue = t, S(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
202
|
+
this.isSettled = !1, this._onFrame && w(this);
|
|
201
203
|
}));
|
|
202
204
|
}
|
|
203
205
|
_snapSettled() {
|
|
@@ -216,12 +218,12 @@ var w = {
|
|
|
216
218
|
this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._playback.stop();
|
|
217
219
|
}
|
|
218
220
|
play(e) {
|
|
219
|
-
|
|
221
|
+
T(this, e);
|
|
220
222
|
}
|
|
221
223
|
stop() {
|
|
222
|
-
|
|
224
|
+
E(this);
|
|
223
225
|
}
|
|
224
|
-
},
|
|
226
|
+
}, O = {
|
|
225
227
|
response: .5,
|
|
226
228
|
dampingFraction: .86,
|
|
227
229
|
initial: 0,
|
|
@@ -232,18 +234,18 @@ var w = {
|
|
|
232
234
|
};
|
|
233
235
|
//#endregion
|
|
234
236
|
//#region src/animation/physics/spring/managed-play.ts
|
|
235
|
-
function
|
|
236
|
-
|
|
237
|
+
function k(e) {
|
|
238
|
+
w(e);
|
|
237
239
|
}
|
|
238
|
-
function
|
|
239
|
-
|
|
240
|
+
function te(e, t) {
|
|
241
|
+
T(e, t);
|
|
240
242
|
}
|
|
241
|
-
function
|
|
242
|
-
|
|
243
|
+
function ne(e) {
|
|
244
|
+
E(e);
|
|
243
245
|
}
|
|
244
246
|
//#endregion
|
|
245
247
|
//#region src/animation/physics/spring/solver/duration.ts
|
|
246
|
-
function
|
|
248
|
+
function re(t) {
|
|
247
249
|
let { visualDuration: n, duration: r, bounce: i = 0, ...a } = t, o = n ?? r ?? .5, s = 1 - e(i, -1, 1);
|
|
248
250
|
return {
|
|
249
251
|
...a,
|
|
@@ -253,7 +255,7 @@ function ie(t) {
|
|
|
253
255
|
}
|
|
254
256
|
//#endregion
|
|
255
257
|
//#region src/animation/physics/spring/solver/solver.ts
|
|
256
|
-
function
|
|
258
|
+
function A(e, t, n, r) {
|
|
257
259
|
if (t < 1) return {
|
|
258
260
|
regime: "under",
|
|
259
261
|
w: e,
|
|
@@ -278,7 +280,7 @@ function k(e, t, n, r) {
|
|
|
278
280
|
e2: Math.exp(o * r)
|
|
279
281
|
};
|
|
280
282
|
}
|
|
281
|
-
function
|
|
283
|
+
function j(e, t, n, r = {
|
|
282
284
|
x: 0,
|
|
283
285
|
v: 0
|
|
284
286
|
}) {
|
|
@@ -293,12 +295,12 @@ function A(e, t, n, r = {
|
|
|
293
295
|
let { r1: i, r2: a, e1: o, e2: s } = n, c = (t - a * e) / (i - a), l = e - c;
|
|
294
296
|
return r.x = c * o + l * s, r.v = c * i * o + l * a * s, r;
|
|
295
297
|
}
|
|
296
|
-
function
|
|
297
|
-
return
|
|
298
|
+
function M(e, t, n, r, i, a) {
|
|
299
|
+
return j(e, t, A(n, r, i, a));
|
|
298
300
|
}
|
|
299
301
|
//#endregion
|
|
300
302
|
//#region src/animation/physics/spring/solver/vector.ts
|
|
301
|
-
var
|
|
303
|
+
var N = new Float64Array(), ie = class {
|
|
302
304
|
solution = {
|
|
303
305
|
x: 0,
|
|
304
306
|
v: 0
|
|
@@ -316,10 +318,10 @@ var j = new Float64Array(), oe = class {
|
|
|
316
318
|
this.vecOrigin.set(this.vecCurrent), this.vecOriginVel.set(this.vecVelocity), this.vecTarget.set(e), this.vecElapsed = 0;
|
|
317
319
|
}
|
|
318
320
|
get values() {
|
|
319
|
-
return this.vecCurrent ??
|
|
321
|
+
return this.vecCurrent ?? N;
|
|
320
322
|
}
|
|
321
323
|
get velocities() {
|
|
322
|
-
return this.vecVelocity ??
|
|
324
|
+
return this.vecVelocity ?? N;
|
|
323
325
|
}
|
|
324
326
|
get armed() {
|
|
325
327
|
return this.vecTarget !== null;
|
|
@@ -327,32 +329,32 @@ var j = new Float64Array(), oe = class {
|
|
|
327
329
|
tick(e, t, n, r) {
|
|
328
330
|
if (this.vecTarget === null || e <= 0) return this.values;
|
|
329
331
|
this.vecElapsed += e / 1e3;
|
|
330
|
-
let i = this.vecElapsed, a = this.vecOrigin, o = this.vecOriginVel, s = this.vecTarget, c = this.vecCurrent, l = this.vecVelocity, u =
|
|
332
|
+
let i = this.vecElapsed, a = this.vecOrigin, o = this.vecOriginVel, s = this.vecTarget, c = this.vecCurrent, l = this.vecVelocity, u = A(t, n, r, i), d = this.solution;
|
|
331
333
|
for (let e = 0; e < c.length; e++) {
|
|
332
334
|
let t = a[e] - s[e], n = o[e];
|
|
333
|
-
|
|
335
|
+
j(t, n, u, d), c[e] = s[e] + d.x, l[e] = d.v;
|
|
334
336
|
}
|
|
335
337
|
return c;
|
|
336
338
|
}
|
|
337
339
|
};
|
|
338
340
|
//#endregion
|
|
339
341
|
//#region src/animation/physics/spring/vector-surface.ts
|
|
340
|
-
function
|
|
341
|
-
let n = e ?? new
|
|
342
|
+
function ae(e, t) {
|
|
343
|
+
let n = e ?? new ie();
|
|
342
344
|
return n.setTargets(t), n;
|
|
343
345
|
}
|
|
344
|
-
function
|
|
345
|
-
return e?.values ??
|
|
346
|
+
function oe(e) {
|
|
347
|
+
return e?.values ?? N;
|
|
346
348
|
}
|
|
347
|
-
function
|
|
348
|
-
return e?.velocities ??
|
|
349
|
+
function se(e) {
|
|
350
|
+
return e?.velocities ?? N;
|
|
349
351
|
}
|
|
350
|
-
function
|
|
351
|
-
return e === null || t <= 0 ?
|
|
352
|
+
function ce(e, t, n, r, i) {
|
|
353
|
+
return e === null || t <= 0 ? N : e.tick(t, n, r, i);
|
|
352
354
|
}
|
|
353
355
|
//#endregion
|
|
354
356
|
//#region src/animation/physics/spring/progress.ts
|
|
355
|
-
var
|
|
357
|
+
var P = class e {
|
|
356
358
|
options;
|
|
357
359
|
get respectReducedMotion() {
|
|
358
360
|
return this.options.respectReducedMotion;
|
|
@@ -371,19 +373,19 @@ var N = class e {
|
|
|
371
373
|
subscribers = /* @__PURE__ */ new Set();
|
|
372
374
|
disposed = !1;
|
|
373
375
|
vectorLanes = null;
|
|
374
|
-
_playback = new
|
|
376
|
+
_playback = new C();
|
|
375
377
|
_onFrame = void 0;
|
|
376
378
|
_emitManagedFrame() {
|
|
377
379
|
this._onFrame?.(this.value, this.velocity);
|
|
378
380
|
}
|
|
379
381
|
constructor(e) {
|
|
380
382
|
this.options = {
|
|
381
|
-
...
|
|
383
|
+
...O,
|
|
382
384
|
...e
|
|
383
|
-
}, 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 =
|
|
385
|
+
}, 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;
|
|
384
386
|
}
|
|
385
387
|
static fromDuration(t) {
|
|
386
|
-
return new e(
|
|
388
|
+
return new e(re(t ?? {}));
|
|
387
389
|
}
|
|
388
390
|
get target() {
|
|
389
391
|
return this.targetValue;
|
|
@@ -401,8 +403,8 @@ var N = class e {
|
|
|
401
403
|
e === this.targetValue && this.currentVelocity === 0 || this.reseatTarget(e);
|
|
402
404
|
}
|
|
403
405
|
reseatTarget(e) {
|
|
404
|
-
this.targetValue = e,
|
|
405
|
-
this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale =
|
|
406
|
+
this.targetValue = e, S(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
407
|
+
this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale = x(this.options.respectReducedMotion), this._onFrame && k(this);
|
|
406
408
|
});
|
|
407
409
|
}
|
|
408
410
|
_snapSettled() {
|
|
@@ -418,7 +420,7 @@ var N = class e {
|
|
|
418
420
|
return this.disposed || this.isSettled ? this.currentValue : (this.elapsed = Math.max(0, e), this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
|
|
419
421
|
}
|
|
420
422
|
evaluateAt(e) {
|
|
421
|
-
let t = this.scaledTarget(), n = this.originValue - t, r = this.originVelocity, { x: i, v: a } =
|
|
423
|
+
let t = this.scaledTarget(), n = this.originValue - t, r = this.originVelocity, { x: i, v: a } = M(n, r, this.omega, this.zeta, this.omegaD, e);
|
|
422
424
|
this.currentValue = t + i, this.currentVelocity = a;
|
|
423
425
|
}
|
|
424
426
|
scaledTarget() {
|
|
@@ -434,19 +436,19 @@ var N = class e {
|
|
|
434
436
|
}
|
|
435
437
|
reset(e, t) {
|
|
436
438
|
let n = e ?? 0, r = t ?? 0;
|
|
437
|
-
this.targetValue = n, this.currentValue = n, this.currentVelocity = r, this.originValue = n, this.originVelocity = r, this.elapsed = 0, this.amplitudeScale =
|
|
439
|
+
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();
|
|
438
440
|
}
|
|
439
441
|
setTargets(e) {
|
|
440
|
-
this.vectorLanes =
|
|
442
|
+
this.vectorLanes = ae(this.vectorLanes, e);
|
|
441
443
|
}
|
|
442
444
|
get values() {
|
|
443
|
-
return
|
|
445
|
+
return oe(this.vectorLanes);
|
|
444
446
|
}
|
|
445
447
|
get velocities() {
|
|
446
|
-
return
|
|
448
|
+
return se(this.vectorLanes);
|
|
447
449
|
}
|
|
448
450
|
tickVector(e) {
|
|
449
|
-
return this.disposed || this.vectorLanes === null || e <= 0 ? this.values :
|
|
451
|
+
return this.disposed || this.vectorLanes === null || e <= 0 ? this.values : ce(this.vectorLanes, e, this.omega, this.zeta, this.omegaD);
|
|
450
452
|
}
|
|
451
453
|
subscribe(e) {
|
|
452
454
|
return this.subscribers.add(e), () => {
|
|
@@ -460,86 +462,226 @@ var N = class e {
|
|
|
460
462
|
this.disposed = !0, this._playback.stop(), this.subscribers.clear();
|
|
461
463
|
}
|
|
462
464
|
play(e) {
|
|
463
|
-
|
|
465
|
+
te(this, e);
|
|
464
466
|
}
|
|
465
467
|
stop() {
|
|
466
|
-
|
|
468
|
+
ne(this);
|
|
467
469
|
}
|
|
468
|
-
};
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
function P(e) {
|
|
472
|
-
let t = new N({
|
|
470
|
+
}, le = 12, ue = .02;
|
|
471
|
+
function F(e) {
|
|
472
|
+
let t = e.initialVelocity ?? 0, n = new P({
|
|
473
473
|
response: e.response,
|
|
474
474
|
dampingFraction: e.dampingFraction,
|
|
475
475
|
initial: 0,
|
|
476
|
+
initialVelocity: t,
|
|
476
477
|
settleThreshold: e.settleThreshold,
|
|
477
478
|
velocitySettleThreshold: e.settleThreshold
|
|
478
479
|
});
|
|
479
|
-
|
|
480
|
-
let n = [];
|
|
481
|
-
for (let
|
|
482
|
-
|
|
480
|
+
n.target = 1;
|
|
481
|
+
let r = () => n.settled ? 1 : n.value, i = [], a = 0;
|
|
482
|
+
if (t !== 0) for (let t = le; t >= 1; t--) {
|
|
483
|
+
let o = 2 ** -t;
|
|
484
|
+
n._stepSeconds(o * e.dt - a), a = o * e.dt, i.push([o, r()]);
|
|
485
|
+
}
|
|
486
|
+
let o = [];
|
|
487
|
+
for (let t = 1; t <= e.sampleCount; t++) n._stepSeconds(e.dt - a), a = 0, o.push(r());
|
|
488
|
+
if (n.dispose(), i.length > 0) {
|
|
489
|
+
let n = (n, r) => Math.abs(r / (n * e.dt) - t) <= ue * Math.abs(t);
|
|
490
|
+
if (o.length > 0 && n(1, o[0])) i = [];
|
|
491
|
+
else {
|
|
492
|
+
let e = 0;
|
|
493
|
+
for (let t = i.length - 1; t >= 0; t--) if (n(i[t][0], i[t][1])) {
|
|
494
|
+
e = t;
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
i = i.slice(e);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
return {
|
|
501
|
+
positions: o,
|
|
502
|
+
head: i
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/animation/physics/spring/solver/settle.ts
|
|
507
|
+
var de = 4096, fe = 20, pe = 2 ** 32;
|
|
508
|
+
function I(e) {
|
|
509
|
+
let t = e.response, n = e.dampingFraction, r = e.initialVelocity ?? O.initialVelocity, i = e.settleThreshold ?? O.settleThreshold, a = e.velocitySettleThreshold ?? O.velocitySettleThreshold;
|
|
510
|
+
if (!(t > 0) || !Number.isFinite(t)) throw RangeError(`settleTime: response must be finite and > 0; got ${t}.`);
|
|
511
|
+
if (!(n >= 0) || !Number.isFinite(n)) throw RangeError(`settleTime: dampingFraction must be finite and >= 0; got ${n}.`);
|
|
512
|
+
if (!(i > 0) || !Number.isFinite(i)) throw RangeError(`settleTime: settleThreshold must be finite and > 0; got ${i}.`);
|
|
513
|
+
if (!(a > 0)) throw RangeError(`settleTime: velocitySettleThreshold must be > 0 (Infinity allowed); got ${a}.`);
|
|
514
|
+
if (!Number.isFinite(r)) throw RangeError(`settleTime: initialVelocity must be finite; got ${r}.`);
|
|
515
|
+
return R(-1, r, t, n, i, a);
|
|
516
|
+
}
|
|
517
|
+
function L(e, t, n, r, i) {
|
|
518
|
+
let a, o = (e) => a(e), s = 0;
|
|
519
|
+
if (r < 1) {
|
|
520
|
+
let o = e, s = (t + r * n * e) / i, c = Math.hypot(o, s);
|
|
521
|
+
a = (e) => {
|
|
522
|
+
let t = Math.exp(-r * n * e) * c;
|
|
523
|
+
return [t, t * n];
|
|
524
|
+
};
|
|
525
|
+
} else if (r === 1) {
|
|
526
|
+
let r = e, i = t + n * e, c = Math.abs(i), l = Math.abs(r), u = Math.abs(i - n * r);
|
|
527
|
+
s = 1 / n, a = (e) => {
|
|
528
|
+
let t = Math.exp(-n * e);
|
|
529
|
+
return [t * (l + c * e), t * (u + n * c * e)];
|
|
530
|
+
}, o = (e, t) => {
|
|
531
|
+
let r = Math.exp(-n * e);
|
|
532
|
+
return [r * (l + c * (e + t)), r * (u + n * c * (e + t))];
|
|
533
|
+
};
|
|
534
|
+
} else {
|
|
535
|
+
let i = n * Math.sqrt(r * r - 1), o = -r * n + i, s = -r * n - i, c = (t - s * e) / (o - s), l = e - c;
|
|
536
|
+
a = (e) => {
|
|
537
|
+
let t = Math.abs(c) * Math.exp(o * e), n = Math.abs(l) * Math.exp(s * e);
|
|
538
|
+
return [t + n, t * -o + n * -s];
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
bound: a,
|
|
543
|
+
supBound: o,
|
|
544
|
+
onset: s
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
function R(e, t, n, r, i, a) {
|
|
548
|
+
let o = 2 * Math.PI / n, s = r < 1 ? o * Math.sqrt(1 - r * r) : 0, { bound: c, supBound: l, onset: u } = L(e, t, o, r, s), d = (e) => {
|
|
549
|
+
let [t, n] = c(e);
|
|
550
|
+
return t < i && n < a;
|
|
551
|
+
}, f = u, p = Math.max(n, u);
|
|
552
|
+
for (; !d(p);) {
|
|
553
|
+
if (p > pe * n) return Infinity;
|
|
554
|
+
f = p, p *= 2;
|
|
555
|
+
}
|
|
556
|
+
for (let e = 0; e < 30; e++) {
|
|
557
|
+
let e = (f + p) / 2;
|
|
558
|
+
d(e) ? p = e : f = e;
|
|
559
|
+
}
|
|
560
|
+
let m = {
|
|
561
|
+
x: 0,
|
|
562
|
+
v: 0
|
|
563
|
+
}, h = (n) => {
|
|
564
|
+
j(e, t, A(o, r, s, n), m);
|
|
565
|
+
}, g = (e) => (h(e), !(Math.abs(m.x) < i && Math.abs(m.v) < a)), _ = (e, t) => {
|
|
566
|
+
h(e);
|
|
567
|
+
let [n, s] = l(e, t), c = o * o * n + 2 * r * o * s;
|
|
568
|
+
return Math.abs(m.x) + t * s < i && Math.abs(m.v) + t * c < a;
|
|
569
|
+
}, v = (e, t, n) => {
|
|
570
|
+
if (_(e, t - e)) return null;
|
|
571
|
+
if (n === 0) return g(e) ? [e, t] : null;
|
|
572
|
+
let r = (e + t) / 2;
|
|
573
|
+
return v(r, t, n - 1) ?? v(e, r, n - 1);
|
|
574
|
+
}, y = n / de;
|
|
575
|
+
for (let e = p; e > 0;) {
|
|
576
|
+
let t = Math.max(0, e - y), n = v(t, e, fe);
|
|
577
|
+
if (n) {
|
|
578
|
+
let [e, t] = n;
|
|
579
|
+
for (let n = 0; n < 40; n++) {
|
|
580
|
+
let n = (e + t) / 2;
|
|
581
|
+
g(n) ? e = n : t = n;
|
|
582
|
+
}
|
|
583
|
+
return t;
|
|
584
|
+
}
|
|
585
|
+
e = t;
|
|
586
|
+
}
|
|
587
|
+
return 0;
|
|
588
|
+
}
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region src/animation/physics/spring/css/span.ts
|
|
591
|
+
function z(e) {
|
|
592
|
+
if (e.maxDuration !== "settle") return e.maxDuration ?? e.response * 4;
|
|
593
|
+
let t = I({
|
|
594
|
+
response: e.response,
|
|
595
|
+
dampingFraction: e.dampingFraction,
|
|
596
|
+
...e.initialVelocity !== void 0 && { initialVelocity: e.initialVelocity },
|
|
597
|
+
...e.settleThreshold !== void 0 && { settleThreshold: e.settleThreshold }
|
|
598
|
+
});
|
|
599
|
+
if (t === Infinity) throw RangeError(e.dampingFraction === 0 ? "maxDuration \"settle\": an undamped spring never settles; pass a finite maxDuration." : "maxDuration \"settle\": this spring never settles in floating-point arithmetic (damped so hard its slow root rounds to 0); pass a finite maxDuration.");
|
|
600
|
+
if (!(t > 0)) throw RangeError("maxDuration \"settle\": the spring starts at rest inside settleThreshold, so there is no span to take; pass a finite maxDuration.");
|
|
601
|
+
return t;
|
|
483
602
|
}
|
|
484
603
|
//#endregion
|
|
485
604
|
//#region src/animation/physics/spring/css/linear-stops.ts
|
|
486
|
-
function
|
|
487
|
-
let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = e
|
|
605
|
+
function B(e) {
|
|
606
|
+
let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = z(e), { positions: i, head: a } = F({
|
|
488
607
|
response: e.response,
|
|
489
608
|
dampingFraction: e.dampingFraction,
|
|
490
609
|
sampleCount: t,
|
|
491
610
|
settleThreshold: n,
|
|
611
|
+
initialVelocity: e.initialVelocity ?? 0,
|
|
492
612
|
dt: r / (t + 1)
|
|
493
|
-
}),
|
|
613
|
+
}), o = ["0"];
|
|
614
|
+
for (let [e, n] of a) {
|
|
615
|
+
let r = e / (t + 1) * 100;
|
|
616
|
+
o.push(`${n.toFixed(9)} ${r.toFixed(6)}%`);
|
|
617
|
+
}
|
|
494
618
|
for (let e = 1; e <= t; e++) {
|
|
495
619
|
let n = e / (t + 1) * 100, r = i[e - 1];
|
|
496
|
-
|
|
620
|
+
o.push(`${r.toFixed(5)} ${n.toFixed(3)}%`);
|
|
497
621
|
}
|
|
498
|
-
return
|
|
622
|
+
return o.push("1"), `linear(${o.join(", ")})`;
|
|
499
623
|
}
|
|
500
|
-
var
|
|
501
|
-
function
|
|
624
|
+
var V = (e) => Math.round(e * 1e5) / 1e5;
|
|
625
|
+
function me(e) {
|
|
502
626
|
let t = e.length - 1;
|
|
503
627
|
if (t < 1) throw RangeError(`linearFromSamples needs at least 2 samples; got ${e.length}.`);
|
|
504
628
|
let n = [];
|
|
505
|
-
for (let r = 0; r <= t; r++) n.push(`${
|
|
629
|
+
for (let r = 0; r <= t; r++) n.push(`${V(e[r])} ${V(r / t * 100)}%`);
|
|
506
630
|
return `linear(${n.join(", ")})`;
|
|
507
631
|
}
|
|
508
632
|
//#endregion
|
|
509
633
|
//#region src/animation/physics/spring/css/timing-function.ts
|
|
510
|
-
function
|
|
511
|
-
|
|
634
|
+
function he(e) {
|
|
635
|
+
return H(e, z(e)).lut;
|
|
636
|
+
}
|
|
637
|
+
function H(e, t) {
|
|
638
|
+
let n = e.sampleCount ?? 64, r = e.settleThreshold ?? .001, { positions: i, head: a } = F({
|
|
512
639
|
response: e.response,
|
|
513
640
|
dampingFraction: e.dampingFraction,
|
|
514
|
-
sampleCount:
|
|
515
|
-
settleThreshold:
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
641
|
+
sampleCount: n,
|
|
642
|
+
settleThreshold: r,
|
|
643
|
+
initialVelocity: e.initialVelocity ?? 0,
|
|
644
|
+
dt: t / n
|
|
645
|
+
}), o = new Float64Array(n + 1);
|
|
646
|
+
o[0] = 0;
|
|
647
|
+
for (let e = 1; e <= n; e++) o[e] = i[e - 1];
|
|
648
|
+
return o[n] = 1, {
|
|
649
|
+
lut: o,
|
|
650
|
+
head: a.map(([e, t]) => [e / n, t])
|
|
651
|
+
};
|
|
521
652
|
}
|
|
522
|
-
function
|
|
523
|
-
let t =
|
|
653
|
+
function ge(e) {
|
|
654
|
+
let t = z(e), { lut: n, head: r } = H(e, t), i = n.length - 1, a = [
|
|
655
|
+
[0, 0],
|
|
656
|
+
...r,
|
|
657
|
+
[1 / i, n[1]]
|
|
658
|
+
], o = (e) => {
|
|
524
659
|
if (e <= 0) return 0;
|
|
525
660
|
if (e >= 1) return 1;
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
661
|
+
if (r.length > 0 && e < a[a.length - 1][0]) {
|
|
662
|
+
let t = 1;
|
|
663
|
+
for (; a[t][0] < e;) t++;
|
|
664
|
+
let [n, r] = a[t - 1], [i, o] = a[t];
|
|
665
|
+
return r + (o - r) * (e - n) / (i - n);
|
|
666
|
+
}
|
|
667
|
+
let t = e * i, o = Math.floor(t), s = t - o, c = n[o];
|
|
668
|
+
return c + (n[o + 1] - c) * s;
|
|
669
|
+
}, s = {
|
|
529
670
|
response: e.response,
|
|
530
|
-
dampingFraction: e.dampingFraction
|
|
671
|
+
dampingFraction: e.dampingFraction,
|
|
672
|
+
maxDuration: t
|
|
531
673
|
};
|
|
532
|
-
return e.settleThreshold !== void 0 && (
|
|
533
|
-
fn:
|
|
534
|
-
css:
|
|
674
|
+
return e.settleThreshold !== void 0 && (s.settleThreshold = e.settleThreshold), e.initialVelocity !== void 0 && (s.initialVelocity = e.initialVelocity), {
|
|
675
|
+
fn: o,
|
|
676
|
+
css: B(s)
|
|
535
677
|
};
|
|
536
678
|
}
|
|
537
679
|
//#endregion
|
|
538
680
|
//#region src/animation/compile/emit/selector.ts
|
|
539
|
-
var
|
|
681
|
+
var U = (e) => `${Number((e * 100).toFixed(10))}%`, _e = (e) => e.kind === "percent" ? U(e.value) : e.offset === void 0 ? e.name : `${e.name} ${U(e.offset)}`;
|
|
540
682
|
//#endregion
|
|
541
683
|
//#region src/animation/orchestration/timeline/native.ts
|
|
542
|
-
function
|
|
684
|
+
function ve(e) {
|
|
543
685
|
if (typeof window > "u") return null;
|
|
544
686
|
if (e.kind === "scroll") {
|
|
545
687
|
if (globalThis.ScrollTimeline === void 0) return null;
|
|
@@ -552,9 +694,9 @@ function V(e) {
|
|
|
552
694
|
}
|
|
553
695
|
//#endregion
|
|
554
696
|
//#region src/animation/physics/decay.ts
|
|
555
|
-
var
|
|
556
|
-
function
|
|
557
|
-
let t = e.initial ?? 0, n = e.velocity, r = e.friction ??
|
|
697
|
+
var W = 5;
|
|
698
|
+
function ye(e) {
|
|
699
|
+
let t = e.initial ?? 0, n = e.velocity, r = e.friction ?? W;
|
|
558
700
|
if (r <= 0) throw Error("decay() requires a friction coefficient > 0.");
|
|
559
701
|
let i = t + n / r;
|
|
560
702
|
return (e) => {
|
|
@@ -569,8 +711,8 @@ function U(e) {
|
|
|
569
711
|
};
|
|
570
712
|
};
|
|
571
713
|
}
|
|
572
|
-
function
|
|
573
|
-
let t = e.friction ??
|
|
714
|
+
function be(e) {
|
|
715
|
+
let t = e.friction ?? W;
|
|
574
716
|
if (t <= 0) throw Error("decayRest() requires a friction coefficient > 0.");
|
|
575
717
|
return (e.initial ?? 0) + e.velocity / t;
|
|
576
718
|
}
|
|
@@ -594,24 +736,24 @@ function q(e, t, n) {
|
|
|
594
736
|
if (i === void 0) throw Error(`Sequence: unknown position "${e}". Register it with .label("${e}", at) first, or pass a number / "+=n" / "-=n".`);
|
|
595
737
|
return i;
|
|
596
738
|
}
|
|
597
|
-
function
|
|
739
|
+
function xe(t, n, r, i) {
|
|
598
740
|
if (n <= 0) return 0;
|
|
599
741
|
let a = e(t, 0, n * r), o = Math.floor(a / n), s = a - o * n;
|
|
600
742
|
return s === 0 && o > 0 && (--o, s = n), i && o % 2 == 1 ? n - s : s;
|
|
601
743
|
}
|
|
602
|
-
function
|
|
744
|
+
function Se(e, t, n) {
|
|
603
745
|
return n && (t - 1) % 2 == 1 ? 0 : e;
|
|
604
746
|
}
|
|
605
|
-
function
|
|
747
|
+
function Ce(e, t, n) {
|
|
606
748
|
return e === 1 && t === 1 && !n;
|
|
607
749
|
}
|
|
608
750
|
function J(e, t, n) {
|
|
609
751
|
return n === 0 ? e : e - t / n;
|
|
610
752
|
}
|
|
611
|
-
async function
|
|
753
|
+
async function we(e, t) {
|
|
612
754
|
e._playOrigin === void 0 && (e._playOrigin = J(t, e._time, e._rate)), e._lastClock = t;
|
|
613
|
-
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 ?
|
|
614
|
-
if (e._time = a,
|
|
755
|
+
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 ? Se(e.duration, e._repeatCount, e._yoyoOn) : 0 : xe(n, e.duration, e._repeatCount, e._yoyoOn);
|
|
756
|
+
if (e._time = a, Ce(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);
|
|
615
757
|
if (K(e.events, e.entries, e.labels, a), G(e.entries, a), i) {
|
|
616
758
|
Y(e);
|
|
617
759
|
let t = e._resolvePlay;
|
|
@@ -641,20 +783,20 @@ function Z(e, t) {
|
|
|
641
783
|
e._playingPromise === n && (e._playingPromise = null);
|
|
642
784
|
}), n;
|
|
643
785
|
}
|
|
644
|
-
function
|
|
786
|
+
function Te(e) {
|
|
645
787
|
return e.started && !e.paused;
|
|
646
788
|
}
|
|
647
|
-
function
|
|
789
|
+
function Ee(e, t, n) {
|
|
648
790
|
e.paused ? n() : t();
|
|
649
791
|
}
|
|
650
792
|
//#endregion
|
|
651
793
|
//#region src/animation/orchestration/sequence/lifecycle.ts
|
|
652
|
-
function
|
|
794
|
+
function De(e) {
|
|
653
795
|
return Q(e, 0);
|
|
654
796
|
}
|
|
655
797
|
function Q(e, t) {
|
|
656
798
|
if (e._playingPromise) return e._playingPromise;
|
|
657
|
-
if (e.respectReducedMotion &&
|
|
799
|
+
if (e.respectReducedMotion && b()) return e.seek(e.duration), Promise.resolve();
|
|
658
800
|
for (let { animation: t, at: n } of e.entries) t.startTime = n, t.started = !0, t.managed = !0;
|
|
659
801
|
return e._time = t, e._paused = !1, e._playOrigin = void 0, e._lastClock = void 0, Z(e, () => new Promise((t) => {
|
|
660
802
|
e._resolvePlay = t, e.playback.loop(e._boundFrame);
|
|
@@ -665,33 +807,33 @@ function $(e) {
|
|
|
665
807
|
let t = e._resolvePlay;
|
|
666
808
|
e._resolvePlay = null, t?.();
|
|
667
809
|
}
|
|
668
|
-
function
|
|
810
|
+
function Oe(e) {
|
|
669
811
|
!e._playingPromise || e._paused || (e._paused = !0, e.playback.stop(), e._playOrigin = void 0);
|
|
670
812
|
}
|
|
671
|
-
function
|
|
813
|
+
function ke(e) {
|
|
672
814
|
if (!e._playingPromise) {
|
|
673
815
|
Q(e, e._time);
|
|
674
816
|
return;
|
|
675
817
|
}
|
|
676
818
|
e._paused && (e._paused = !1, e._playOrigin = void 0, e._lastClock = void 0, e.playback.loop(e._boundFrame));
|
|
677
819
|
}
|
|
678
|
-
function
|
|
820
|
+
function Ae(e, t) {
|
|
679
821
|
if (!Number.isFinite(t)) throw Error(`Sequence.timeScale(n): n must be a finite number, got ${t}.`);
|
|
680
822
|
e._rate = t, X(e, e._playingPromise != null);
|
|
681
823
|
}
|
|
682
|
-
function
|
|
824
|
+
function je(e) {
|
|
683
825
|
e._rate = -e._rate, X(e, e._playingPromise != null);
|
|
684
826
|
}
|
|
685
|
-
function
|
|
827
|
+
function Me(e, t) {
|
|
686
828
|
if (t !== Infinity && (!Number.isInteger(t) || t < 1)) throw Error(`Sequence.repeat(count): count must be a positive integer or Infinity, got ${t}.`);
|
|
687
829
|
e._repeatCount = t;
|
|
688
830
|
}
|
|
689
|
-
function
|
|
831
|
+
function Ne(e, t) {
|
|
690
832
|
e._yoyoOn = t;
|
|
691
833
|
}
|
|
692
834
|
//#endregion
|
|
693
835
|
//#region src/animation/orchestration/sequence/events.ts
|
|
694
|
-
var
|
|
836
|
+
var Pe = class {
|
|
695
837
|
subscribers = new Map([
|
|
696
838
|
["segment:enter", /* @__PURE__ */ new Set()],
|
|
697
839
|
["segment:leave", /* @__PURE__ */ new Set()],
|
|
@@ -726,14 +868,14 @@ var Ce = class {
|
|
|
726
868
|
}
|
|
727
869
|
this._prevPhase = n;
|
|
728
870
|
}
|
|
729
|
-
},
|
|
871
|
+
}, Fe = class {
|
|
730
872
|
entries = [];
|
|
731
873
|
labels = /* @__PURE__ */ new Map();
|
|
732
|
-
events = new
|
|
874
|
+
events = new Pe();
|
|
733
875
|
cursor = 0;
|
|
734
876
|
_time = 0;
|
|
735
877
|
respectReducedMotion;
|
|
736
|
-
playback = new
|
|
878
|
+
playback = new C();
|
|
737
879
|
_boundFrame;
|
|
738
880
|
_resolvePlay = null;
|
|
739
881
|
_playOrigin = void 0;
|
|
@@ -786,32 +928,32 @@ var Ce = class {
|
|
|
786
928
|
return this._playingPromise ?? Promise.resolve();
|
|
787
929
|
}
|
|
788
930
|
play() {
|
|
789
|
-
return
|
|
931
|
+
return De(this);
|
|
790
932
|
}
|
|
791
933
|
async _frame(e) {
|
|
792
|
-
return
|
|
934
|
+
return we(this, e);
|
|
793
935
|
}
|
|
794
936
|
stop() {
|
|
795
937
|
return $(this), this;
|
|
796
938
|
}
|
|
797
939
|
pause() {
|
|
798
|
-
return
|
|
940
|
+
return Oe(this), this;
|
|
799
941
|
}
|
|
800
942
|
resume() {
|
|
801
|
-
return
|
|
943
|
+
return ke(this), this;
|
|
802
944
|
}
|
|
803
945
|
timeScale(e) {
|
|
804
|
-
return
|
|
946
|
+
return Ae(this, e), this;
|
|
805
947
|
}
|
|
806
948
|
reverse() {
|
|
807
|
-
return
|
|
949
|
+
return je(this), this;
|
|
808
950
|
}
|
|
809
951
|
repeat(e) {
|
|
810
|
-
return
|
|
952
|
+
return Me(this, e), this;
|
|
811
953
|
}
|
|
812
954
|
yoyo(e = !0) {
|
|
813
|
-
return
|
|
955
|
+
return Ne(this, e), this;
|
|
814
956
|
}
|
|
815
957
|
};
|
|
816
958
|
//#endregion
|
|
817
|
-
export {
|
|
959
|
+
export { d as A, S as C, n as D, t as E, i as M, a as N, f as O, o as P, x as S, e as T, A as _, ye as a, ee as b, _e as c, me as d, B as f, P as g, I as h, Ee as i, s as j, u as k, ge as l, R as m, Z as n, be as o, L as p, Te as r, ve as s, Fe as t, he as u, j as v, p as w, C as x, O as y };
|