@mkbabb/keyframes.js 4.3.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -6
- package/dist/animate-CTWr6K7j.js +26 -0
- package/dist/{animations-DaMcGoCd.js → animations-CZxf0rep.js} +3 -3
- package/dist/compile-YRJRdpKF.js +251 -0
- package/dist/{draw-svg-CF2cTJj-.js → draw-svg-Dat9mHgi.js} +1 -1
- package/dist/engine-DQcb7CLW.js +1349 -0
- package/dist/errors-W8zkvPw4.js +21 -0
- package/dist/format-BUgCTjmr.js +123 -0
- package/dist/ingest-CU-kdYcM.js +160 -0
- package/dist/keyframes.d.ts +2495 -1659
- package/dist/keyframes.js +223 -87
- package/dist/morph-svg-83uyYxoW.js +84 -0
- package/dist/{motion-path-CqmlG74k.js → motion-path-C0OHqcA3.js} +1 -1
- package/dist/rolldown-runtime-Dy4uBu1J.js +11 -0
- package/dist/scheduler-7eIr_q1g.js +14 -0
- package/dist/scroll-grammar-B4kPvGh5.js +23 -0
- package/dist/{scroll-scene-JpRpH1uU.js → scroll-scene-DQxhxn9I.js} +18 -39
- package/dist/{sequence-COn8zk5o.js → sequence-cBr7thU8.js} +49 -7
- package/dist/{springTimingFunction-CcJEvGwN.js → springTimingFunction-D26gPkAy.js} +23 -11
- package/dist/{timeline-BjcmprQ6.js → timeline-vY3eD3Ax.js} +125 -111
- package/dist/utils-BPRImVl5.js +100 -0
- package/dist/validate-B1pE-Y_T.js +35 -0
- package/dist/{waapi-Bd5QadtA.js → waapi-D0ssxKy1.js} +90 -28
- package/package.json +61 -6
- package/dist/animate-D5KoLKwi.js +0 -21
- package/dist/binarySearch-DOP8erk-.js +0 -13
- package/dist/compile-C0xOTIC4.js +0 -249
- package/dist/engine-BKm1GcJT.js +0 -1028
- package/dist/ingest-BFBYGTH-.js +0 -139
package/dist/keyframes.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { n as
|
|
4
|
-
import { n as
|
|
5
|
-
import { t as
|
|
1
|
+
import { n as e, t } from "./errors-W8zkvPw4.js";
|
|
2
|
+
import { _ as n, a as r, c as i, f as a, g as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g } from "./timeline-vY3eD3Ax.js";
|
|
3
|
+
import { n as _, r as ee, t as v } from "./springTimingFunction-D26gPkAy.js";
|
|
4
|
+
import { n as y, t as b } from "./decay-BvNmFk51.js";
|
|
5
|
+
import { t as x } from "./sequence-cBr7thU8.js";
|
|
6
6
|
//#region src/animation/numeric.ts
|
|
7
|
-
var C = class {
|
|
7
|
+
var S = new Float64Array(), C = class {
|
|
8
8
|
keyframes;
|
|
9
9
|
segments;
|
|
10
10
|
positions;
|
|
@@ -12,17 +12,17 @@ var C = class {
|
|
|
12
12
|
_duration;
|
|
13
13
|
_respectReducedMotion;
|
|
14
14
|
_easingFn;
|
|
15
|
-
_playback = new
|
|
16
|
-
constructor(
|
|
17
|
-
if (
|
|
18
|
-
this.keyframes =
|
|
19
|
-
let
|
|
20
|
-
if (typeof
|
|
21
|
-
if (this._easingFn =
|
|
22
|
-
if (
|
|
23
|
-
this.positions =
|
|
24
|
-
} else this.positions =
|
|
25
|
-
this.result = { ...
|
|
15
|
+
_playback = new c();
|
|
16
|
+
constructor(e, r) {
|
|
17
|
+
if (e.length < 2) throw Error("NumericAnimation requires at least 2 keyframes.");
|
|
18
|
+
this.keyframes = e.map((e) => ({ ...e })), this._duration = r?.duration ?? 0, this._respectReducedMotion = r?.respectReducedMotion ?? !1;
|
|
19
|
+
let i = r?.timingFunction;
|
|
20
|
+
if (typeof i == "string") throw new t("timingFunction", i, "NumericAnimation accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
|
|
21
|
+
if (this._easingFn = i == null ? (e) => e : n(i).fn, r?.positions) {
|
|
22
|
+
if (r.positions.length !== e.length) throw Error("positions length must match keyframes length.");
|
|
23
|
+
this.positions = r.positions;
|
|
24
|
+
} else this.positions = e.map((t, n) => n / (e.length - 1) * 100);
|
|
25
|
+
this.result = { ...e[0] }, this.segments = this.buildSegments();
|
|
26
26
|
}
|
|
27
27
|
buildSegments() {
|
|
28
28
|
let e = [];
|
|
@@ -30,21 +30,27 @@ var C = class {
|
|
|
30
30
|
return e;
|
|
31
31
|
}
|
|
32
32
|
buildSegment(e) {
|
|
33
|
-
let t = this.keyframes[e], n = this.keyframes[e + 1], r = Object.keys(t);
|
|
33
|
+
let t = this.keyframes[e], n = this.keyframes[e + 1], r = Object.keys(t), i = new Float64Array(r.length), a = new Float64Array(r.length);
|
|
34
|
+
for (let e = 0; e < r.length; e++) {
|
|
35
|
+
let o = r[e];
|
|
36
|
+
i[e] = t[o], a[e] = n[o];
|
|
37
|
+
}
|
|
34
38
|
return {
|
|
35
39
|
startPos: this.positions[e],
|
|
36
40
|
stopPos: this.positions[e + 1],
|
|
37
41
|
keys: r,
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
from: i,
|
|
43
|
+
to: a,
|
|
40
44
|
timingFunction: this._easingFn
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
47
|
at(e) {
|
|
44
|
-
let t =
|
|
48
|
+
let t = a(e, 0, 1) * 100, n = ee(this.segments, t, (e) => e.startPos, (e) => e.stopPos);
|
|
45
49
|
n === -1 && (n = this.segments.length - 1);
|
|
46
|
-
let
|
|
47
|
-
|
|
50
|
+
let r = this.segments[n], i = l(a(t, r.startPos, r.stopPos), r.startPos, r.stopPos, 0, 1), o = r.timingFunction(i), s = r.keys.length;
|
|
51
|
+
S.length < s && (S = new Float64Array(s)), f(r.from, r.to, o, S);
|
|
52
|
+
let c = this.result;
|
|
53
|
+
for (let e = 0; e < s; e++) c[r.keys[e]] = S[e];
|
|
48
54
|
return this.result;
|
|
49
55
|
}
|
|
50
56
|
updateKeyframe(e, t) {
|
|
@@ -116,35 +122,65 @@ var C = class {
|
|
|
116
122
|
stop() {
|
|
117
123
|
this.animation.stop();
|
|
118
124
|
}
|
|
119
|
-
}, E =
|
|
120
|
-
|
|
125
|
+
}, E = 2 * Math.PI;
|
|
126
|
+
function D(e, t) {
|
|
127
|
+
let n = e - Math.floor(e);
|
|
128
|
+
switch (t) {
|
|
129
|
+
case "sine": return Math.sin(E * n);
|
|
130
|
+
case "triangle": return n < .5 ? 4 * n - 1 : 3 - 4 * n;
|
|
131
|
+
case "square": return n < .5 ? 1 : -1;
|
|
132
|
+
case "sawtooth": return 2 * n - 1;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
var O = class {
|
|
136
|
+
frequency;
|
|
137
|
+
waveform;
|
|
138
|
+
phase = 0;
|
|
139
|
+
constructor(e) {
|
|
140
|
+
this.frequency = e.frequency, this.waveform = e.waveform ?? "sine";
|
|
141
|
+
}
|
|
142
|
+
tick(e) {
|
|
143
|
+
let t = this.phase + this.frequency * e;
|
|
144
|
+
return this.phase = t - Math.floor(t), this.phase;
|
|
145
|
+
}
|
|
146
|
+
get value() {
|
|
147
|
+
return D(this.phase, this.waveform);
|
|
148
|
+
}
|
|
149
|
+
sample(e) {
|
|
150
|
+
return D(e * this.frequency, this.waveform);
|
|
151
|
+
}
|
|
152
|
+
reset(e = 0) {
|
|
153
|
+
this.phase = e - Math.floor(e);
|
|
154
|
+
}
|
|
155
|
+
}, k = (e, t) => {
|
|
156
|
+
if (typeof e == "number") return a(e, 0, Math.max(0, t - 1));
|
|
121
157
|
switch (e) {
|
|
122
158
|
case "first": return 0;
|
|
123
159
|
case "last": return t - 1;
|
|
124
160
|
case "center": return (t - 1) / 2;
|
|
125
161
|
case "edges": return -1;
|
|
126
162
|
}
|
|
127
|
-
},
|
|
163
|
+
}, A = (e, t, n) => n === "edges" ? Math.min(e, t - 1 - e) : Math.abs(e - k(n, t)), j = (e, t) => {
|
|
128
164
|
if (e <= 1) return 0;
|
|
129
165
|
if (t === "edges") return Math.floor((e - 1) / 2);
|
|
130
|
-
let n =
|
|
166
|
+
let n = k(t, e);
|
|
131
167
|
return Math.max(n, e - 1 - n);
|
|
132
168
|
};
|
|
133
|
-
function
|
|
134
|
-
let { each:
|
|
135
|
-
if (typeof
|
|
136
|
-
let
|
|
169
|
+
function M(e, r = {}) {
|
|
170
|
+
let { each: i = 100, from: a = "first", ease: o } = r;
|
|
171
|
+
if (typeof o == "string") throw new t("ease", o, "stagger accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
|
|
172
|
+
let s = o ? n(o).fn : void 0, c = typeof e == "number" ? e : e.length, l = (e, t) => {
|
|
137
173
|
if (t <= 1) return 0;
|
|
138
|
-
let n =
|
|
174
|
+
let n = j(t, a);
|
|
139
175
|
if (n === 0) return 0;
|
|
140
|
-
let
|
|
141
|
-
return
|
|
142
|
-
},
|
|
143
|
-
return
|
|
176
|
+
let r = A(e, t, a);
|
|
177
|
+
return s ? s(r / n) * i * n : r * i;
|
|
178
|
+
}, u = ((e, t = c) => l(e, t));
|
|
179
|
+
return u.delays = (e = c) => Array.from({ length: e }, (t, n) => l(n, e)), u;
|
|
144
180
|
}
|
|
145
181
|
//#endregion
|
|
146
182
|
//#region src/animation/flip.ts
|
|
147
|
-
var
|
|
183
|
+
var N = 300, P = (e) => {
|
|
148
184
|
let t = e.getBoundingClientRect();
|
|
149
185
|
return {
|
|
150
186
|
x: t.x,
|
|
@@ -152,21 +188,21 @@ var A = 300, j = (e) => {
|
|
|
152
188
|
width: t.width,
|
|
153
189
|
height: t.height
|
|
154
190
|
};
|
|
155
|
-
},
|
|
191
|
+
}, F = (e, t) => {
|
|
156
192
|
let n = e.at(1), r = n.translateX, i = n.translateY, a = n.scaleX, o = n.scaleY, s = e.at(t);
|
|
157
193
|
return `translate(${s.translateX - r}px, ${s.translateY - i}px) scale(${a === 0 ? 1 : s.scaleX / a}, ${o === 0 ? 1 : s.scaleY / o})`;
|
|
158
|
-
},
|
|
159
|
-
e.style.transform =
|
|
194
|
+
}, I = (e, t, n, r) => (e.style.transformOrigin = r, e.style.transform = F(t, 0), n <= 0 ? (e.style.transform = F(t, 1), Promise.resolve()) : new c().play(n, (n) => {
|
|
195
|
+
e.style.transform = F(t, n);
|
|
160
196
|
}));
|
|
161
|
-
function
|
|
162
|
-
let { duration: r =
|
|
163
|
-
return t(),
|
|
197
|
+
function L(e, t, n = {}) {
|
|
198
|
+
let { duration: r = N, timingFunction: i, transformOrigin: a = "top left" } = n, o = P(e);
|
|
199
|
+
return t(), I(e, new T(o, P(e), {
|
|
164
200
|
...i === void 0 ? {} : { timingFunction: i },
|
|
165
201
|
transformOrigin: a
|
|
166
202
|
}), r, a);
|
|
167
203
|
}
|
|
168
|
-
function
|
|
169
|
-
let { duration: r =
|
|
204
|
+
function R(e, t, n = {}) {
|
|
205
|
+
let { duration: r = N, timingFunction: i, transformOrigin: a = "top left" } = n, o = new T(P(e), P(t), {
|
|
170
206
|
...i === void 0 ? {} : { timingFunction: i },
|
|
171
207
|
duration: r,
|
|
172
208
|
transformOrigin: a
|
|
@@ -174,12 +210,56 @@ function F(e, t, n = {}) {
|
|
|
174
210
|
return o.apply(e, 0), r <= 0 ? (o.apply(e, 1), Promise.resolve()) : o.play(e, r);
|
|
175
211
|
}
|
|
176
212
|
//#endregion
|
|
213
|
+
//#region src/animation/drag-2d.ts
|
|
214
|
+
function z(e, t) {
|
|
215
|
+
let n = new U({
|
|
216
|
+
...t?.x,
|
|
217
|
+
axis: "x"
|
|
218
|
+
}), r = new U({
|
|
219
|
+
...t?.y,
|
|
220
|
+
axis: "y"
|
|
221
|
+
});
|
|
222
|
+
n.attach(e), r.attach(e);
|
|
223
|
+
let i = /* @__PURE__ */ new Set(), a = (e) => e.dragging ? e.spring.target : e.spring.value, o = () => {
|
|
224
|
+
let e = a(n), t = a(r), o = n.velocity, s = r.velocity;
|
|
225
|
+
for (let n of i) n(e, t, o, s);
|
|
226
|
+
}, s = n.subscribe(() => o()), c = r.subscribe(() => o());
|
|
227
|
+
return {
|
|
228
|
+
x: n,
|
|
229
|
+
y: r,
|
|
230
|
+
get value() {
|
|
231
|
+
return {
|
|
232
|
+
x: a(n),
|
|
233
|
+
y: a(r)
|
|
234
|
+
};
|
|
235
|
+
},
|
|
236
|
+
get velocity() {
|
|
237
|
+
return {
|
|
238
|
+
x: n.velocity,
|
|
239
|
+
y: r.velocity
|
|
240
|
+
};
|
|
241
|
+
},
|
|
242
|
+
get settled() {
|
|
243
|
+
return n.settled && r.settled;
|
|
244
|
+
},
|
|
245
|
+
subscribe(e) {
|
|
246
|
+
return i.add(e), () => i.delete(e);
|
|
247
|
+
},
|
|
248
|
+
dispose() {
|
|
249
|
+
i.clear(), s(), c(), n.dispose(), r.dispose();
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
177
254
|
//#region src/animation/drag.ts
|
|
178
|
-
var
|
|
255
|
+
var B = 100, V = .4, H = 5, U = class {
|
|
179
256
|
spring;
|
|
180
257
|
axis;
|
|
181
258
|
transform;
|
|
182
259
|
velocityWindow;
|
|
260
|
+
bounds;
|
|
261
|
+
rubberBand;
|
|
262
|
+
snap;
|
|
183
263
|
element;
|
|
184
264
|
capturedPointerId;
|
|
185
265
|
samples = [];
|
|
@@ -189,7 +269,7 @@ var I = 100, L = class {
|
|
|
189
269
|
onPointerMove = (e) => this.handleMove(e);
|
|
190
270
|
onPointerUp = (e) => this.handleUp(e);
|
|
191
271
|
constructor(e) {
|
|
192
|
-
this.axis = e?.axis ?? "x", this.transform = e?.transform ?? ((e) => e), this.velocityWindow = e?.velocityWindow ??
|
|
272
|
+
this.axis = e?.axis ?? "x", this.transform = e?.transform ?? ((e) => e), this.velocityWindow = e?.velocityWindow ?? B, this.bounds = e?.bounds, this.rubberBand = e?.rubberBand ?? V, this.snap = e?.snap !== void 0 && e.snap.length > 0 ? e.snap : void 0, this.spring = e?.spring ?? new r(e?.springOptions);
|
|
193
273
|
}
|
|
194
274
|
get dragging() {
|
|
195
275
|
return this.capturedPointerId !== void 0;
|
|
@@ -237,14 +317,38 @@ var I = 100, L = class {
|
|
|
237
317
|
handleMove(e) {
|
|
238
318
|
if (e.pointerId !== this.capturedPointerId) return;
|
|
239
319
|
let t = this.coordOf(e);
|
|
240
|
-
this.spring.target = t, this.pushSample(t, e.timeStamp);
|
|
320
|
+
this.spring.target = this.applyBounds(t), this.pushSample(t, e.timeStamp);
|
|
321
|
+
}
|
|
322
|
+
applyBounds(e) {
|
|
323
|
+
let t = this.bounds;
|
|
324
|
+
return t ? e < t.min ? t.min + (e - t.min) * this.rubberBand : e > t.max ? t.max + (e - t.max) * this.rubberBand : e : e;
|
|
241
325
|
}
|
|
242
326
|
handleUp(e) {
|
|
243
327
|
if (e.pointerId !== this.capturedPointerId) return;
|
|
244
328
|
let t = this.element, n = this.coordOf(e);
|
|
245
329
|
this.pushSample(n, e.timeStamp);
|
|
246
330
|
let r = this.estimateVelocity();
|
|
247
|
-
t && this.endGesture(t), this.
|
|
331
|
+
if (t && this.endGesture(t), this.snap) {
|
|
332
|
+
let e = y({
|
|
333
|
+
initial: n,
|
|
334
|
+
velocity: r,
|
|
335
|
+
friction: H
|
|
336
|
+
}), t = this.nearestSnap(e);
|
|
337
|
+
this.bounds && (t = a(t, this.bounds.min, this.bounds.max)), this.spring.reset(n, r), this.spring.target = t;
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (this.spring.reset(n, r), this.bounds) {
|
|
341
|
+
let e = this.spring.value;
|
|
342
|
+
(e < this.bounds.min || e > this.bounds.max) && (this.spring.target = a(e, this.bounds.min, this.bounds.max));
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
nearestSnap(e) {
|
|
346
|
+
let t = this.snap, n = t[0], r = Math.abs(e - n);
|
|
347
|
+
for (let i = 1; i < t.length; i++) {
|
|
348
|
+
let a = t[i], o = Math.abs(e - a);
|
|
349
|
+
o < r && (n = a, r = o);
|
|
350
|
+
}
|
|
351
|
+
return n;
|
|
248
352
|
}
|
|
249
353
|
endGesture(e) {
|
|
250
354
|
this.capturedPointerId !== void 0 && e.releasePointerCapture?.(this.capturedPointerId), e.removeEventListener("pointermove", this.onPointerMove), e.removeEventListener("pointerup", this.onPointerUp), e.removeEventListener("pointercancel", this.onPointerUp), this.capturedPointerId = void 0;
|
|
@@ -265,46 +369,78 @@ var I = 100, L = class {
|
|
|
265
369
|
return r <= 0 ? 0 : (n.value - t.value) / r * 1e3;
|
|
266
370
|
}
|
|
267
371
|
};
|
|
268
|
-
function
|
|
269
|
-
let n = new
|
|
372
|
+
function W(e, t) {
|
|
373
|
+
let n = new U(t);
|
|
270
374
|
return n.attach(e), n;
|
|
271
375
|
}
|
|
272
376
|
//#endregion
|
|
273
|
-
//#region src/animation/
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
377
|
+
//#region src/animation/load-engine.ts
|
|
378
|
+
var G = null, K = null, q = null, J = null, Y = () => G ??= import("./engine-DQcb7CLW.js"), X = null, Z = () => X ??= Y(), Q = null, te = () => Q ??= Promise.all([Y(), K ??= import("./compile-YRJRdpKF.js")]).then(([e, t]) => Object.assign({ compileToCSS: t.compileToCSS }, e)), ne = null, re = () => ne ??= Promise.all([
|
|
379
|
+
Y(),
|
|
380
|
+
q ??= import("./ingest-CU-kdYcM.js"),
|
|
381
|
+
J ??= import("./scroll-scene-DQxhxn9I.js")
|
|
382
|
+
]).then(([e, t, n]) => Object.assign({
|
|
383
|
+
fromStyleSheets: t.fromStyleSheets,
|
|
384
|
+
fromLiveAnimations: t.fromLiveAnimations,
|
|
385
|
+
resolveLiveKeyframes: t.resolveLiveKeyframes,
|
|
386
|
+
adoptRunning: t.adoptRunning,
|
|
387
|
+
ScrollScene: n.ScrollScene,
|
|
388
|
+
createScrollScene: n.createScrollScene,
|
|
389
|
+
parseScrollCSS: n.parseScrollCSS,
|
|
390
|
+
parseScrollTimeline: n.parseScrollTimeline,
|
|
391
|
+
parseScrollRange: n.parseScrollRange,
|
|
392
|
+
serializeScrollOptions: n.serializeScrollOptions,
|
|
393
|
+
roundTripScrollCSS: n.roundTripScrollCSS,
|
|
394
|
+
dispatchScrollBackend: n.dispatchScrollBackend,
|
|
395
|
+
resolveRange: n.resolveRange,
|
|
396
|
+
pinCSS: n.pinCSS
|
|
397
|
+
}, e)), ie = null, $ = () => ie ??= Promise.all([
|
|
398
|
+
Y(),
|
|
399
|
+
import("./animate-CTWr6K7j.js"),
|
|
400
|
+
import("./motion-path-C0OHqcA3.js"),
|
|
401
|
+
import("./draw-svg-Dat9mHgi.js"),
|
|
402
|
+
import("./morph-svg-83uyYxoW.js"),
|
|
403
|
+
q ??= import("./ingest-CU-kdYcM.js"),
|
|
404
|
+
J ??= import("./scroll-scene-DQxhxn9I.js"),
|
|
405
|
+
K ??= import("./compile-YRJRdpKF.js"),
|
|
406
|
+
import("./validate-B1pE-Y_T.js"),
|
|
407
|
+
import("./animations-CZxf0rep.js"),
|
|
408
|
+
import("./format-BUgCTjmr.js").then((e) => e.r),
|
|
409
|
+
import("./utils-BPRImVl5.js").then((e) => e.o),
|
|
410
|
+
import("./scheduler-7eIr_q1g.js").then((e) => e.t)
|
|
411
|
+
]).then(([e, t, n, r, i, a, o, s, c, l, u, d, f]) => Object.assign({
|
|
412
|
+
animate: t.animate,
|
|
413
|
+
MotionPath: n.MotionPath,
|
|
414
|
+
fromMotionPath: n.fromMotionPath,
|
|
415
|
+
DrawSVG: r.DrawSVG,
|
|
416
|
+
fromDrawSVG: r.fromDrawSVG,
|
|
417
|
+
MorphSVG: i.MorphSVG,
|
|
418
|
+
fromMorphSVG: i.fromMorphSVG,
|
|
419
|
+
fromStyleSheets: a.fromStyleSheets,
|
|
420
|
+
fromLiveAnimations: a.fromLiveAnimations,
|
|
421
|
+
resolveLiveKeyframes: a.resolveLiveKeyframes,
|
|
422
|
+
adoptRunning: a.adoptRunning,
|
|
423
|
+
ScrollScene: o.ScrollScene,
|
|
424
|
+
createScrollScene: o.createScrollScene,
|
|
425
|
+
parseScrollCSS: o.parseScrollCSS,
|
|
426
|
+
parseScrollTimeline: o.parseScrollTimeline,
|
|
427
|
+
parseScrollRange: o.parseScrollRange,
|
|
428
|
+
serializeScrollOptions: o.serializeScrollOptions,
|
|
429
|
+
roundTripScrollCSS: o.roundTripScrollCSS,
|
|
430
|
+
dispatchScrollBackend: o.dispatchScrollBackend,
|
|
431
|
+
resolveRange: o.resolveRange,
|
|
432
|
+
pinCSS: o.pinCSS,
|
|
433
|
+
compileToCSS: s.compileToCSS,
|
|
434
|
+
validate: c.validate,
|
|
435
|
+
explain: c.explain,
|
|
436
|
+
presets: l,
|
|
437
|
+
CSSKeyframesToString: u.CSSKeyframesToString,
|
|
438
|
+
CSSKeyframesToStrings: u.CSSKeyframesToStrings,
|
|
439
|
+
formatCSSKeyframeString: u.formatCSSKeyframeString,
|
|
440
|
+
transformTargetsStyle: d.transformTargetsStyle,
|
|
441
|
+
yieldToMain: f.yieldToMain
|
|
442
|
+
}, e)), ae = () => {
|
|
443
|
+
$();
|
|
308
444
|
};
|
|
309
445
|
//#endregion
|
|
310
|
-
export {
|
|
446
|
+
export { t as AnimationOptionError, U as Draggable, T as ElementMorph, h as KeyframesScrollTimeline, u as ManualTimeline, C as NumericAnimation, O as Oscillator, c as RAFPlayback, x as Sequence, i as SmoothProgress, r as SpringProgress, p as Timeline, e as UnknownEasingError, s as createNativeTimeline, b as decay, y as decayRest, W as drag, z as drag2D, L as flip, R as flipShared, $ as loadAnimationEngine, te as loadCompiler, Z as loadEngine, re as loadIngest, d as probeVelocity, g as reducedMotionScale, m as reseatToSpring, o as resolveEasing, _ as springLinearStops, v as springTimingFunction, M as stagger, n as toEasing, ae as warmEngine, D as waveformValue };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { t as e } from "./errors-W8zkvPw4.js";
|
|
2
|
+
import { CSSKeyframesAnimation as t } from "./engine-DQcb7CLW.js";
|
|
3
|
+
import { PathGeometry as n } from "@mkbabb/value.js";
|
|
4
|
+
//#region src/animation/morph-svg.ts
|
|
5
|
+
var r = 64, i = (e) => `--morph-${e}-x`, a = (e) => `--morph-${e}-y`, o = (e) => `--morph-${e}-angle`, s = (e, t, n) => {
|
|
6
|
+
let r = Array(t + 1);
|
|
7
|
+
for (let i = 0; i <= t; i++) if (n) {
|
|
8
|
+
let n = e.sampleAtLength(e.totalLength * (i / t));
|
|
9
|
+
r[i] = {
|
|
10
|
+
x: n.x,
|
|
11
|
+
y: n.y,
|
|
12
|
+
angle: n.angle
|
|
13
|
+
};
|
|
14
|
+
} else r[i] = e.getPointAtT(i / t);
|
|
15
|
+
return r;
|
|
16
|
+
}, c = (e) => Number.isInteger(e) ? `${e}` : e.toFixed(3), l = (e) => {
|
|
17
|
+
if (e.length === 0) return "";
|
|
18
|
+
let t = `M ${c(e[0].x)} ${c(e[0].y)}`;
|
|
19
|
+
for (let n = 1; n < e.length; n++) t += ` L ${c(e[n].x)} ${c(e[n].y)}`;
|
|
20
|
+
return t;
|
|
21
|
+
}, u = (e, t) => {
|
|
22
|
+
let n = Array(t + 1);
|
|
23
|
+
for (let e = 0; e <= t; e++) n[e] = {
|
|
24
|
+
x: 0,
|
|
25
|
+
y: 0
|
|
26
|
+
};
|
|
27
|
+
return (r) => {
|
|
28
|
+
let o = r;
|
|
29
|
+
for (let e = 0; e <= t; e++) {
|
|
30
|
+
let t = n[e];
|
|
31
|
+
t.x = o[i(e)]?.[0]?.value ?? 0, t.y = o[a(e)]?.[0]?.value ?? 0;
|
|
32
|
+
}
|
|
33
|
+
let s = l(n);
|
|
34
|
+
e.style.setProperty("--morph-d", s), e.style.setProperty("d", `path("${s}")`);
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
function d(c, l, d = {}) {
|
|
38
|
+
let { samples: f = r, target: p, orient: m = !1, autoPlay: h = !0, ...g } = d;
|
|
39
|
+
if (typeof c != "string" || c.length === 0) throw new e("from", c, "fromMorphSVG(): `from` must be a non-empty SVG path `d` string.");
|
|
40
|
+
if (typeof l != "string" || l.length === 0) throw new e("to", l, "fromMorphSVG(): `to` must be a non-empty SVG path `d` string.");
|
|
41
|
+
if (!Number.isInteger(f) || f < 2) throw new e("samples", f, "fromMorphSVG(): `samples` must be an integer >= 2 (a 1-sample morph is just the two endpoints, with no body to interpolate).");
|
|
42
|
+
let _ = new n(c), v = new n(l);
|
|
43
|
+
if (_.totalLength === 0) throw new e("from", c, "fromMorphSVG(): the `from` path has zero arc-length — a morph between a zero-length path and anything is malformed input, not an identity animation.");
|
|
44
|
+
if (v.totalLength === 0) throw new e("to", l, "fromMorphSVG(): the `to` path has zero arc-length — a morph between a zero-length path and anything is malformed input, not an identity animation.");
|
|
45
|
+
let y = s(_, f, m), b = s(v, f, m), x = {}, S = {};
|
|
46
|
+
for (let e = 0; e <= f; e++) x[i(e)] = y[e].x, x[a(e)] = y[e].y, S[i(e)] = b[e].x, S[a(e)] = b[e].y, m && (x[o(e)] = y[e].angle ?? 0, S[o(e)] = b[e].angle ?? 0);
|
|
47
|
+
let C = {
|
|
48
|
+
"0%": x,
|
|
49
|
+
"100%": S
|
|
50
|
+
}, w = p == null ? void 0 : u(p, f), T = new t(g).fromKeyframes(C, w);
|
|
51
|
+
return h && T.play(), T;
|
|
52
|
+
}
|
|
53
|
+
var f = class {
|
|
54
|
+
animation;
|
|
55
|
+
samples;
|
|
56
|
+
constructor(e, t, n = {}) {
|
|
57
|
+
this.animation = d(e, t, n), this.samples = n.samples ?? r;
|
|
58
|
+
}
|
|
59
|
+
sampleD(e) {
|
|
60
|
+
let t = (e < 0 ? 0 : e > 1 ? 1 : e) * this.animation.options.duration, n = this.animation.interpFrames(t, !1), r = Array(this.samples + 1);
|
|
61
|
+
for (let e = 0; e <= this.samples; e++) {
|
|
62
|
+
let t = n[i(e)]?.[0]?.value, o = n[a(e)]?.[0]?.value;
|
|
63
|
+
r[e] = {
|
|
64
|
+
x: t ?? 0,
|
|
65
|
+
y: o ?? 0
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return l(r);
|
|
69
|
+
}
|
|
70
|
+
play() {
|
|
71
|
+
return this.animation.play();
|
|
72
|
+
}
|
|
73
|
+
pause() {
|
|
74
|
+
return this.animation.pause(), this;
|
|
75
|
+
}
|
|
76
|
+
stop() {
|
|
77
|
+
return this.animation.stop(), this;
|
|
78
|
+
}
|
|
79
|
+
get finished() {
|
|
80
|
+
return this.animation.finished;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
export { f as MorphSVG, d as fromMorphSVG };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.defineProperty, t = (t, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in t) e(r, i, {
|
|
5
|
+
get: t[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
+
//#region src/animation/internal/scheduler.ts
|
|
3
|
+
var t = /* @__PURE__ */ e({ yieldToMain: () => i }), n = null, r = () => typeof MessageChannel == "function" ? () => new Promise((e) => {
|
|
4
|
+
let t = new MessageChannel();
|
|
5
|
+
t.port1.onmessage = () => {
|
|
6
|
+
t.port1.close(), e();
|
|
7
|
+
}, t.port2.postMessage(void 0);
|
|
8
|
+
}) : () => new Promise((e) => setTimeout(e, 0));
|
|
9
|
+
function i() {
|
|
10
|
+
let e = globalThis.scheduler;
|
|
11
|
+
return e && typeof e.yield == "function" ? e.yield() : (n ??= r(), n());
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { i as n, t };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { extractTimelineOptions as e, parseAnimationRange as t, parseAnimationTimeline as n, parseCSSStylesheet as r, serializeTimelineOptions as i } from "@mkbabb/value.js";
|
|
2
|
+
//#region src/animation/scroll-grammar.ts
|
|
3
|
+
function a(e) {
|
|
4
|
+
return n(e);
|
|
5
|
+
}
|
|
6
|
+
function o(e) {
|
|
7
|
+
return t(e);
|
|
8
|
+
}
|
|
9
|
+
function s(t) {
|
|
10
|
+
return e(typeof t == "string" ? r(t) : t);
|
|
11
|
+
}
|
|
12
|
+
function c(e) {
|
|
13
|
+
return i(e);
|
|
14
|
+
}
|
|
15
|
+
function l(e) {
|
|
16
|
+
let t = s(e);
|
|
17
|
+
return {
|
|
18
|
+
options: t,
|
|
19
|
+
declarations: c(t)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { c as a, l as i, o as n, a as r, s as t };
|