@mkbabb/keyframes.js 5.1.0 → 5.3.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 +98 -8
- package/dist/easing-registry-BAgudUsG.js +2 -0
- package/dist/{easing-registry-DHV2-5gA.js → easing-registry-BlbS88NR.js} +2 -2
- package/dist/engine/index.d.ts +570 -323
- package/dist/engine/index.js +3710 -17
- package/dist/keyframes.d.ts +1043 -454
- package/dist/keyframes.js +277 -107
- package/dist/{sequence-C_DCiOIQ.js → sequence-CES7o7hs.js} +258 -182
- package/package.json +104 -100
- package/dist/animation-BGyzfzBq.js +0 -947
- package/dist/compile-CcSUwM8R.js +0 -276
- package/dist/delegation-DWwr4IXr.js +0 -263
- package/dist/draw-svg-GURj9nin.js +0 -45
- package/dist/easing-registry-y1p9McFy.js +0 -2
- package/dist/engine-DEVgCTUy.js +0 -156
- package/dist/engine-DrBtsKaf.js +0 -4
- package/dist/format-C-Gi9r7L.js +0 -123
- package/dist/grammar-BLucehC4.js +0 -23
- package/dist/group-vJcsHKN9.js +0 -360
- package/dist/ingest-S5hUe20K.js +0 -166
- package/dist/morph-svg-BToeumw5.js +0 -89
- package/dist/motion-path-pQVbamWT.js +0 -35
- package/dist/parse-flatten-DRMHFytp.js +0 -2
- package/dist/parse-flatten-ZZUSEQEL.js +0 -63
- package/dist/presets-BG2Fczzq.js +0 -275
- package/dist/scheduler-CUtVnuoU.js +0 -14
- package/dist/scroll-CxpYFO4u.js +0 -180
- package/dist/validate-DDeGnvSt.js +0 -39
|
@@ -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("./easing-registry-
|
|
30
|
+
t = await import("./easing-registry-BAgudUsG.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
|
}
|
|
@@ -38,7 +38,7 @@ async function d(e) {
|
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/animation/internal/binarySearch.ts
|
|
41
|
-
function
|
|
41
|
+
function ee(e, t, n, r) {
|
|
42
42
|
let i = 0, a = e.length - 1;
|
|
43
43
|
for (; i <= a;) {
|
|
44
44
|
let o = i + a >> 1, s = e[o];
|
|
@@ -50,16 +50,16 @@ function f(e, t, n, r) {
|
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/animation/internal/leaves.ts
|
|
53
|
-
var
|
|
54
|
-
function
|
|
53
|
+
var f = 1e3 / 60;
|
|
54
|
+
function p(e) {
|
|
55
55
|
if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
|
|
56
|
-
let t =
|
|
56
|
+
let t = f, n = Date.now();
|
|
57
57
|
return setTimeout(() => {
|
|
58
58
|
let r = Date.now(), i = r - n;
|
|
59
|
-
n = r, t = Math.max(0,
|
|
59
|
+
n = r, t = Math.max(0, f - i), e(r);
|
|
60
60
|
}, t);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function m(e) {
|
|
63
63
|
if (e != null) {
|
|
64
64
|
if (typeof e == "number" && typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
|
|
65
65
|
clearTimeout(e);
|
|
@@ -67,23 +67,23 @@ function h(e) {
|
|
|
67
67
|
}
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region src/animation/internal/reduced-motion.ts
|
|
70
|
-
var
|
|
71
|
-
function
|
|
70
|
+
var te = "(prefers-reduced-motion: reduce)", h = null, g;
|
|
71
|
+
function ne() {
|
|
72
72
|
let e = typeof window > "u" ? void 0 : window.matchMedia;
|
|
73
|
-
return typeof e == "function" ?
|
|
73
|
+
return typeof e == "function" ? h !== null && g === e ? h : (g = e, h = e.call(window, te), h) : (h = null, g = e, null);
|
|
74
74
|
}
|
|
75
|
-
function
|
|
76
|
-
return
|
|
75
|
+
function _() {
|
|
76
|
+
return ne()?.matches ?? !1;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return e === !1 || e === void 0 || !
|
|
78
|
+
function v(e) {
|
|
79
|
+
return e === !1 || e === void 0 || !_() ? 1 : e === !0 || e < 0 ? 0 : e > 1 ? 1 : e;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
return !e && e !== 0 || !
|
|
81
|
+
function y(e, t, n) {
|
|
82
|
+
return !e && e !== 0 || !_() ? n() : e === !0 || e === 0 ? t() : n();
|
|
83
83
|
}
|
|
84
84
|
//#endregion
|
|
85
85
|
//#region src/animation/physics/playback.ts
|
|
86
|
-
var
|
|
86
|
+
var b = class {
|
|
87
87
|
_rafId = null;
|
|
88
88
|
_startTime = void 0;
|
|
89
89
|
_lastFrameT = 0;
|
|
@@ -94,16 +94,16 @@ var C = class {
|
|
|
94
94
|
}
|
|
95
95
|
_run(e) {
|
|
96
96
|
let t = ++this._gen, n = (e) => {
|
|
97
|
-
t === this._gen && (e ? this._rafId =
|
|
97
|
+
t === this._gen && (e ? this._rafId = p(r) : this._cleanup());
|
|
98
98
|
}, r = (t) => {
|
|
99
99
|
let r = e(t);
|
|
100
100
|
r && typeof r.then == "function" ? r.then(n) : n(r);
|
|
101
101
|
};
|
|
102
|
-
this._rafId =
|
|
102
|
+
this._rafId = p(r);
|
|
103
103
|
}
|
|
104
104
|
play = (t, n, r) => {
|
|
105
105
|
if (t <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
|
|
106
|
-
return this.stop(),
|
|
106
|
+
return this.stop(), y(r?.respectReducedMotion, () => (n(1), Promise.resolve()), () => new Promise((r) => {
|
|
107
107
|
this._resolve = r, this._startTime = void 0, this._run((r) => {
|
|
108
108
|
this._startTime === void 0 && (this._startTime = r);
|
|
109
109
|
let i = e((r - this._startTime) / t, 0, 1);
|
|
@@ -121,14 +121,32 @@ var C = class {
|
|
|
121
121
|
this.stop(), this._run(e);
|
|
122
122
|
};
|
|
123
123
|
stop = () => {
|
|
124
|
-
this._gen++, this._rafId !== null &&
|
|
124
|
+
this._gen++, this._rafId !== null && m(this._rafId), this._cleanup();
|
|
125
125
|
};
|
|
126
126
|
_cleanup() {
|
|
127
127
|
this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
|
|
128
128
|
let e = this._resolve;
|
|
129
129
|
this._resolve = null, e?.();
|
|
130
130
|
}
|
|
131
|
-
}
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/animation/physics/managed-stepper.ts
|
|
134
|
+
function x(e) {
|
|
135
|
+
e._playback.drive(e, () => e._emitManagedFrame());
|
|
136
|
+
}
|
|
137
|
+
function S(e, t) {
|
|
138
|
+
e.disposed || (e._onFrame = t, y(e.respectReducedMotion, () => {
|
|
139
|
+
e.snap(), e._emitManagedFrame();
|
|
140
|
+
}, () => {
|
|
141
|
+
e.settled ? e._emitManagedFrame() : x(e);
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
function C(e) {
|
|
145
|
+
e._onFrame = void 0, e._playback.stop();
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/animation/physics/smooth.ts
|
|
149
|
+
var w = {
|
|
132
150
|
damping: .1,
|
|
133
151
|
snapThreshold: .001,
|
|
134
152
|
targetEpsilon: 0,
|
|
@@ -140,8 +158,14 @@ var C = class {
|
|
|
140
158
|
targetValue;
|
|
141
159
|
currentValue;
|
|
142
160
|
isSettled;
|
|
143
|
-
_playback = new
|
|
161
|
+
_playback = new b();
|
|
144
162
|
_onFrame = void 0;
|
|
163
|
+
get respectReducedMotion() {
|
|
164
|
+
return this.options.respectReducedMotion;
|
|
165
|
+
}
|
|
166
|
+
_emitManagedFrame() {
|
|
167
|
+
this._onFrame?.(this.currentValue);
|
|
168
|
+
}
|
|
145
169
|
constructor(e) {
|
|
146
170
|
this.options = {
|
|
147
171
|
...w,
|
|
@@ -160,8 +184,8 @@ var C = class {
|
|
|
160
184
|
setTarget(t) {
|
|
161
185
|
this.options.clamp && (t = e(t, 0, 1));
|
|
162
186
|
let n = Math.abs(t - this.targetValue);
|
|
163
|
-
n > 0 && n >= this.options.targetEpsilon && (this.targetValue = t,
|
|
164
|
-
this.isSettled = !1, this._onFrame && this
|
|
187
|
+
n > 0 && n >= this.options.targetEpsilon && (this.targetValue = t, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
188
|
+
this.isSettled = !1, this._onFrame && x(this);
|
|
165
189
|
}));
|
|
166
190
|
}
|
|
167
191
|
_snapSettled() {
|
|
@@ -180,19 +204,13 @@ var C = class {
|
|
|
180
204
|
this.targetValue = t, this.currentValue = t, this.isSettled = !0, this._playback.stop();
|
|
181
205
|
}
|
|
182
206
|
play(e) {
|
|
183
|
-
|
|
184
|
-
if (this.isSettled) {
|
|
185
|
-
e?.(this.currentValue);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
this._startLoop();
|
|
189
|
-
});
|
|
207
|
+
S(this, e);
|
|
190
208
|
}
|
|
191
209
|
stop() {
|
|
192
|
-
this
|
|
210
|
+
C(this);
|
|
193
211
|
}
|
|
194
212
|
_startLoop() {
|
|
195
|
-
|
|
213
|
+
x(this);
|
|
196
214
|
}
|
|
197
215
|
}, E = {
|
|
198
216
|
response: .5,
|
|
@@ -204,8 +222,19 @@ var C = class {
|
|
|
204
222
|
respectReducedMotion: !1
|
|
205
223
|
};
|
|
206
224
|
//#endregion
|
|
207
|
-
//#region src/animation/physics/spring/
|
|
208
|
-
function D(
|
|
225
|
+
//#region src/animation/physics/spring/managed-play.ts
|
|
226
|
+
function D(e) {
|
|
227
|
+
x(e);
|
|
228
|
+
}
|
|
229
|
+
function O(e, t) {
|
|
230
|
+
S(e, t);
|
|
231
|
+
}
|
|
232
|
+
function k(e) {
|
|
233
|
+
C(e);
|
|
234
|
+
}
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/animation/physics/spring/solver/duration.ts
|
|
237
|
+
function re(t) {
|
|
209
238
|
let { visualDuration: n, duration: r, bounce: i = 0, ...a } = t, o = n ?? r ?? .5, s = 1 - e(i, -1, 1);
|
|
210
239
|
return {
|
|
211
240
|
...a,
|
|
@@ -214,8 +243,57 @@ function D(t) {
|
|
|
214
243
|
};
|
|
215
244
|
}
|
|
216
245
|
//#endregion
|
|
217
|
-
//#region src/animation/physics/spring/
|
|
218
|
-
|
|
246
|
+
//#region src/animation/physics/spring/solver/solver.ts
|
|
247
|
+
function A(e, t, n, r) {
|
|
248
|
+
if (t < 1) return {
|
|
249
|
+
regime: "under",
|
|
250
|
+
w: e,
|
|
251
|
+
z: t,
|
|
252
|
+
wd: n,
|
|
253
|
+
decay: Math.exp(-t * e * r),
|
|
254
|
+
cos: Math.cos(n * r),
|
|
255
|
+
sin: Math.sin(n * r)
|
|
256
|
+
};
|
|
257
|
+
if (t === 1) return {
|
|
258
|
+
regime: "critical",
|
|
259
|
+
w: e,
|
|
260
|
+
decay: Math.exp(-e * r),
|
|
261
|
+
t: r
|
|
262
|
+
};
|
|
263
|
+
let i = e * Math.sqrt(t * t - 1), a = -t * e + i, o = -t * e - i;
|
|
264
|
+
return {
|
|
265
|
+
regime: "over",
|
|
266
|
+
r1: a,
|
|
267
|
+
r2: o,
|
|
268
|
+
e1: Math.exp(a * r),
|
|
269
|
+
e2: Math.exp(o * r)
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function j(e, t, n, r = {
|
|
273
|
+
x: 0,
|
|
274
|
+
v: 0
|
|
275
|
+
}) {
|
|
276
|
+
if (n.regime === "under") {
|
|
277
|
+
let { w: i, z: a, wd: o, decay: s, cos: c, sin: l } = n, u = e, d = (t + a * i * e) / o;
|
|
278
|
+
return r.x = s * (u * c + d * l), r.v = s * ((d * o - u * a * i) * c - (u * o + d * a * i) * l), r;
|
|
279
|
+
}
|
|
280
|
+
if (n.regime === "critical") {
|
|
281
|
+
let { w: i, decay: a, t: o } = n, s = e, c = t + i * e;
|
|
282
|
+
return r.x = a * (s + c * o), r.v = a * (c - i * (s + c * o)), r;
|
|
283
|
+
}
|
|
284
|
+
let { r1: i, r2: a, e1: o, e2: s } = n, c = (t - a * e) / (i - a), l = e - c;
|
|
285
|
+
return r.x = c * o + l * s, r.v = c * i * o + l * a * s, r;
|
|
286
|
+
}
|
|
287
|
+
function ie(e, t, n, r, i, a) {
|
|
288
|
+
return j(e, t, A(n, r, i, a));
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/animation/physics/spring/solver/vector.ts
|
|
292
|
+
var M = new Float64Array(), N = class {
|
|
293
|
+
solution = {
|
|
294
|
+
x: 0,
|
|
295
|
+
v: 0
|
|
296
|
+
};
|
|
219
297
|
vecOrigin = null;
|
|
220
298
|
vecOriginVel = null;
|
|
221
299
|
vecTarget = null;
|
|
@@ -229,10 +307,10 @@ var O = new Float64Array(), k = class {
|
|
|
229
307
|
this.vecOrigin.set(this.vecCurrent), this.vecOriginVel.set(this.vecVelocity), this.vecTarget.set(e), this.vecElapsed = 0;
|
|
230
308
|
}
|
|
231
309
|
get values() {
|
|
232
|
-
return this.vecCurrent ??
|
|
310
|
+
return this.vecCurrent ?? M;
|
|
233
311
|
}
|
|
234
312
|
get velocities() {
|
|
235
|
-
return this.vecVelocity ??
|
|
313
|
+
return this.vecVelocity ?? M;
|
|
236
314
|
}
|
|
237
315
|
get armed() {
|
|
238
316
|
return this.vecTarget !== null;
|
|
@@ -240,56 +318,36 @@ var O = new Float64Array(), k = class {
|
|
|
240
318
|
tick(e, t, n, r) {
|
|
241
319
|
if (this.vecTarget === null || e <= 0) return this.values;
|
|
242
320
|
this.vecElapsed += e / 1e3;
|
|
243
|
-
let i = this.vecElapsed, a =
|
|
244
|
-
|
|
245
|
-
let
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
for (let e = 0; e < d.length; e++) {
|
|
249
|
-
let t = c[e] - u[e], n = l[e], r, x;
|
|
250
|
-
if (o < 1) {
|
|
251
|
-
let e = t, i = (n + o * a * t) / s;
|
|
252
|
-
r = p * (e * m + i * h), x = p * ((i * s - e * o * a) * m - (e * s + i * o * a) * h);
|
|
253
|
-
} else if (o === 1) {
|
|
254
|
-
let e = t, o = n + a * t;
|
|
255
|
-
r = g * (e + o * i), x = g * (o - a * (e + o * i));
|
|
256
|
-
} else {
|
|
257
|
-
let e = (n - v * t) / (_ - v), i = t - e;
|
|
258
|
-
r = e * y + i * b, x = e * _ * y + i * v * b;
|
|
259
|
-
}
|
|
260
|
-
d[e] = u[e] + r, f[e] = x;
|
|
321
|
+
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;
|
|
322
|
+
for (let e = 0; e < c.length; e++) {
|
|
323
|
+
let t = a[e] - s[e], n = o[e];
|
|
324
|
+
j(t, n, u, d), c[e] = s[e] + d.x, l[e] = d.v;
|
|
261
325
|
}
|
|
262
|
-
return
|
|
326
|
+
return c;
|
|
263
327
|
}
|
|
264
328
|
};
|
|
265
329
|
//#endregion
|
|
266
|
-
//#region src/animation/physics/spring/
|
|
267
|
-
function
|
|
268
|
-
let
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
x: n * (r + i * a),
|
|
280
|
-
v: n * (i - o * (r + i * a))
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
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);
|
|
284
|
-
return {
|
|
285
|
-
x: d * p + f * m,
|
|
286
|
-
v: d * l * p + f * u * m
|
|
287
|
-
};
|
|
330
|
+
//#region src/animation/physics/spring/vector-surface.ts
|
|
331
|
+
function P(e, t) {
|
|
332
|
+
let n = e ?? new N();
|
|
333
|
+
return n.setTargets(t), n;
|
|
334
|
+
}
|
|
335
|
+
function F(e) {
|
|
336
|
+
return e?.values ?? M;
|
|
337
|
+
}
|
|
338
|
+
function I(e) {
|
|
339
|
+
return e?.velocities ?? M;
|
|
340
|
+
}
|
|
341
|
+
function L(e, t, n, r, i) {
|
|
342
|
+
return e === null || t <= 0 ? M : e.tick(t, n, r, i);
|
|
288
343
|
}
|
|
289
344
|
//#endregion
|
|
290
345
|
//#region src/animation/physics/spring/progress.ts
|
|
291
|
-
var
|
|
346
|
+
var R = class e {
|
|
292
347
|
options;
|
|
348
|
+
get respectReducedMotion() {
|
|
349
|
+
return this.options.respectReducedMotion;
|
|
350
|
+
}
|
|
293
351
|
targetValue;
|
|
294
352
|
currentValue;
|
|
295
353
|
currentVelocity;
|
|
@@ -304,16 +362,19 @@ var j = class e {
|
|
|
304
362
|
subscribers = /* @__PURE__ */ new Set();
|
|
305
363
|
disposed = !1;
|
|
306
364
|
vectorLanes = null;
|
|
307
|
-
_playback = new
|
|
365
|
+
_playback = new b();
|
|
308
366
|
_onFrame = void 0;
|
|
367
|
+
_emitManagedFrame() {
|
|
368
|
+
this._onFrame?.(this.value, this.velocity);
|
|
369
|
+
}
|
|
309
370
|
constructor(e) {
|
|
310
371
|
this.options = {
|
|
311
372
|
...E,
|
|
312
373
|
...e
|
|
313
|
-
}, 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 =
|
|
374
|
+
}, 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 = v(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;
|
|
314
375
|
}
|
|
315
376
|
static fromDuration(t) {
|
|
316
|
-
return new e(
|
|
377
|
+
return new e(re(t ?? {}));
|
|
317
378
|
}
|
|
318
379
|
get target() {
|
|
319
380
|
return this.targetValue;
|
|
@@ -331,8 +392,8 @@ var j = class e {
|
|
|
331
392
|
e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
|
|
332
393
|
}
|
|
333
394
|
reseatTarget(e) {
|
|
334
|
-
this.targetValue = e,
|
|
335
|
-
this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale =
|
|
395
|
+
this.targetValue = e, y(this.options.respectReducedMotion, () => this._snapSettled(), () => {
|
|
396
|
+
this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale = v(this.options.respectReducedMotion), this._onFrame && D(this);
|
|
336
397
|
});
|
|
337
398
|
}
|
|
338
399
|
_snapSettled() {
|
|
@@ -348,7 +409,7 @@ var j = class e {
|
|
|
348
409
|
return this.disposed || this.isSettled ? this.currentValue : (this.elapsed = Math.max(0, e), this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
|
|
349
410
|
}
|
|
350
411
|
evaluateAt(e) {
|
|
351
|
-
let t = this.amplitudeScale, n = this.originValue + t * (this.targetValue - this.originValue), r = this.originValue - n, i = this.originVelocity, { x: a, v: o } =
|
|
412
|
+
let t = this.amplitudeScale, n = this.originValue + t * (this.targetValue - this.originValue), r = this.originValue - n, i = this.originVelocity, { x: a, v: o } = ie(r, i, this.omega, this.zeta, this.omegaD, e);
|
|
352
413
|
this.currentValue = n + a, this.currentVelocity = o;
|
|
353
414
|
}
|
|
354
415
|
checkSettled() {
|
|
@@ -360,19 +421,19 @@ var j = class e {
|
|
|
360
421
|
}
|
|
361
422
|
reset(e, t) {
|
|
362
423
|
let n = e ?? 0, r = t ?? 0;
|
|
363
|
-
this.targetValue = n, this.currentValue = n, this.currentVelocity = r, this.originValue = n, this.originVelocity = r, this.elapsed = 0, this.amplitudeScale =
|
|
424
|
+
this.targetValue = n, this.currentValue = n, this.currentVelocity = r, this.originValue = n, this.originVelocity = r, this.elapsed = 0, this.amplitudeScale = v(this.options.respectReducedMotion), this.isSettled = r === 0, this.emit(), this._playback.stop();
|
|
364
425
|
}
|
|
365
426
|
setTargets(e) {
|
|
366
|
-
|
|
427
|
+
this.vectorLanes = P(this.vectorLanes, e);
|
|
367
428
|
}
|
|
368
429
|
get values() {
|
|
369
|
-
return this.vectorLanes
|
|
430
|
+
return F(this.vectorLanes);
|
|
370
431
|
}
|
|
371
432
|
get velocities() {
|
|
372
|
-
return this.vectorLanes
|
|
433
|
+
return I(this.vectorLanes);
|
|
373
434
|
}
|
|
374
435
|
tickVector(e) {
|
|
375
|
-
return this.disposed || this.vectorLanes === null || e <= 0 ? this.values : this.vectorLanes
|
|
436
|
+
return this.disposed || this.vectorLanes === null || e <= 0 ? this.values : L(this.vectorLanes, e, this.omega, this.zeta, this.omegaD);
|
|
376
437
|
}
|
|
377
438
|
subscribe(e) {
|
|
378
439
|
return this.subscribers.add(e), () => {
|
|
@@ -386,25 +447,16 @@ var j = class e {
|
|
|
386
447
|
this.disposed = !0, this._playback.stop(), this.subscribers.clear();
|
|
387
448
|
}
|
|
388
449
|
play(e) {
|
|
389
|
-
|
|
390
|
-
if (this.isSettled) {
|
|
391
|
-
e?.(this.currentValue, this.currentVelocity);
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
this._startLoop();
|
|
395
|
-
}));
|
|
450
|
+
O(this, e);
|
|
396
451
|
}
|
|
397
452
|
stop() {
|
|
398
|
-
this
|
|
399
|
-
}
|
|
400
|
-
_startLoop() {
|
|
401
|
-
this._playback.drive(this, () => this._onFrame?.(this.currentValue, this.currentVelocity));
|
|
453
|
+
k(this);
|
|
402
454
|
}
|
|
403
455
|
};
|
|
404
456
|
//#endregion
|
|
405
|
-
//#region src/animation/physics/spring/sample.ts
|
|
406
|
-
function
|
|
407
|
-
let t = new
|
|
457
|
+
//#region src/animation/physics/spring/solver/sample.ts
|
|
458
|
+
function z(e) {
|
|
459
|
+
let t = new R({
|
|
408
460
|
response: e.response,
|
|
409
461
|
dampingFraction: e.dampingFraction,
|
|
410
462
|
initial: 0,
|
|
@@ -417,9 +469,9 @@ function M(e) {
|
|
|
417
469
|
return t.dispose(), n;
|
|
418
470
|
}
|
|
419
471
|
//#endregion
|
|
420
|
-
//#region src/animation/physics/spring/linear-stops.ts
|
|
421
|
-
function
|
|
422
|
-
let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i =
|
|
472
|
+
//#region src/animation/physics/spring/css/linear-stops.ts
|
|
473
|
+
function B(e) {
|
|
474
|
+
let t = e.sampleCount ?? 24, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = z({
|
|
423
475
|
response: e.response,
|
|
424
476
|
dampingFraction: e.dampingFraction,
|
|
425
477
|
sampleCount: t,
|
|
@@ -433,9 +485,9 @@ function N(e) {
|
|
|
433
485
|
return a.push("1"), `linear(${a.join(", ")})`;
|
|
434
486
|
}
|
|
435
487
|
//#endregion
|
|
436
|
-
//#region src/animation/physics/spring/timing-function.ts
|
|
437
|
-
function
|
|
438
|
-
let t = e.sampleCount ?? 64, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i =
|
|
488
|
+
//#region src/animation/physics/spring/css/timing-function.ts
|
|
489
|
+
function V(e) {
|
|
490
|
+
let t = e.sampleCount ?? 64, n = e.settleThreshold ?? .001, r = e.maxDuration ?? e.response * 4, i = z({
|
|
439
491
|
response: e.response,
|
|
440
492
|
dampingFraction: e.dampingFraction,
|
|
441
493
|
sampleCount: t,
|
|
@@ -456,12 +508,12 @@ function P(e) {
|
|
|
456
508
|
};
|
|
457
509
|
return e.settleThreshold !== void 0 && (s.settleThreshold = e.settleThreshold), e.maxDuration !== void 0 && (s.maxDuration = e.maxDuration), {
|
|
458
510
|
fn: o,
|
|
459
|
-
css:
|
|
511
|
+
css: B(s)
|
|
460
512
|
};
|
|
461
513
|
}
|
|
462
514
|
//#endregion
|
|
463
515
|
//#region src/animation/orchestration/timeline/native.ts
|
|
464
|
-
function
|
|
516
|
+
function H(e) {
|
|
465
517
|
if (typeof window > "u") return null;
|
|
466
518
|
if (e.kind === "scroll") {
|
|
467
519
|
if (globalThis.ScrollTimeline === void 0) return null;
|
|
@@ -474,9 +526,9 @@ function F(e) {
|
|
|
474
526
|
}
|
|
475
527
|
//#endregion
|
|
476
528
|
//#region src/animation/physics/decay.ts
|
|
477
|
-
var
|
|
478
|
-
function
|
|
479
|
-
let t = e.initial ?? 0, n = e.velocity, r = e.friction ??
|
|
529
|
+
var U = 5;
|
|
530
|
+
function W(e) {
|
|
531
|
+
let t = e.initial ?? 0, n = e.velocity, r = e.friction ?? U;
|
|
480
532
|
if (r <= 0) throw Error("decay() requires a friction coefficient > 0.");
|
|
481
533
|
let i = t + n / r;
|
|
482
534
|
return (e) => {
|
|
@@ -491,23 +543,23 @@ function L(e) {
|
|
|
491
543
|
};
|
|
492
544
|
};
|
|
493
545
|
}
|
|
494
|
-
function
|
|
495
|
-
let t = e.friction ??
|
|
546
|
+
function G(e) {
|
|
547
|
+
let t = e.friction ?? U;
|
|
496
548
|
if (t <= 0) throw Error("decayRest() requires a friction coefficient > 0.");
|
|
497
549
|
return (e.initial ?? 0) + e.velocity / t;
|
|
498
550
|
}
|
|
499
551
|
//#endregion
|
|
500
552
|
//#region src/animation/orchestration/sequence/transport.ts
|
|
501
|
-
function
|
|
553
|
+
function K(t, n) {
|
|
502
554
|
for (let { animation: r, at: i } of t) {
|
|
503
555
|
let t = e(n - i, 0, r.options.duration);
|
|
504
556
|
r.interpFrames(t, !0);
|
|
505
557
|
}
|
|
506
558
|
}
|
|
507
|
-
function
|
|
559
|
+
function q(e, t, n, r) {
|
|
508
560
|
e.fire(t, n, r);
|
|
509
561
|
}
|
|
510
|
-
function
|
|
562
|
+
function J(e, t, n) {
|
|
511
563
|
if (e === void 0) return t;
|
|
512
564
|
if (typeof e == "number") return e;
|
|
513
565
|
let r = /^([+-])=(\d*\.?\d+)$/.exec(e);
|
|
@@ -516,50 +568,97 @@ function V(e, t, n) {
|
|
|
516
568
|
if (i === void 0) throw Error(`Sequence: unknown position "${e}". Register it with .label("${e}", at) first, or pass a number / "+=n" / "-=n".`);
|
|
517
569
|
return i;
|
|
518
570
|
}
|
|
519
|
-
function
|
|
571
|
+
function ae(t, n, r, i) {
|
|
520
572
|
if (n <= 0) return 0;
|
|
521
573
|
let a = e(t, 0, n * r), o = Math.floor(a / n), s = a - o * n;
|
|
522
574
|
return s === 0 && o > 0 && (--o, s = n), i && o % 2 == 1 ? n - s : s;
|
|
523
575
|
}
|
|
524
|
-
function
|
|
576
|
+
function oe(e, t, n) {
|
|
525
577
|
return n && (t - 1) % 2 == 1 ? 0 : e;
|
|
526
578
|
}
|
|
527
|
-
function
|
|
579
|
+
function se(e, t, n) {
|
|
528
580
|
return e === 1 && t === 1 && !n;
|
|
529
581
|
}
|
|
530
|
-
function
|
|
582
|
+
function Y(e, t, n) {
|
|
531
583
|
return n === 0 ? e : e - t / n;
|
|
532
584
|
}
|
|
533
|
-
function
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
if (e._time = a, W(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);
|
|
540
|
-
if (B(e.events, e.entries, e.labels, a), z(e.entries, a), i) {
|
|
541
|
-
J(e);
|
|
585
|
+
async function ce(e, t) {
|
|
586
|
+
e._playOrigin === void 0 && (e._playOrigin = Y(t, e._time, e._rate)), e._lastClock = t;
|
|
587
|
+
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 ? oe(e.duration, e._repeatCount, e._yoyoOn) : 0 : ae(n, e.duration, e._repeatCount, e._yoyoOn);
|
|
588
|
+
if (e._time = a, se(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);
|
|
589
|
+
if (q(e.events, e.entries, e.labels, a), K(e.entries, a), i) {
|
|
590
|
+
X(e);
|
|
542
591
|
let t = e._resolvePlay;
|
|
543
592
|
return e._resolvePlay = null, t?.(), !1;
|
|
544
593
|
}
|
|
545
594
|
return !0;
|
|
546
595
|
}
|
|
547
|
-
function
|
|
596
|
+
function X(e) {
|
|
548
597
|
for (let { animation: t } of e.entries) t.managed = !1, t.started = !1, t.startTime = void 0;
|
|
549
598
|
e._playOrigin = void 0, e._lastClock = void 0, e._paused = !1;
|
|
550
599
|
}
|
|
551
|
-
function
|
|
600
|
+
function Z(e, t) {
|
|
552
601
|
if (!t) return;
|
|
553
602
|
let n = e._lastClock;
|
|
554
603
|
if (n === void 0) {
|
|
555
604
|
e._playOrigin = void 0;
|
|
556
605
|
return;
|
|
557
606
|
}
|
|
558
|
-
e._playOrigin =
|
|
607
|
+
e._playOrigin = Y(n, e._time, e._rate);
|
|
608
|
+
}
|
|
609
|
+
//#endregion
|
|
610
|
+
//#region src/animation/internal/transport/core.ts
|
|
611
|
+
function Q(e, t) {
|
|
612
|
+
if (e._playingPromise) return e._playingPromise;
|
|
613
|
+
let n = t();
|
|
614
|
+
return e._playingPromise = n, n.finally(() => {
|
|
615
|
+
e._playingPromise === n && (e._playingPromise = null);
|
|
616
|
+
}), n;
|
|
617
|
+
}
|
|
618
|
+
function le(e) {
|
|
619
|
+
return e.started && !e.paused;
|
|
620
|
+
}
|
|
621
|
+
function ue(e, t, n) {
|
|
622
|
+
e.paused ? n() : t();
|
|
623
|
+
}
|
|
624
|
+
//#endregion
|
|
625
|
+
//#region src/animation/orchestration/sequence/lifecycle.ts
|
|
626
|
+
function de(e) {
|
|
627
|
+
if (e._playingPromise) return e._playingPromise;
|
|
628
|
+
if (e.respectReducedMotion && _()) return e.seek(e.duration), Promise.resolve();
|
|
629
|
+
for (let { animation: t, at: n } of e.entries) t.startTime = n, t.started = !0, t.managed = !0;
|
|
630
|
+
return e._time = 0, e._paused = !1, e._playOrigin = void 0, e._lastClock = void 0, Q(e, () => new Promise((t) => {
|
|
631
|
+
e._resolvePlay = t, e.playback.loop(e._boundFrame);
|
|
632
|
+
}));
|
|
633
|
+
}
|
|
634
|
+
function fe(e) {
|
|
635
|
+
e.playback.stop(), X(e);
|
|
636
|
+
let t = e._resolvePlay;
|
|
637
|
+
e._resolvePlay = null, t?.();
|
|
638
|
+
}
|
|
639
|
+
function pe(e) {
|
|
640
|
+
!e._playingPromise || e._paused || (e._paused = !0, e.playback.stop(), e._playOrigin = void 0);
|
|
641
|
+
}
|
|
642
|
+
function $(e) {
|
|
643
|
+
!e._playingPromise || !e._paused || (e._paused = !1, e._playOrigin = void 0, e._lastClock = void 0, e.playback.loop(e._boundFrame));
|
|
644
|
+
}
|
|
645
|
+
function me(e, t) {
|
|
646
|
+
if (!Number.isFinite(t)) throw Error(`Sequence.timeScale(n): n must be a finite number, got ${t}.`);
|
|
647
|
+
e._rate = t, Z(e, e._playingPromise != null);
|
|
648
|
+
}
|
|
649
|
+
function he(e) {
|
|
650
|
+
e._rate = -e._rate, Z(e, e._playingPromise != null);
|
|
651
|
+
}
|
|
652
|
+
function ge(e, t) {
|
|
653
|
+
if (t !== Infinity && (!Number.isInteger(t) || t < 1)) throw Error(`Sequence.repeat(count): count must be a positive integer or Infinity, got ${t}.`);
|
|
654
|
+
e._repeatCount = t;
|
|
655
|
+
}
|
|
656
|
+
function _e(e, t) {
|
|
657
|
+
e._yoyoOn = t;
|
|
559
658
|
}
|
|
560
659
|
//#endregion
|
|
561
660
|
//#region src/animation/orchestration/sequence/events.ts
|
|
562
|
-
var
|
|
661
|
+
var ve = class {
|
|
563
662
|
subscribers = new Map([
|
|
564
663
|
["segment:enter", /* @__PURE__ */ new Set()],
|
|
565
664
|
["segment:leave", /* @__PURE__ */ new Set()],
|
|
@@ -594,18 +693,19 @@ var X = class {
|
|
|
594
693
|
}
|
|
595
694
|
this._prevPhase = n;
|
|
596
695
|
}
|
|
597
|
-
},
|
|
696
|
+
}, ye = class {
|
|
598
697
|
entries = [];
|
|
599
698
|
labels = /* @__PURE__ */ new Map();
|
|
600
|
-
events = new
|
|
699
|
+
events = new ve();
|
|
601
700
|
cursor = 0;
|
|
602
701
|
_time = 0;
|
|
603
702
|
respectReducedMotion;
|
|
604
|
-
playback = new
|
|
703
|
+
playback = new b();
|
|
605
704
|
_boundFrame;
|
|
606
705
|
_resolvePlay = null;
|
|
607
706
|
_playOrigin = void 0;
|
|
608
707
|
_playingPromise = null;
|
|
708
|
+
_duration = 0;
|
|
609
709
|
_rate = 1;
|
|
610
710
|
_repeatCount = 1;
|
|
611
711
|
_yoyoOn = !1;
|
|
@@ -615,12 +715,7 @@ var X = class {
|
|
|
615
715
|
this.respectReducedMotion = e?.respectReducedMotion ?? !1, this._boundFrame = this._frame.bind(this);
|
|
616
716
|
}
|
|
617
717
|
get duration() {
|
|
618
|
-
|
|
619
|
-
for (let t of this.entries) {
|
|
620
|
-
let n = t.at + t.animation.options.duration;
|
|
621
|
-
n > e && (e = n);
|
|
622
|
-
}
|
|
623
|
-
return e;
|
|
718
|
+
return this._duration;
|
|
624
719
|
}
|
|
625
720
|
get time() {
|
|
626
721
|
return this._time;
|
|
@@ -635,20 +730,20 @@ var X = class {
|
|
|
635
730
|
return this._rate;
|
|
636
731
|
}
|
|
637
732
|
label(e, t) {
|
|
638
|
-
return this.labels.set(e,
|
|
733
|
+
return this.labels.set(e, J(t, this.cursor, this.labels)), this;
|
|
639
734
|
}
|
|
640
735
|
on(e, t) {
|
|
641
736
|
return this.events.subscribe(e, t);
|
|
642
737
|
}
|
|
643
738
|
add(e, t) {
|
|
644
|
-
let n =
|
|
739
|
+
let n = J(t, this.cursor, this.labels);
|
|
645
740
|
return this.entries.push({
|
|
646
741
|
animation: e,
|
|
647
742
|
at: n
|
|
648
|
-
}), this.entries.sort((e, t) => e.at - t.at), this.cursor = n + e.options.duration, this;
|
|
743
|
+
}), this.entries.sort((e, t) => e.at - t.at), this.cursor = n + e.options.duration, this._duration = Math.max(this._duration, this.cursor), this;
|
|
649
744
|
}
|
|
650
745
|
seek(e) {
|
|
651
|
-
return this._time = e,
|
|
746
|
+
return this._time = e, q(this.events, this.entries, this.labels, e), K(this.entries, e), this;
|
|
652
747
|
}
|
|
653
748
|
setTargets(...e) {
|
|
654
749
|
for (let { animation: t } of this.entries) t.setTargets(...e);
|
|
@@ -658,51 +753,32 @@ var X = class {
|
|
|
658
753
|
return this._playingPromise ?? Promise.resolve();
|
|
659
754
|
}
|
|
660
755
|
play() {
|
|
661
|
-
|
|
662
|
-
if (this.respectReducedMotion && K()) return this.seek(this.duration), Promise.resolve();
|
|
663
|
-
for (let { animation: e, at: t } of this.entries) e.startTime = t, e.started = !0, e.managed = !0;
|
|
664
|
-
this._time = 0, this._paused = !1, this._playOrigin = void 0, this._lastClock = void 0;
|
|
665
|
-
let e = new Promise((e) => {
|
|
666
|
-
this._resolvePlay = e, this.playback.loop(this._boundFrame);
|
|
667
|
-
});
|
|
668
|
-
return this._playingPromise = e, e.finally(() => {
|
|
669
|
-
this._playingPromise = null;
|
|
670
|
-
}), e;
|
|
756
|
+
return de(this);
|
|
671
757
|
}
|
|
672
758
|
async _frame(e) {
|
|
673
|
-
return
|
|
674
|
-
}
|
|
675
|
-
_reanchor() {
|
|
676
|
-
Y(this, this._playingPromise != null);
|
|
677
|
-
}
|
|
678
|
-
_settle() {
|
|
679
|
-
J(this);
|
|
759
|
+
return ce(this, e);
|
|
680
760
|
}
|
|
681
761
|
stop() {
|
|
682
|
-
this
|
|
683
|
-
let e = this._resolvePlay;
|
|
684
|
-
return this._resolvePlay = null, e?.(), this;
|
|
762
|
+
return fe(this), this;
|
|
685
763
|
}
|
|
686
764
|
pause() {
|
|
687
|
-
return
|
|
765
|
+
return pe(this), this;
|
|
688
766
|
}
|
|
689
767
|
resume() {
|
|
690
|
-
return
|
|
768
|
+
return $(this), this;
|
|
691
769
|
}
|
|
692
770
|
timeScale(e) {
|
|
693
|
-
|
|
694
|
-
return this._rate = e, this._reanchor(), this;
|
|
771
|
+
return me(this, e), this;
|
|
695
772
|
}
|
|
696
773
|
reverse() {
|
|
697
|
-
return this
|
|
774
|
+
return he(this), this;
|
|
698
775
|
}
|
|
699
776
|
repeat(e) {
|
|
700
|
-
|
|
701
|
-
return this._repeatCount = e, this;
|
|
777
|
+
return ge(this, e), this;
|
|
702
778
|
}
|
|
703
779
|
yoyo(e = !0) {
|
|
704
|
-
return this
|
|
780
|
+
return _e(this, e), this;
|
|
705
781
|
}
|
|
706
782
|
};
|
|
707
783
|
//#endregion
|
|
708
|
-
export {
|
|
784
|
+
export { a as C, i as S, n as _, W as a, d as b, V as c, T as d, b as f, t as g, e as h, ue as i, B as l, y as m, Q as n, G as o, v as p, le as r, H as s, ye as t, R as u, ee as v, o as w, s as x, u as y };
|