@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
package/dist/keyframes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as e, C as t, D as n, E as r, M as i, N as a, O as o, S as s, T as c, _ as l, a as u, b as d, c as f, d as p, f as m, g as h, h as g, j as _, l as v, m as y, o as b, p as x, s as S, t as C, u as w, v as ee, x as T, y as E } from "./sequence-BzJ-b_HG.js";
|
|
2
2
|
//#region src/animation/physics/numeric.ts
|
|
3
|
-
var
|
|
3
|
+
var D = class {
|
|
4
4
|
_out = new Float64Array();
|
|
5
5
|
keyframes;
|
|
6
6
|
segments;
|
|
@@ -9,15 +9,15 @@ var S = class {
|
|
|
9
9
|
_duration;
|
|
10
10
|
_respectReducedMotion;
|
|
11
11
|
_easingFn;
|
|
12
|
-
_playback = new
|
|
13
|
-
constructor(e,
|
|
12
|
+
_playback = new T();
|
|
13
|
+
constructor(e, t) {
|
|
14
14
|
if (e.length < 2) throw Error("NumericAnimation requires at least 2 keyframes.");
|
|
15
|
-
this.keyframes = e.map((e) => ({ ...e })), this._duration =
|
|
16
|
-
let
|
|
17
|
-
if (typeof
|
|
18
|
-
if (this._easingFn =
|
|
19
|
-
if (
|
|
20
|
-
this.positions =
|
|
15
|
+
this.keyframes = e.map((e) => ({ ...e })), this._duration = t?.duration ?? 0, this._respectReducedMotion = t?.respectReducedMotion ?? !1;
|
|
16
|
+
let n = t?.timingFunction;
|
|
17
|
+
if (typeof n == "string") throw new i("timingFunction", n, "NumericAnimation accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
|
|
18
|
+
if (this._easingFn = n == null ? (e) => e : _(n).fn, t?.positions) {
|
|
19
|
+
if (t.positions.length !== e.length) throw Error("positions length must match keyframes length.");
|
|
20
|
+
this.positions = t.positions;
|
|
21
21
|
} else this.positions = e.map((t, n) => n / (e.length - 1) * 100);
|
|
22
22
|
this.result = { ...e[0] }, this.segments = this.buildSegments();
|
|
23
23
|
}
|
|
@@ -42,12 +42,12 @@ var S = class {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
at(e) {
|
|
45
|
-
let t =
|
|
46
|
-
|
|
47
|
-
let
|
|
48
|
-
this._out.length <
|
|
49
|
-
let
|
|
50
|
-
for (let e = 0; e <
|
|
45
|
+
let t = c(e, 0, 1) * 100, i = o(this.segments, t, (e) => e.startPos, (e) => e.stopPos);
|
|
46
|
+
i === -1 && (i = this.segments.length - 1);
|
|
47
|
+
let a = this.segments[i], s = n(c(t, a.startPos, a.stopPos), a.startPos, a.stopPos, 0, 1), l = a.timingFunction(s), u = a.keys.length;
|
|
48
|
+
this._out.length < u && (this._out = new Float64Array(u)), r(a.from, a.to, l, this._out);
|
|
49
|
+
let d = this.result;
|
|
50
|
+
for (let e = 0; e < u; e++) d[a.keys[e]] = this._out[e];
|
|
51
51
|
return this.result;
|
|
52
52
|
}
|
|
53
53
|
updateKeyframe(e, t) {
|
|
@@ -67,12 +67,12 @@ var S = class {
|
|
|
67
67
|
};
|
|
68
68
|
//#endregion
|
|
69
69
|
//#region src/animation/physics/spring/solver/reseat.ts
|
|
70
|
-
function
|
|
70
|
+
function O(e) {
|
|
71
71
|
let t = e.curr.time - e.prev.time;
|
|
72
72
|
return t <= 0 ? 0 : (e.curr.value - e.prev.value) / (t / 1e3);
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
let r =
|
|
74
|
+
function k(e, t, n) {
|
|
75
|
+
let r = O(e), i = new h({
|
|
76
76
|
...n,
|
|
77
77
|
initial: e.curr.value,
|
|
78
78
|
initialVelocity: r
|
|
@@ -80,8 +80,92 @@ function ee(e, t, n) {
|
|
|
80
80
|
return i.target = t, i;
|
|
81
81
|
}
|
|
82
82
|
//#endregion
|
|
83
|
+
//#region src/animation/physics/spring/css/keyframes.ts
|
|
84
|
+
var A = 16, te = 10, ne = 2 ** -30, j = 1e4;
|
|
85
|
+
function M(e) {
|
|
86
|
+
let t = e.response ?? E.response, n = e.dampingFraction ?? E.dampingFraction, r = e.initial ?? E.initial, i = e.initialVelocity ?? E.initialVelocity, a = e.settleThreshold ?? E.settleThreshold, o = e.velocitySettleThreshold ?? E.velocitySettleThreshold, { target: s, tolerance: c } = e, u = (e, t) => {
|
|
87
|
+
throw RangeError(`springKeyframes: ${e}; got ${t}.`);
|
|
88
|
+
};
|
|
89
|
+
(!(t > 0) || !Number.isFinite(t)) && u("response must be finite and > 0", t), (!(n >= 0) || !Number.isFinite(n)) && u("dampingFraction must be finite and >= 0", n), (!(c > 0) || !Number.isFinite(c)) && u("tolerance must be finite and > 0", c), (!(a > 0) || !Number.isFinite(a)) && u("settleThreshold must be finite and > 0", a), o > 0 || u("velocitySettleThreshold must be > 0 (Infinity allowed)", o), Number.isFinite(r) || u("initial must be finite", r), Number.isFinite(s) || u("target must be finite", s), Number.isFinite(i) || u("initialVelocity must be finite", i);
|
|
90
|
+
let d = r - s, f = 2 * Math.PI / t, p = n < 1 ? f * Math.sqrt(1 - n * n) : 0, m = {
|
|
91
|
+
x: 0,
|
|
92
|
+
v: 0
|
|
93
|
+
}, h = (e) => ee(d, i, l(f, n, p, e), m), g = (e) => s + h(e).x, _ = y(d, i, t, n, Math.min(a, c / 2), o);
|
|
94
|
+
if (_ === Infinity) throw RangeError(n === 0 ? "springKeyframes: an undamped spring never settles." : "springKeyframes: this spring never settles in floating-point arithmetic (damped so hard its slow root rounds to 0).");
|
|
95
|
+
let v = (e) => {
|
|
96
|
+
if (Number.isNaN(e) && u("at(t) needs a number", e), e <= 0) return {
|
|
97
|
+
value: r,
|
|
98
|
+
velocity: i
|
|
99
|
+
};
|
|
100
|
+
if (e >= _) return {
|
|
101
|
+
value: s,
|
|
102
|
+
velocity: 0
|
|
103
|
+
};
|
|
104
|
+
let t = h(e);
|
|
105
|
+
return {
|
|
106
|
+
value: s + t.x,
|
|
107
|
+
velocity: t.v
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
if (_ === 0) return {
|
|
111
|
+
offsets: [0, 1],
|
|
112
|
+
values: [r, s],
|
|
113
|
+
duration: _,
|
|
114
|
+
at: v
|
|
115
|
+
};
|
|
116
|
+
let b = x(d, i, f, n, p), S = (e, t) => {
|
|
117
|
+
let [r, i] = b.supBound(e, t);
|
|
118
|
+
return f * f * r + 2 * n * f * i;
|
|
119
|
+
}, C = (e, t, n, r) => {
|
|
120
|
+
let i = (n - e) / A, a = 0;
|
|
121
|
+
for (let o = 0; o <= A; o++) {
|
|
122
|
+
let s = o === A ? n : e + o * i, c = t + (r - t) * o / A;
|
|
123
|
+
a = Math.max(a, Math.abs(g(s) - c));
|
|
124
|
+
}
|
|
125
|
+
return a + i * i / 8 * S(e, n - e) <= c;
|
|
126
|
+
}, w = [0], T = [r], D = _ * ne, O = 0, k = r, M = _ / 16;
|
|
127
|
+
for (;;) {
|
|
128
|
+
let e = _ - O, t = (t) => t >= e ? C(O, k, _, s) : C(O, k, O + t, g(O + t)), n, r, i = Math.min(M, e);
|
|
129
|
+
if (t(i)) {
|
|
130
|
+
for (n = i, r = e; n < e;) {
|
|
131
|
+
if (i = Math.min(2 * n, e), !t(i)) {
|
|
132
|
+
r = i;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
n = i;
|
|
136
|
+
}
|
|
137
|
+
if (n >= e) {
|
|
138
|
+
w.push(_), T.push(s);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
for (;;) {
|
|
143
|
+
if (r = i, i /= 2, i < D) throw RangeError(`springKeyframes: tolerance ${c} is below what floating point resolves for this spring.`);
|
|
144
|
+
if (t(i)) break;
|
|
145
|
+
}
|
|
146
|
+
n = i;
|
|
147
|
+
}
|
|
148
|
+
for (let e = 0; e < te; e++) {
|
|
149
|
+
let e = (n + r) / 2;
|
|
150
|
+
t(e) ? n = e : r = e;
|
|
151
|
+
}
|
|
152
|
+
if (!(O + n < _)) {
|
|
153
|
+
w.push(_), T.push(s);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
if (O += n, k = g(O), w.push(O), T.push(k), M = n, w.length > j) throw RangeError(`springKeyframes: tolerance ${c} needs more than ${j} keyframes for this spring; loosen it.`);
|
|
157
|
+
}
|
|
158
|
+
let N = w.map((e) => e / _);
|
|
159
|
+
return N[N.length - 1] = 1, {
|
|
160
|
+
offsets: N,
|
|
161
|
+
values: T,
|
|
162
|
+
duration: _,
|
|
163
|
+
at: v
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
83
167
|
//#region src/animation/physics/morph.ts
|
|
84
|
-
var
|
|
168
|
+
var N = (e) => {
|
|
85
169
|
if (e instanceof HTMLElement) {
|
|
86
170
|
let t = e.getBoundingClientRect();
|
|
87
171
|
return {
|
|
@@ -92,7 +176,7 @@ var w = (e) => {
|
|
|
92
176
|
};
|
|
93
177
|
}
|
|
94
178
|
return e;
|
|
95
|
-
},
|
|
179
|
+
}, P = class {
|
|
96
180
|
animation;
|
|
97
181
|
transformOrigin;
|
|
98
182
|
timingFunction;
|
|
@@ -101,8 +185,8 @@ var w = (e) => {
|
|
|
101
185
|
this.transformOrigin = n?.transformOrigin ?? "top left", this.timingFunction = n?.timingFunction, this.duration = n?.duration ?? 0, this.measure(e, t);
|
|
102
186
|
}
|
|
103
187
|
measure(e, t) {
|
|
104
|
-
let n =
|
|
105
|
-
return this.animation = new
|
|
188
|
+
let n = N(e), r = N(t), i = r.x - n.x, a = r.y - n.y, o = n.width === 0 ? 1 : r.width / n.width, s = n.height === 0 ? 1 : r.height / n.height;
|
|
189
|
+
return this.animation = new D([{
|
|
106
190
|
translateX: 0,
|
|
107
191
|
translateY: 0,
|
|
108
192
|
scaleX: 1,
|
|
@@ -136,19 +220,19 @@ var w = (e) => {
|
|
|
136
220
|
stop() {
|
|
137
221
|
this.animation.stop();
|
|
138
222
|
}
|
|
139
|
-
},
|
|
223
|
+
}, F = class {
|
|
140
224
|
smoother;
|
|
141
225
|
_easingFn;
|
|
142
226
|
currentProgress = 0;
|
|
143
227
|
boundaryEpsilon;
|
|
144
228
|
constructor(e) {
|
|
145
229
|
this.boundaryEpsilon = e?.boundaryEpsilon ?? .005;
|
|
146
|
-
let
|
|
147
|
-
if (typeof
|
|
148
|
-
this._easingFn =
|
|
230
|
+
let t = e?.easing;
|
|
231
|
+
if (typeof t == "string") throw new i("easing", t, "Timeline accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
|
|
232
|
+
this._easingFn = t == null ? (e) => e : _(t).fn, e?.smoothing === !1 ? this.smoother = null : this.smoother = new d(e?.smoothing);
|
|
149
233
|
}
|
|
150
234
|
applyPipeline() {
|
|
151
|
-
let e =
|
|
235
|
+
let e = c(this.sample(), 0, 1);
|
|
152
236
|
e = this._easingFn(e);
|
|
153
237
|
let t = this.boundaryEpsilon;
|
|
154
238
|
return e <= t ? e = 0 : e >= 1 - t && (e = 1), e;
|
|
@@ -176,7 +260,7 @@ var w = (e) => {
|
|
|
176
260
|
let t = e ?? 0;
|
|
177
261
|
this.smoother && this.smoother.reset(t), this.currentProgress = t;
|
|
178
262
|
}
|
|
179
|
-
},
|
|
263
|
+
}, re = class extends F {
|
|
180
264
|
threshold;
|
|
181
265
|
getScrollY;
|
|
182
266
|
getViewportHeight;
|
|
@@ -187,7 +271,7 @@ var w = (e) => {
|
|
|
187
271
|
let e = this.getViewportHeight() * this.threshold;
|
|
188
272
|
return e <= 0 ? 0 : this.getScrollY() / e;
|
|
189
273
|
}
|
|
190
|
-
},
|
|
274
|
+
}, ie = class extends F {
|
|
191
275
|
value = 0;
|
|
192
276
|
constructor(e) {
|
|
193
277
|
super({
|
|
@@ -201,17 +285,17 @@ var w = (e) => {
|
|
|
201
285
|
sample() {
|
|
202
286
|
return this.value;
|
|
203
287
|
}
|
|
204
|
-
},
|
|
205
|
-
function
|
|
288
|
+
}, ae = 2 * Math.PI;
|
|
289
|
+
function I(e, t) {
|
|
206
290
|
let n = e - Math.floor(e);
|
|
207
291
|
switch (t) {
|
|
208
|
-
case "sine": return Math.sin(
|
|
292
|
+
case "sine": return Math.sin(ae * n);
|
|
209
293
|
case "triangle": return n < .5 ? 4 * n - 1 : 3 - 4 * n;
|
|
210
294
|
case "square": return n < .5 ? 1 : -1;
|
|
211
295
|
case "sawtooth": return 2 * n - 1;
|
|
212
296
|
}
|
|
213
297
|
}
|
|
214
|
-
var
|
|
298
|
+
var oe = class {
|
|
215
299
|
frequency;
|
|
216
300
|
waveform;
|
|
217
301
|
phase = 0;
|
|
@@ -223,43 +307,43 @@ var A = class {
|
|
|
223
307
|
return this.phase = t - Math.floor(t), this.phase;
|
|
224
308
|
}
|
|
225
309
|
get value() {
|
|
226
|
-
return
|
|
310
|
+
return I(this.phase, this.waveform);
|
|
227
311
|
}
|
|
228
312
|
sample(e) {
|
|
229
|
-
return
|
|
313
|
+
return I(e * this.frequency, this.waveform);
|
|
230
314
|
}
|
|
231
315
|
reset(e = 0) {
|
|
232
316
|
this.phase = e - Math.floor(e);
|
|
233
317
|
}
|
|
234
|
-
},
|
|
235
|
-
if (typeof e == "number") return
|
|
318
|
+
}, se = (e, t) => {
|
|
319
|
+
if (typeof e == "number") return c(e, 0, Math.max(0, t - 1));
|
|
236
320
|
switch (e) {
|
|
237
321
|
case "first": return 0;
|
|
238
322
|
case "last": return t - 1;
|
|
239
323
|
case "center": return (t - 1) / 2;
|
|
240
324
|
case "edges": return -1;
|
|
241
325
|
}
|
|
242
|
-
},
|
|
326
|
+
}, ce = (e, t, n) => n === "edges" ? Math.min(e, t - 1 - e) : Math.abs(e - se(n, t)), le = (e, t) => {
|
|
243
327
|
if (e <= 1) return 0;
|
|
244
328
|
if (t === "edges") return Math.floor((e - 1) / 2);
|
|
245
|
-
let n =
|
|
329
|
+
let n = se(t, e);
|
|
246
330
|
return Math.max(n, e - 1 - n);
|
|
247
331
|
};
|
|
248
|
-
function
|
|
249
|
-
let { each:
|
|
250
|
-
if (typeof
|
|
251
|
-
let
|
|
332
|
+
function L(e, t = {}) {
|
|
333
|
+
let { each: n = 100, from: r = "first", ease: a } = t;
|
|
334
|
+
if (typeof a == "string") throw new i("ease", a, "stagger accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
|
|
335
|
+
let o = a ? _(a).fn : void 0, s = typeof e == "number" ? e : e.length, c = (e, t) => {
|
|
252
336
|
if (t <= 1) return 0;
|
|
253
|
-
let
|
|
254
|
-
if (
|
|
255
|
-
let
|
|
256
|
-
return
|
|
257
|
-
},
|
|
258
|
-
return
|
|
337
|
+
let i = le(t, r);
|
|
338
|
+
if (i === 0) return 0;
|
|
339
|
+
let a = ce(e, t, r);
|
|
340
|
+
return o ? o(a / i) * n * i : a * n;
|
|
341
|
+
}, l = ((e, t = s) => c(e, t));
|
|
342
|
+
return l.delays = (e = s) => Array.from({ length: e }, (t, n) => c(n, e)), l;
|
|
259
343
|
}
|
|
260
344
|
//#endregion
|
|
261
345
|
//#region src/animation/orchestration/flip.ts
|
|
262
|
-
var
|
|
346
|
+
var ue = 300, de = "translate(0px, 0px) scale(1, 1)", R = (e) => {
|
|
263
347
|
let t = e.getBoundingClientRect();
|
|
264
348
|
return {
|
|
265
349
|
x: t.x,
|
|
@@ -267,56 +351,56 @@ var ie = 300, ae = "translate(0px, 0px) scale(1, 1)", N = (e) => {
|
|
|
267
351
|
width: t.width,
|
|
268
352
|
height: t.height
|
|
269
353
|
};
|
|
270
|
-
},
|
|
271
|
-
let t =
|
|
272
|
-
return t === void 0 ? !1 : (t(), e.style.transform =
|
|
273
|
-
},
|
|
354
|
+
}, z = /* @__PURE__ */ new WeakMap(), B = (e) => {
|
|
355
|
+
let t = z.get(e);
|
|
356
|
+
return t === void 0 ? !1 : (t(), e.style.transform = de, !0);
|
|
357
|
+
}, V = (e, t, n, r) => {
|
|
274
358
|
let { translateX: i, translateY: a, scaleX: o, scaleY: s } = e.at(r);
|
|
275
359
|
return `translate(${t.x + i - n.x}px, ${t.y + a - n.y}px) scale(${n.width === 0 ? 1 : t.width * o / n.width}, ${n.height === 0 ? 1 : t.height * s / n.height})`;
|
|
276
|
-
},
|
|
277
|
-
let { duration: a =
|
|
360
|
+
}, H = (e, t, n, r, i) => {
|
|
361
|
+
let { duration: a = ue, timingFunction: o, transformOrigin: s = "top left" } = i, c = new P(t, r, {
|
|
278
362
|
...o === void 0 ? {} : { timingFunction: o },
|
|
279
363
|
transformOrigin: s
|
|
280
364
|
});
|
|
281
|
-
if (e.style.transformOrigin = s, e.style.transform =
|
|
282
|
-
let l = new
|
|
283
|
-
l.stop(),
|
|
365
|
+
if (e.style.transformOrigin = s, e.style.transform = V(c, t, n, 0), a <= 0) return e.style.transform = V(c, t, n, 1), Object.assign(Promise.resolve(), { cancel: () => {} });
|
|
366
|
+
let l = new T(), u = () => {
|
|
367
|
+
l.stop(), z.get(e) === u && z.delete(e);
|
|
284
368
|
};
|
|
285
|
-
|
|
286
|
-
let
|
|
287
|
-
e.style.transform =
|
|
369
|
+
z.set(e, u);
|
|
370
|
+
let d = l.play(a, (r) => {
|
|
371
|
+
e.style.transform = V(c, t, n, r);
|
|
288
372
|
}).then(() => {
|
|
289
|
-
|
|
373
|
+
z.get(e) === u && z.delete(e);
|
|
290
374
|
});
|
|
291
|
-
return Object.assign(
|
|
375
|
+
return Object.assign(d, { cancel: u });
|
|
292
376
|
};
|
|
293
|
-
function
|
|
294
|
-
let r =
|
|
295
|
-
|
|
296
|
-
let i =
|
|
297
|
-
return
|
|
377
|
+
function fe(e, t, n = {}) {
|
|
378
|
+
let r = R(e);
|
|
379
|
+
B(e), t();
|
|
380
|
+
let i = R(e);
|
|
381
|
+
return H(e, r, i, i, n);
|
|
298
382
|
}
|
|
299
|
-
function
|
|
300
|
-
let r =
|
|
301
|
-
return
|
|
383
|
+
function U(e, t, n = {}) {
|
|
384
|
+
let r = R(e);
|
|
385
|
+
return H(e, r, B(e) ? R(e) : r, R(t), n);
|
|
302
386
|
}
|
|
303
387
|
//#endregion
|
|
304
388
|
//#region src/animation/orchestration/split-text/refuse.ts
|
|
305
|
-
var
|
|
389
|
+
var pe = {
|
|
306
390
|
unmeasurable: "the container yielded no laid-out client rects (detached, display:none, or zero-area) — a line-split cannot group fragments without a measured line box. Use by:\"word\" (layout-independent), or split after the element is laid out.",
|
|
307
391
|
unstable: "the line measurement could not converge — the container's size depends on its own content flow (a container-query / intrinsic-size feedback loop), so the line grouping oscillates on every reflow. Refused rather than latch a stale line map.",
|
|
308
392
|
empty: "there is no text content to split into lines."
|
|
309
|
-
},
|
|
393
|
+
}, W = class e extends Error {
|
|
310
394
|
name = "SplitTextRefusalError";
|
|
311
395
|
reason;
|
|
312
396
|
constructor(t, n) {
|
|
313
|
-
super(`splitText refused a by:"line" split (${t}): ` + (n ??
|
|
397
|
+
super(`splitText refused a by:"line" split (${t}): ` + (n ?? pe[t])), this.reason = t, Object.setPrototypeOf(this, e.prototype);
|
|
314
398
|
}
|
|
315
|
-
},
|
|
316
|
-
function
|
|
317
|
-
if (
|
|
399
|
+
}, G = (e) => e.length === 0 || /^\s+$/u.test(e), K = typeof Intl < "u" && typeof Intl.Segmenter == "function";
|
|
400
|
+
function q(e, t) {
|
|
401
|
+
if (K) {
|
|
318
402
|
let n = new Intl.Segmenter(t, { granularity: "word" }), r = [], i = "", a = !1;
|
|
319
|
-
for (let { segment: t, isWordLike: o } of n.segment(e))
|
|
403
|
+
for (let { segment: t, isWordLike: o } of n.segment(e)) G(t) ? (i && r.push({
|
|
320
404
|
text: i,
|
|
321
405
|
kind: "unit"
|
|
322
406
|
}), i = "", r.push({
|
|
@@ -333,42 +417,42 @@ function H(e, t) {
|
|
|
333
417
|
}
|
|
334
418
|
return e.split(/(\s+)/u).filter((e) => e.length > 0).map((e) => ({
|
|
335
419
|
text: e,
|
|
336
|
-
kind:
|
|
420
|
+
kind: G(e) ? "space" : "unit"
|
|
337
421
|
}));
|
|
338
422
|
}
|
|
339
|
-
function
|
|
340
|
-
if (
|
|
423
|
+
function me(e, t) {
|
|
424
|
+
if (K) {
|
|
341
425
|
let n = new Intl.Segmenter(t, { granularity: "grapheme" }), r = [];
|
|
342
426
|
for (let { segment: t } of n.segment(e)) r.push({
|
|
343
427
|
text: t,
|
|
344
|
-
kind:
|
|
428
|
+
kind: G(t) ? "space" : "unit"
|
|
345
429
|
});
|
|
346
430
|
return r;
|
|
347
431
|
}
|
|
348
432
|
return Array.from(e).map((e) => ({
|
|
349
433
|
text: e,
|
|
350
|
-
kind:
|
|
434
|
+
kind: G(e) ? "space" : "unit"
|
|
351
435
|
}));
|
|
352
436
|
}
|
|
353
437
|
//#endregion
|
|
354
438
|
//#region src/animation/orchestration/split-text/split-text.ts
|
|
355
|
-
var
|
|
439
|
+
var he = (e) => Math.round(e), J = (e) => e.some((e) => {
|
|
356
440
|
let t = e.getBoundingClientRect();
|
|
357
441
|
return t.width > 0 || t.height > 0;
|
|
358
|
-
}),
|
|
359
|
-
function
|
|
442
|
+
}), ge = new Set(/* @__PURE__ */ "article.aside.blockquote.button.details.dialog.fieldset.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.img.input.li.main.menu.meter.nav.ol.optgroup.option.output.progress.search.section.select.summary.table.td.textarea.th.tr.ul".split("."));
|
|
443
|
+
function _e(e) {
|
|
360
444
|
if (e.hasAttribute("role")) return !0;
|
|
361
445
|
let t = e.tagName.toLowerCase();
|
|
362
|
-
return t === "a" || t === "area" ? e.hasAttribute("href") :
|
|
446
|
+
return t === "a" || t === "area" ? e.hasAttribute("href") : ge.has(t);
|
|
363
447
|
}
|
|
364
|
-
function
|
|
365
|
-
if (!e.isConnected || !
|
|
448
|
+
function ve(e) {
|
|
449
|
+
if (!e.isConnected || !J([e])) return !1;
|
|
366
450
|
let t = e.ownerDocument.createElement("span");
|
|
367
451
|
t.textContent = "x", t.style.cssText = "position:absolute;visibility:hidden", e.appendChild(t);
|
|
368
|
-
let n =
|
|
452
|
+
let n = J([t]);
|
|
369
453
|
return t.remove(), n;
|
|
370
454
|
}
|
|
371
|
-
function
|
|
455
|
+
function ye(e, t, n, r) {
|
|
372
456
|
let i = e.createDocumentFragment(), a = [];
|
|
373
457
|
for (let o of t) {
|
|
374
458
|
if (o.kind === "space") {
|
|
@@ -383,10 +467,10 @@ function de(e, t, n, r) {
|
|
|
383
467
|
fragments: a
|
|
384
468
|
};
|
|
385
469
|
}
|
|
386
|
-
function
|
|
387
|
-
if (t.trim().length === 0) throw new
|
|
388
|
-
if (!
|
|
389
|
-
let a = e.ownerDocument, o =
|
|
470
|
+
function be(e, t, n, r, i) {
|
|
471
|
+
if (t.trim().length === 0) throw new W("empty");
|
|
472
|
+
if (!ve(e)) throw new W("unmeasurable");
|
|
473
|
+
let a = e.ownerDocument, o = q(t, n), s = [], c = [], l = /* @__PURE__ */ new Map();
|
|
390
474
|
for (let e of o) {
|
|
391
475
|
if (e.kind === "space") {
|
|
392
476
|
s.push(a.createTextNode(e.text));
|
|
@@ -404,7 +488,7 @@ function K(e, t, n, r, i) {
|
|
|
404
488
|
};
|
|
405
489
|
if (t) {
|
|
406
490
|
if (t.kind === "unit" && e instanceof HTMLElement) {
|
|
407
|
-
let t =
|
|
491
|
+
let t = he(e.getBoundingClientRect().top);
|
|
408
492
|
f === null ? f = t : t !== f && (d.length > 0 && u.push(d), d = [], f = t);
|
|
409
493
|
}
|
|
410
494
|
d.push(t);
|
|
@@ -418,32 +502,32 @@ function K(e, t, n, r, i) {
|
|
|
418
502
|
}
|
|
419
503
|
return e.replaceChildren(p), m;
|
|
420
504
|
}
|
|
421
|
-
function
|
|
422
|
-
return e.setAttribute("aria-label", t), n === null ||
|
|
505
|
+
function Y(e, t, n) {
|
|
506
|
+
return e.setAttribute("aria-label", t), n === null || _e(e) ? !1 : (e.setAttribute("role", n), !0);
|
|
423
507
|
}
|
|
424
|
-
function
|
|
508
|
+
function xe(e, t = {}) {
|
|
425
509
|
let { by: n = "word", a11y: r = !0, role: i = "img", locale: a, stagger: o, fragmentClass: s = "kf-split", onRefuse: c } = t, l = e.ownerDocument, u = e.textContent ?? "", d = e.innerHTML, f = e.getAttribute("aria-label"), p;
|
|
426
|
-
if (n === "line") p =
|
|
510
|
+
if (n === "line") p = be(e, u, a, s, r);
|
|
427
511
|
else {
|
|
428
|
-
let t =
|
|
512
|
+
let t = ye(l, n === "grapheme" ? me(u, a) : q(u, a), s, r);
|
|
429
513
|
e.replaceChildren(t.frag), p = t.fragments;
|
|
430
514
|
}
|
|
431
|
-
let m = r ?
|
|
432
|
-
n === "line" && (p =
|
|
515
|
+
let m = r ? Y(e, u, i) : !1, h = L(p.length, o), g = h.delays(p.length), _ = null, v = 0, y = 0, b = () => {
|
|
516
|
+
n === "line" && (p = be(e, u, a, s, r), r && Y(e, u, i), h = L(p.length, o), g = h.delays(p.length));
|
|
433
517
|
}, x = () => {
|
|
434
518
|
_?.disconnect(), _ = null;
|
|
435
519
|
};
|
|
436
520
|
return n === "line" && typeof ResizeObserver < "u" && (_ = new ResizeObserver(() => {
|
|
437
521
|
let e = typeof performance < "u" ? performance.now() : Date.now();
|
|
438
522
|
if (e - y > 500 && (y = e, v = 0), ++v > 12) {
|
|
439
|
-
let e = new
|
|
523
|
+
let e = new W("unstable");
|
|
440
524
|
x(), c?.(e);
|
|
441
525
|
return;
|
|
442
526
|
}
|
|
443
527
|
try {
|
|
444
528
|
b();
|
|
445
529
|
} catch (e) {
|
|
446
|
-
if (e instanceof
|
|
530
|
+
if (e instanceof W) {
|
|
447
531
|
x(), c?.(e);
|
|
448
532
|
return;
|
|
449
533
|
}
|
|
@@ -471,8 +555,8 @@ function fe(e, t = {}) {
|
|
|
471
555
|
}
|
|
472
556
|
//#endregion
|
|
473
557
|
//#region src/animation/orchestration/view-transition/view-transition.ts
|
|
474
|
-
var
|
|
475
|
-
function
|
|
558
|
+
var Se = 300, Ce = () => typeof document < "u" && typeof document.startViewTransition == "function", X = (e) => e.then(() => void 0, () => void 0);
|
|
559
|
+
function Z(e) {
|
|
476
560
|
let t = Promise.resolve(e()).then(() => void 0, () => void 0);
|
|
477
561
|
return {
|
|
478
562
|
ready: t,
|
|
@@ -482,22 +566,22 @@ function Y(e) {
|
|
|
482
566
|
backend: "immediate"
|
|
483
567
|
};
|
|
484
568
|
}
|
|
485
|
-
function
|
|
486
|
-
if (t.length === 0) return
|
|
569
|
+
function we(e, t, n, r) {
|
|
570
|
+
if (t.length === 0) return Z(e);
|
|
487
571
|
let i = {
|
|
488
572
|
duration: n,
|
|
489
573
|
...r === void 0 ? {} : { timingFunction: r }
|
|
490
574
|
}, a = Promise.resolve(e()).then(() => void 0, () => void 0);
|
|
491
575
|
return {
|
|
492
576
|
ready: a,
|
|
493
|
-
finished: a.then(() => Promise.all(t.map(([e, t]) =>
|
|
577
|
+
finished: a.then(() => Promise.all(t.map(([e, t]) => U(e, t, i)))).then(() => void 0, () => void 0),
|
|
494
578
|
updateCallbackDone: a,
|
|
495
579
|
skip: () => {},
|
|
496
580
|
backend: "flip"
|
|
497
581
|
};
|
|
498
582
|
}
|
|
499
|
-
function
|
|
500
|
-
let { types:
|
|
583
|
+
function Te(e, n = {}) {
|
|
584
|
+
let { types: r, duration: i = Se, timingFunction: a, shared: o = [], fallback: s = "flip", respectReducedMotion: c = !0 } = n, l = () => {
|
|
501
585
|
if (typeof s == "function") {
|
|
502
586
|
let t = s(e).then(() => void 0, () => void 0);
|
|
503
587
|
return {
|
|
@@ -508,27 +592,27 @@ function X(e, t = {}) {
|
|
|
508
592
|
backend: "flip"
|
|
509
593
|
};
|
|
510
594
|
}
|
|
511
|
-
return s === "none" ?
|
|
595
|
+
return s === "none" ? Z(e) : we(e, o, i, a);
|
|
512
596
|
};
|
|
513
|
-
return
|
|
514
|
-
if (!
|
|
515
|
-
let t = document,
|
|
597
|
+
return t(c, () => Z(e), () => {
|
|
598
|
+
if (!Ce()) return l();
|
|
599
|
+
let t = document, n = t.startViewTransition.bind(t), i;
|
|
516
600
|
try {
|
|
517
|
-
i =
|
|
601
|
+
i = r && r.length > 0 ? n({
|
|
518
602
|
update: e,
|
|
519
|
-
types:
|
|
520
|
-
}) :
|
|
603
|
+
types: r
|
|
604
|
+
}) : n(e);
|
|
521
605
|
} catch {
|
|
522
606
|
try {
|
|
523
|
-
i =
|
|
607
|
+
i = n(e);
|
|
524
608
|
} catch {
|
|
525
609
|
return l();
|
|
526
610
|
}
|
|
527
611
|
}
|
|
528
612
|
return {
|
|
529
|
-
ready:
|
|
530
|
-
finished:
|
|
531
|
-
updateCallbackDone:
|
|
613
|
+
ready: X(i.ready),
|
|
614
|
+
finished: X(i.finished),
|
|
615
|
+
updateCallbackDone: X(i.updateCallbackDone),
|
|
532
616
|
skip: () => i.skipTransition?.(),
|
|
533
617
|
backend: "view-transition"
|
|
534
618
|
};
|
|
@@ -536,11 +620,12 @@ function X(e, t = {}) {
|
|
|
536
620
|
}
|
|
537
621
|
//#endregion
|
|
538
622
|
//#region src/animation/orchestration/drag/draggable.ts
|
|
539
|
-
var
|
|
623
|
+
var Ee = 100, De = .4, Oe = 5, Q = class {
|
|
540
624
|
spring;
|
|
541
625
|
axis;
|
|
542
626
|
transform;
|
|
543
627
|
velocityWindow;
|
|
628
|
+
passThrough;
|
|
544
629
|
bounds;
|
|
545
630
|
rubberBand;
|
|
546
631
|
snap;
|
|
@@ -549,11 +634,12 @@ var ge = 100, _e = .4, ve = 5, Z = class {
|
|
|
549
634
|
samples = [];
|
|
550
635
|
subscribers = /* @__PURE__ */ new Set();
|
|
551
636
|
springUnsub;
|
|
637
|
+
heldEmissions;
|
|
552
638
|
onPointerDown = (e) => this.handleDown(e);
|
|
553
639
|
onPointerMove = (e) => this.handleMove(e);
|
|
554
640
|
onPointerUp = (e) => this.handleUp(e);
|
|
555
641
|
constructor(e) {
|
|
556
|
-
this.axis = e?.axis ?? "x", this.transform = e?.transform ?? ((e) => e), this.velocityWindow = e?.velocityWindow ??
|
|
642
|
+
this.axis = e?.axis ?? "x", this.transform = e?.transform ?? ((e) => e), this.velocityWindow = e?.velocityWindow ?? Ee, this.passThrough = e?.passThrough ?? !1, this.bounds = e?.bounds, this.rubberBand = e?.rubberBand ?? De, this.snap = e?.snap !== void 0 && e.snap.length > 0 ? e.snap : void 0, this.spring = e?.spring ?? new h(e?.springOptions);
|
|
557
643
|
}
|
|
558
644
|
get dragging() {
|
|
559
645
|
return this.capturedPointerId !== void 0;
|
|
@@ -580,7 +666,8 @@ var ge = 100, _e = .4, ve = 5, Z = class {
|
|
|
580
666
|
};
|
|
581
667
|
}
|
|
582
668
|
emit(e, t) {
|
|
583
|
-
|
|
669
|
+
if (this.heldEmissions) this.heldEmissions.push([e, t]);
|
|
670
|
+
else for (let n of this.subscribers) n(e, t);
|
|
584
671
|
}
|
|
585
672
|
dispose() {
|
|
586
673
|
this.detach(), this.springUnsub?.(), this.springUnsub = void 0, this.subscribers.clear(), this.spring.dispose();
|
|
@@ -592,16 +679,16 @@ var ge = 100, _e = .4, ve = 5, Z = class {
|
|
|
592
679
|
let t = this.element;
|
|
593
680
|
if (!t || this.dragging) return;
|
|
594
681
|
this.capturedPointerId = e.pointerId, t.setPointerCapture?.(e.pointerId), t.addEventListener("pointermove", this.onPointerMove), t.addEventListener("pointerup", this.onPointerUp), t.addEventListener("pointercancel", this.onPointerUp);
|
|
595
|
-
let n = this.coordOf(e);
|
|
596
|
-
this.spring.reset(
|
|
597
|
-
value:
|
|
682
|
+
let n = this.coordOf(e), r = this.passThrough ? this.applyBounds(n) : n;
|
|
683
|
+
this.spring.reset(r, 0), this.samples = [{
|
|
684
|
+
value: r,
|
|
598
685
|
t: e.timeStamp
|
|
599
686
|
}];
|
|
600
687
|
}
|
|
601
688
|
handleMove(e) {
|
|
602
689
|
if (e.pointerId !== this.capturedPointerId) return;
|
|
603
|
-
let t = this.coordOf(e);
|
|
604
|
-
this.spring.target =
|
|
690
|
+
let t = this.coordOf(e), n = this.applyBounds(t);
|
|
691
|
+
this.passThrough ? this.spring.reset(n, 0) : this.spring.target = n, this.pushSample(this.passThrough ? n : t, e.timeStamp);
|
|
605
692
|
}
|
|
606
693
|
applyBounds(e) {
|
|
607
694
|
let t = this.bounds;
|
|
@@ -609,21 +696,31 @@ var ge = 100, _e = .4, ve = 5, Z = class {
|
|
|
609
696
|
}
|
|
610
697
|
handleUp(e) {
|
|
611
698
|
if (e.pointerId !== this.capturedPointerId) return;
|
|
612
|
-
let t = this.element, n = this.coordOf(e);
|
|
613
|
-
this.pushSample(
|
|
614
|
-
let
|
|
615
|
-
if (t && this.endGesture(t), this.
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
699
|
+
let t = this.element, n = this.coordOf(e), r = this.passThrough ? this.applyBounds(n) : n;
|
|
700
|
+
this.pushSample(r, e.timeStamp);
|
|
701
|
+
let i = this.estimateVelocity();
|
|
702
|
+
if (t && this.endGesture(t), !this.passThrough) return this.seatRelease(r, i);
|
|
703
|
+
let a = this.heldEmissions = [];
|
|
704
|
+
try {
|
|
705
|
+
this.seatRelease(r, i);
|
|
706
|
+
} finally {
|
|
707
|
+
this.heldEmissions = void 0;
|
|
708
|
+
for (let [e, t] of a) this.emit(e, t);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
seatRelease(e, t) {
|
|
712
|
+
if (this.snap) {
|
|
713
|
+
let n = b({
|
|
714
|
+
initial: e,
|
|
715
|
+
velocity: t,
|
|
716
|
+
friction: Oe
|
|
717
|
+
}), r = this.nearestSnap(n);
|
|
718
|
+
this.bounds && (r = c(r, this.bounds.min, this.bounds.max)), this.spring.reset(e, t), this.spring.target = r;
|
|
622
719
|
return;
|
|
623
720
|
}
|
|
624
|
-
if (this.spring.reset(
|
|
721
|
+
if (this.spring.reset(e, t), this.bounds) {
|
|
625
722
|
let e = this.spring.value;
|
|
626
|
-
(e < this.bounds.min || e > this.bounds.max) && (this.spring.target =
|
|
723
|
+
(e < this.bounds.min || e > this.bounds.max) && (this.spring.target = c(e, this.bounds.min, this.bounds.max));
|
|
627
724
|
}
|
|
628
725
|
}
|
|
629
726
|
nearestSnap(e) {
|
|
@@ -653,17 +750,17 @@ var ge = 100, _e = .4, ve = 5, Z = class {
|
|
|
653
750
|
return r <= 0 ? 0 : (n.value - t.value) / r * 1e3;
|
|
654
751
|
}
|
|
655
752
|
};
|
|
656
|
-
function
|
|
657
|
-
let n = new
|
|
753
|
+
function ke(e, t) {
|
|
754
|
+
let n = new Q(t);
|
|
658
755
|
return n.attach(e), n;
|
|
659
756
|
}
|
|
660
757
|
//#endregion
|
|
661
758
|
//#region src/animation/orchestration/drag/2d.ts
|
|
662
|
-
function
|
|
663
|
-
let n = new
|
|
759
|
+
function Ae(e, t) {
|
|
760
|
+
let n = new Q({
|
|
664
761
|
...t?.x,
|
|
665
762
|
axis: "x"
|
|
666
|
-
}), r = new
|
|
763
|
+
}), r = new Q({
|
|
667
764
|
...t?.y,
|
|
668
765
|
axis: "y"
|
|
669
766
|
});
|
|
@@ -700,10 +797,10 @@ function be(e, t) {
|
|
|
700
797
|
}
|
|
701
798
|
//#endregion
|
|
702
799
|
//#region src/animation/load-engine.ts
|
|
703
|
-
var
|
|
704
|
-
throw
|
|
705
|
-
}),
|
|
800
|
+
var je, $ = () => je ??= import("./engine/index.js").catch((e) => {
|
|
801
|
+
throw je = void 0, e;
|
|
802
|
+
}), Me = () => {
|
|
706
803
|
$();
|
|
707
804
|
};
|
|
708
805
|
//#endregion
|
|
709
|
-
export {
|
|
806
|
+
export { i as AnimationOptionError, Q as Draggable, P as ElementMorph, re as KeyframesScrollTimeline, ie as ManualTimeline, D as NumericAnimation, oe as Oscillator, T as RAFPlayback, C as Sequence, d as SmoothProgress, W as SplitTextRefusalError, h as SpringProgress, F as Timeline, a as UnknownEasingError, S as createNativeTimeline, u as decay, b as decayRest, ke as drag, Ae as drag2D, fe as flip, U as flipShared, p as linearFromSamples, $ as loadAnimationEngine, O as probeVelocity, s as reducedMotionScale, k as reseatToSpring, e as resolveEasing, f as serializeSelector, g as settleTime, xe as splitText, M as springKeyframes, m as springLinearStops, v as springTimingFunction, w as springTimingLUT, L as stagger, _ as toEasing, Te as viewTransition, Me as warmEngine, I as waveformValue };
|