@mkbabb/keyframes.js 4.4.0 → 5.1.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 +36 -221
- package/dist/animation-BGyzfzBq.js +947 -0
- package/dist/compile-CcSUwM8R.js +276 -0
- package/dist/{waapi-D9MHMm_9.js → delegation-DWwr4IXr.js} +116 -32
- package/dist/{draw-svg-DYRDxBlL.js → draw-svg-GURj9nin.js} +17 -13
- package/dist/easing-registry-DHV2-5gA.js +27 -0
- package/dist/easing-registry-y1p9McFy.js +2 -0
- package/dist/engine/index.d.ts +2873 -0
- package/dist/engine/index.js +17 -0
- package/dist/engine-DEVgCTUy.js +156 -0
- package/dist/engine-DrBtsKaf.js +4 -0
- package/dist/{format-BUgCTjmr.js → format-C-Gi9r7L.js} +4 -4
- package/dist/{scroll-grammar-B4kPvGh5.js → grammar-BLucehC4.js} +1 -1
- package/dist/group-vJcsHKN9.js +360 -0
- package/dist/{ingest-CNM5xkQT.js → ingest-S5hUe20K.js} +62 -56
- package/dist/keyframes.d.ts +585 -989
- package/dist/keyframes.js +188 -129
- package/dist/morph-svg-BToeumw5.js +89 -0
- package/dist/{motion-path-J-RSNmRQ.js → motion-path-pQVbamWT.js} +16 -12
- package/dist/parse-flatten-DRMHFytp.js +2 -0
- package/dist/parse-flatten-ZZUSEQEL.js +63 -0
- package/dist/{animations-5nf2kBkv.js → presets-BG2Fczzq.js} +124 -73
- package/dist/{scheduler-7eIr_q1g.js → scheduler-CUtVnuoU.js} +1 -1
- package/dist/{scroll-scene-CXEgM49Q.js → scroll-CxpYFO4u.js} +50 -46
- package/dist/sequence-C_DCiOIQ.js +708 -0
- package/dist/validate-DDeGnvSt.js +39 -0
- package/package.json +45 -6
- package/dist/animate-CuUJt2Tb.js +0 -26
- package/dist/compile-DgNRG6Lo.js +0 -251
- package/dist/decay-BvNmFk51.js +0 -25
- package/dist/engine-CNHvTgpw.js +0 -1122
- package/dist/errors-W8zkvPw4.js +0 -21
- package/dist/morph-svg-DRjl9Hfz.js +0 -62
- package/dist/rolldown-runtime-Dy4uBu1J.js +0 -11
- package/dist/sequence-CF5hazqz.js +0 -198
- package/dist/springTimingFunction-CDHZ00JQ.js +0 -63
- package/dist/timeline-B7SV3T_E.js +0 -442
- package/dist/utils-D7nuAND5.js +0 -97
- package/dist/validate-8r6Yo-uc.js +0 -35
package/dist/keyframes.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { n as b, t as x } from "./decay-BvNmFk51.js";
|
|
5
|
-
import { t as S } from "./sequence-CF5hazqz.js";
|
|
6
|
-
//#region src/animation/numeric.ts
|
|
7
|
-
var C = new Float64Array(), w = class {
|
|
1
|
+
import { _ as e, a as t, b as n, c as r, f as i, h as a, i as o, l as s, m as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h, v as g, y as _ } from "./sequence-C_DCiOIQ.js";
|
|
2
|
+
//#region src/animation/physics/numeric.ts
|
|
3
|
+
var v = new Float64Array(), y = class {
|
|
8
4
|
keyframes;
|
|
9
5
|
segments;
|
|
10
6
|
positions;
|
|
@@ -12,15 +8,15 @@ var C = new Float64Array(), w = class {
|
|
|
12
8
|
_duration;
|
|
13
9
|
_respectReducedMotion;
|
|
14
10
|
_easingFn;
|
|
15
|
-
_playback = new
|
|
16
|
-
constructor(e,
|
|
11
|
+
_playback = new s();
|
|
12
|
+
constructor(e, t) {
|
|
17
13
|
if (e.length < 2) throw Error("NumericAnimation requires at least 2 keyframes.");
|
|
18
|
-
this.keyframes = e.map((e) => ({ ...e })), this._duration =
|
|
19
|
-
let
|
|
20
|
-
if (typeof
|
|
21
|
-
if (this._easingFn =
|
|
22
|
-
if (
|
|
23
|
-
this.positions =
|
|
14
|
+
this.keyframes = e.map((e) => ({ ...e })), this._duration = t?.duration ?? 0, this._respectReducedMotion = t?.respectReducedMotion ?? !1;
|
|
15
|
+
let n = t?.timingFunction;
|
|
16
|
+
if (typeof n == "string") throw new _("timingFunction", n, "NumericAnimation accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
|
|
17
|
+
if (this._easingFn = n == null ? (e) => e : g(n).fn, t?.positions) {
|
|
18
|
+
if (t.positions.length !== e.length) throw Error("positions length must match keyframes length.");
|
|
19
|
+
this.positions = t.positions;
|
|
24
20
|
} else this.positions = e.map((t, n) => n / (e.length - 1) * 100);
|
|
25
21
|
this.result = { ...e[0] }, this.segments = this.buildSegments();
|
|
26
22
|
}
|
|
@@ -45,12 +41,12 @@ var C = new Float64Array(), w = class {
|
|
|
45
41
|
};
|
|
46
42
|
}
|
|
47
43
|
at(e) {
|
|
48
|
-
let t =
|
|
44
|
+
let t = i(e, 0, 1) * 100, n = a(this.segments, t, (e) => e.startPos, (e) => e.stopPos);
|
|
49
45
|
n === -1 && (n = this.segments.length - 1);
|
|
50
|
-
let r = this.segments[n],
|
|
51
|
-
|
|
52
|
-
let
|
|
53
|
-
for (let e = 0; e <
|
|
46
|
+
let r = this.segments[n], o = c(i(t, r.startPos, r.stopPos), r.startPos, r.stopPos, 0, 1), s = r.timingFunction(o), l = r.keys.length;
|
|
47
|
+
v.length < l && (v = new Float64Array(l)), d(r.from, r.to, s, v);
|
|
48
|
+
let u = this.result;
|
|
49
|
+
for (let e = 0; e < l; e++) u[r.keys[e]] = v[e];
|
|
54
50
|
return this.result;
|
|
55
51
|
}
|
|
56
52
|
updateKeyframe(e, t) {
|
|
@@ -67,7 +63,24 @@ var C = new Float64Array(), w = class {
|
|
|
67
63
|
stop() {
|
|
68
64
|
this._playback.stop();
|
|
69
65
|
}
|
|
70
|
-
}
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/animation/physics/spring/reseat.ts
|
|
69
|
+
function b(e) {
|
|
70
|
+
let t = e.curr.time - e.prev.time;
|
|
71
|
+
return t <= 0 ? 0 : (e.curr.value - e.prev.value) / (t / 1e3);
|
|
72
|
+
}
|
|
73
|
+
function x(e, t, n) {
|
|
74
|
+
let r = b(e), i = new p({
|
|
75
|
+
...n,
|
|
76
|
+
initial: e.curr.value,
|
|
77
|
+
initialVelocity: r
|
|
78
|
+
});
|
|
79
|
+
return i.target = t, i;
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/animation/physics/morph.ts
|
|
83
|
+
var S = (e) => {
|
|
71
84
|
if (e instanceof HTMLElement) {
|
|
72
85
|
let t = e.getBoundingClientRect();
|
|
73
86
|
return {
|
|
@@ -78,7 +91,7 @@ var C = new Float64Array(), w = class {
|
|
|
78
91
|
};
|
|
79
92
|
}
|
|
80
93
|
return e;
|
|
81
|
-
},
|
|
94
|
+
}, C = class {
|
|
82
95
|
animation;
|
|
83
96
|
transformOrigin;
|
|
84
97
|
timingFunction;
|
|
@@ -87,8 +100,8 @@ var C = new Float64Array(), w = class {
|
|
|
87
100
|
this.transformOrigin = n?.transformOrigin ?? "top left", this.timingFunction = n?.timingFunction, this.duration = n?.duration ?? 0, this.measure(e, t);
|
|
88
101
|
}
|
|
89
102
|
measure(e, t) {
|
|
90
|
-
let n =
|
|
91
|
-
return this.animation = new
|
|
103
|
+
let n = S(e), r = S(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;
|
|
104
|
+
return this.animation = new y([{
|
|
92
105
|
translateX: 0,
|
|
93
106
|
translateY: 0,
|
|
94
107
|
scaleX: 1,
|
|
@@ -122,6 +135,71 @@ var C = new Float64Array(), w = class {
|
|
|
122
135
|
stop() {
|
|
123
136
|
this.animation.stop();
|
|
124
137
|
}
|
|
138
|
+
}, w = class {
|
|
139
|
+
smoother;
|
|
140
|
+
_easingFn;
|
|
141
|
+
currentProgress = 0;
|
|
142
|
+
boundaryEpsilon;
|
|
143
|
+
constructor(e) {
|
|
144
|
+
this.boundaryEpsilon = e?.boundaryEpsilon ?? .005;
|
|
145
|
+
let t = e?.easing;
|
|
146
|
+
if (typeof t == "string") throw new _("easing", t, "Timeline accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
|
|
147
|
+
this._easingFn = t == null ? (e) => e : g(t).fn, e?.smoothing === !1 ? this.smoother = null : this.smoother = new r(e?.smoothing);
|
|
148
|
+
}
|
|
149
|
+
applyPipeline() {
|
|
150
|
+
let e = i(this.sample(), 0, 1);
|
|
151
|
+
e = this._easingFn(e);
|
|
152
|
+
let t = this.boundaryEpsilon;
|
|
153
|
+
return e <= t ? e = 0 : e >= 1 - t && (e = 1), e;
|
|
154
|
+
}
|
|
155
|
+
_advance(e) {
|
|
156
|
+
let t = this.applyPipeline();
|
|
157
|
+
return this.smoother ? (this.smoother.setTarget(t), t <= 0 || t >= 1 ? this.smoother.snap() : this.smoother.tickDt(e), this.currentProgress = this.smoother.current) : this.currentProgress = t, this.currentProgress;
|
|
158
|
+
}
|
|
159
|
+
tick() {
|
|
160
|
+
return this._advance(16.667);
|
|
161
|
+
}
|
|
162
|
+
tickDt(e) {
|
|
163
|
+
return this._advance(e);
|
|
164
|
+
}
|
|
165
|
+
get progress() {
|
|
166
|
+
return this.currentProgress;
|
|
167
|
+
}
|
|
168
|
+
get settled() {
|
|
169
|
+
return this.smoother == null || this.smoother.settled;
|
|
170
|
+
}
|
|
171
|
+
snap() {
|
|
172
|
+
this.smoother?.snap(), this.smoother && (this.currentProgress = this.smoother.current);
|
|
173
|
+
}
|
|
174
|
+
reset(e) {
|
|
175
|
+
let t = e ?? 0;
|
|
176
|
+
this.smoother && this.smoother.reset(t), this.currentProgress = t;
|
|
177
|
+
}
|
|
178
|
+
}, T = class extends w {
|
|
179
|
+
threshold;
|
|
180
|
+
getScrollY;
|
|
181
|
+
getViewportHeight;
|
|
182
|
+
constructor(e) {
|
|
183
|
+
super(e), this.threshold = e?.threshold ?? .35, this.getScrollY = e?.getScrollY ?? (() => window.scrollY), this.getViewportHeight = e?.getViewportHeight ?? (() => window.innerHeight);
|
|
184
|
+
}
|
|
185
|
+
sample() {
|
|
186
|
+
let e = this.getViewportHeight() * this.threshold;
|
|
187
|
+
return e <= 0 ? 0 : this.getScrollY() / e;
|
|
188
|
+
}
|
|
189
|
+
}, E = class extends w {
|
|
190
|
+
value = 0;
|
|
191
|
+
constructor(e) {
|
|
192
|
+
super({
|
|
193
|
+
smoothing: !1,
|
|
194
|
+
...e
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
set(e) {
|
|
198
|
+
this.value = e;
|
|
199
|
+
}
|
|
200
|
+
sample() {
|
|
201
|
+
return this.value;
|
|
202
|
+
}
|
|
125
203
|
}, D = 2 * Math.PI;
|
|
126
204
|
function O(e, t) {
|
|
127
205
|
let n = e - Math.floor(e);
|
|
@@ -153,34 +231,34 @@ var k = class {
|
|
|
153
231
|
this.phase = e - Math.floor(e);
|
|
154
232
|
}
|
|
155
233
|
}, A = (e, t) => {
|
|
156
|
-
if (typeof e == "number") return
|
|
234
|
+
if (typeof e == "number") return i(e, 0, Math.max(0, t - 1));
|
|
157
235
|
switch (e) {
|
|
158
236
|
case "first": return 0;
|
|
159
237
|
case "last": return t - 1;
|
|
160
238
|
case "center": return (t - 1) / 2;
|
|
161
239
|
case "edges": return -1;
|
|
162
240
|
}
|
|
163
|
-
},
|
|
241
|
+
}, j = (e, t, n) => n === "edges" ? Math.min(e, t - 1 - e) : Math.abs(e - A(n, t)), M = (e, t) => {
|
|
164
242
|
if (e <= 1) return 0;
|
|
165
243
|
if (t === "edges") return Math.floor((e - 1) / 2);
|
|
166
244
|
let n = A(t, e);
|
|
167
245
|
return Math.max(n, e - 1 - n);
|
|
168
246
|
};
|
|
169
|
-
function
|
|
170
|
-
let { each:
|
|
171
|
-
if (typeof
|
|
172
|
-
let
|
|
247
|
+
function N(e, t = {}) {
|
|
248
|
+
let { each: n = 100, from: r = "first", ease: i } = t;
|
|
249
|
+
if (typeof i == "string") throw new _("ease", i, "stagger accepts a callable TimingFunction or a typed Easing; resolve a string name first via `await resolveEasing(name)`.");
|
|
250
|
+
let a = i ? g(i).fn : void 0, o = typeof e == "number" ? e : e.length, s = (e, t) => {
|
|
173
251
|
if (t <= 1) return 0;
|
|
174
|
-
let
|
|
175
|
-
if (
|
|
176
|
-
let
|
|
177
|
-
return
|
|
178
|
-
},
|
|
179
|
-
return
|
|
252
|
+
let i = M(t, r);
|
|
253
|
+
if (i === 0) return 0;
|
|
254
|
+
let o = j(e, t, r);
|
|
255
|
+
return a ? a(o / i) * n * i : o * n;
|
|
256
|
+
}, c = ((e, t = o) => s(e, t));
|
|
257
|
+
return c.delays = (e = o) => Array.from({ length: e }, (t, n) => s(n, e)), c;
|
|
180
258
|
}
|
|
181
259
|
//#endregion
|
|
182
|
-
//#region src/animation/flip.ts
|
|
183
|
-
var
|
|
260
|
+
//#region src/animation/orchestration/flip.ts
|
|
261
|
+
var P = 300, F = (e) => {
|
|
184
262
|
let t = e.getBoundingClientRect();
|
|
185
263
|
return {
|
|
186
264
|
x: t.x,
|
|
@@ -188,21 +266,21 @@ var N = 300, P = (e) => {
|
|
|
188
266
|
width: t.width,
|
|
189
267
|
height: t.height
|
|
190
268
|
};
|
|
191
|
-
},
|
|
269
|
+
}, I = (e, t) => {
|
|
192
270
|
let n = e.at(1), r = n.translateX, i = n.translateY, a = n.scaleX, o = n.scaleY, s = e.at(t);
|
|
193
271
|
return `translate(${s.translateX - r}px, ${s.translateY - i}px) scale(${a === 0 ? 1 : s.scaleX / a}, ${o === 0 ? 1 : s.scaleY / o})`;
|
|
194
|
-
},
|
|
195
|
-
e.style.transform =
|
|
272
|
+
}, L = (e, t, n, r) => (e.style.transformOrigin = r, e.style.transform = I(t, 0), n <= 0 ? (e.style.transform = I(t, 1), Promise.resolve()) : new s().play(n, (n) => {
|
|
273
|
+
e.style.transform = I(t, n);
|
|
196
274
|
}));
|
|
197
|
-
function
|
|
198
|
-
let { duration: r =
|
|
199
|
-
return t(),
|
|
275
|
+
function R(e, t, n = {}) {
|
|
276
|
+
let { duration: r = P, timingFunction: i, transformOrigin: a = "top left" } = n, o = F(e);
|
|
277
|
+
return t(), L(e, new C(o, F(e), {
|
|
200
278
|
...i === void 0 ? {} : { timingFunction: i },
|
|
201
279
|
transformOrigin: a
|
|
202
280
|
}), r, a);
|
|
203
281
|
}
|
|
204
|
-
function
|
|
205
|
-
let { duration: r =
|
|
282
|
+
function z(e, t, n = {}) {
|
|
283
|
+
let { duration: r = P, timingFunction: i, transformOrigin: a = "top left" } = n, o = new C(F(e), F(t), {
|
|
206
284
|
...i === void 0 ? {} : { timingFunction: i },
|
|
207
285
|
duration: r,
|
|
208
286
|
transformOrigin: a
|
|
@@ -210,48 +288,7 @@ function R(e, t, n = {}) {
|
|
|
210
288
|
return o.apply(e, 0), r <= 0 ? (o.apply(e, 1), Promise.resolve()) : o.play(e, r);
|
|
211
289
|
}
|
|
212
290
|
//#endregion
|
|
213
|
-
//#region src/animation/drag
|
|
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
|
|
254
|
-
//#region src/animation/drag.ts
|
|
291
|
+
//#region src/animation/orchestration/drag/draggable.ts
|
|
255
292
|
var B = 100, V = .4, H = 5, U = class {
|
|
256
293
|
spring;
|
|
257
294
|
axis;
|
|
@@ -269,7 +306,7 @@ var B = 100, V = .4, H = 5, U = class {
|
|
|
269
306
|
onPointerMove = (e) => this.handleMove(e);
|
|
270
307
|
onPointerUp = (e) => this.handleUp(e);
|
|
271
308
|
constructor(e) {
|
|
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
|
|
309
|
+
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 p(e?.springOptions);
|
|
273
310
|
}
|
|
274
311
|
get dragging() {
|
|
275
312
|
return this.capturedPointerId !== void 0;
|
|
@@ -329,17 +366,17 @@ var B = 100, V = .4, H = 5, U = class {
|
|
|
329
366
|
this.pushSample(n, e.timeStamp);
|
|
330
367
|
let r = this.estimateVelocity();
|
|
331
368
|
if (t && this.endGesture(t), this.snap) {
|
|
332
|
-
let e =
|
|
369
|
+
let e = f({
|
|
333
370
|
initial: n,
|
|
334
371
|
velocity: r,
|
|
335
372
|
friction: H
|
|
336
373
|
}), t = this.nearestSnap(e);
|
|
337
|
-
this.bounds && (t =
|
|
374
|
+
this.bounds && (t = i(t, this.bounds.min, this.bounds.max)), this.spring.reset(n, r), this.spring.target = t;
|
|
338
375
|
return;
|
|
339
376
|
}
|
|
340
377
|
if (this.spring.reset(n, r), this.bounds) {
|
|
341
378
|
let e = this.spring.value;
|
|
342
|
-
(e < this.bounds.min || e > this.bounds.max) && (this.spring.target =
|
|
379
|
+
(e < this.bounds.min || e > this.bounds.max) && (this.spring.target = i(e, this.bounds.min, this.bounds.max));
|
|
343
380
|
}
|
|
344
381
|
}
|
|
345
382
|
nearestSnap(e) {
|
|
@@ -374,42 +411,64 @@ function W(e, t) {
|
|
|
374
411
|
return n.attach(e), n;
|
|
375
412
|
}
|
|
376
413
|
//#endregion
|
|
414
|
+
//#region src/animation/orchestration/drag/drag-2d.ts
|
|
415
|
+
function G(e, t) {
|
|
416
|
+
let n = new U({
|
|
417
|
+
...t?.x,
|
|
418
|
+
axis: "x"
|
|
419
|
+
}), r = new U({
|
|
420
|
+
...t?.y,
|
|
421
|
+
axis: "y"
|
|
422
|
+
});
|
|
423
|
+
n.attach(e), r.attach(e);
|
|
424
|
+
let i = /* @__PURE__ */ new Set(), a = (e) => e.dragging ? e.spring.target : e.spring.value, o = () => {
|
|
425
|
+
let e = a(n), t = a(r), o = n.velocity, s = r.velocity;
|
|
426
|
+
for (let n of i) n(e, t, o, s);
|
|
427
|
+
}, s = n.subscribe(() => o()), c = r.subscribe(() => o());
|
|
428
|
+
return {
|
|
429
|
+
x: n,
|
|
430
|
+
y: r,
|
|
431
|
+
get value() {
|
|
432
|
+
return {
|
|
433
|
+
x: a(n),
|
|
434
|
+
y: a(r)
|
|
435
|
+
};
|
|
436
|
+
},
|
|
437
|
+
get velocity() {
|
|
438
|
+
return {
|
|
439
|
+
x: n.velocity,
|
|
440
|
+
y: r.velocity
|
|
441
|
+
};
|
|
442
|
+
},
|
|
443
|
+
get settled() {
|
|
444
|
+
return n.settled && r.settled;
|
|
445
|
+
},
|
|
446
|
+
subscribe(e) {
|
|
447
|
+
return i.add(e), () => i.delete(e);
|
|
448
|
+
},
|
|
449
|
+
dispose() {
|
|
450
|
+
i.clear(), s(), c(), n.dispose(), r.dispose();
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
//#endregion
|
|
377
455
|
//#region src/animation/load-engine.ts
|
|
378
|
-
var
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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-CuUJt2Tb.js"),
|
|
400
|
-
import("./motion-path-J-RSNmRQ.js"),
|
|
401
|
-
import("./draw-svg-DYRDxBlL.js"),
|
|
402
|
-
import("./morph-svg-DRjl9Hfz.js"),
|
|
403
|
-
q ??= import("./ingest-CNM5xkQT.js"),
|
|
404
|
-
J ??= import("./scroll-scene-CXEgM49Q.js"),
|
|
405
|
-
K ??= import("./compile-DgNRG6Lo.js"),
|
|
406
|
-
import("./validate-8r6Yo-uc.js"),
|
|
407
|
-
import("./animations-5nf2kBkv.js"),
|
|
408
|
-
import("./format-BUgCTjmr.js").then((e) => e.r),
|
|
409
|
-
import("./utils-D7nuAND5.js").then((e) => e.o),
|
|
410
|
-
import("./scheduler-7eIr_q1g.js").then((e) => e.t)
|
|
456
|
+
var K = null, q = () => K ??= import("./engine-DrBtsKaf.js"), J = null, Y = () => J ??= Promise.all([
|
|
457
|
+
q(),
|
|
458
|
+
import("./group-vJcsHKN9.js").then((e) => e.t),
|
|
459
|
+
import("./motion-path-pQVbamWT.js").then((e) => e.r),
|
|
460
|
+
import("./draw-svg-GURj9nin.js").then((e) => e.n),
|
|
461
|
+
import("./morph-svg-BToeumw5.js").then((e) => e.r),
|
|
462
|
+
import("./ingest-S5hUe20K.js").then((e) => e.t),
|
|
463
|
+
import("./scroll-CxpYFO4u.js").then((e) => e.t),
|
|
464
|
+
import("./compile-CcSUwM8R.js").then((e) => e.t),
|
|
465
|
+
import("./validate-DDeGnvSt.js").then((e) => e.r),
|
|
466
|
+
import("./presets-BG2Fczzq.js").then((e) => e.t),
|
|
467
|
+
import("./format-C-Gi9r7L.js").then((e) => e.o),
|
|
468
|
+
import("./parse-flatten-DRMHFytp.js"),
|
|
469
|
+
import("./scheduler-CUtVnuoU.js").then((e) => e.t)
|
|
411
470
|
]).then(([e, t, n, r, i, a, o, s, c, l, u, d, f]) => Object.assign({
|
|
412
|
-
|
|
471
|
+
AnimationGroup: t.AnimationGroup,
|
|
413
472
|
MotionPath: n.MotionPath,
|
|
414
473
|
fromMotionPath: n.fromMotionPath,
|
|
415
474
|
DrawSVG: r.DrawSVG,
|
|
@@ -439,8 +498,8 @@ var G = null, K = null, q = null, J = null, Y = () => G ??= import("./engine-CNH
|
|
|
439
498
|
formatCSSKeyframeString: u.formatCSSKeyframeString,
|
|
440
499
|
transformTargetsStyle: d.transformTargetsStyle,
|
|
441
500
|
yieldToMain: f.yieldToMain
|
|
442
|
-
}, e)),
|
|
443
|
-
|
|
501
|
+
}, e)), X = () => {
|
|
502
|
+
Y();
|
|
444
503
|
};
|
|
445
504
|
//#endregion
|
|
446
|
-
export {
|
|
505
|
+
export { _ as AnimationOptionError, U as Draggable, C as ElementMorph, T as KeyframesScrollTimeline, E as ManualTimeline, y as NumericAnimation, k as Oscillator, s as RAFPlayback, m as Sequence, r as SmoothProgress, p as SpringProgress, w as Timeline, n as UnknownEasingError, o as createNativeTimeline, l as decay, f as decayRest, W as drag, G as drag2D, R as flip, z as flipShared, Y as loadAnimationEngine, b as probeVelocity, h as reducedMotionScale, x as reseatToSpring, e as resolveEasing, u as springLinearStops, t as springTimingFunction, N as stagger, g as toEasing, X as warmEngine, O as waveformValue };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { n as e } from "./presets-BG2Fczzq.js";
|
|
2
|
+
import { y as t } from "./sequence-C_DCiOIQ.js";
|
|
3
|
+
import { t as n } from "./engine-DEVgCTUy.js";
|
|
4
|
+
import { PathGeometry as r } from "@mkbabb/value.js";
|
|
5
|
+
//#region src/animation/svg/morph-svg.ts
|
|
6
|
+
var i = /* @__PURE__ */ e({
|
|
7
|
+
MorphSVG: () => m,
|
|
8
|
+
fromMorphSVG: () => p
|
|
9
|
+
}), a = 64, o = (e) => `--morph-${e}-x`, s = (e) => `--morph-${e}-y`, c = (e) => `--morph-${e}-angle`, l = (e, t, n) => {
|
|
10
|
+
let r = Array(t + 1);
|
|
11
|
+
for (let i = 0; i <= t; i++) if (n) {
|
|
12
|
+
let n = e.sampleAtLength(e.totalLength * (i / t));
|
|
13
|
+
r[i] = {
|
|
14
|
+
x: n.x,
|
|
15
|
+
y: n.y,
|
|
16
|
+
angle: n.angle
|
|
17
|
+
};
|
|
18
|
+
} else r[i] = e.getPointAtT(i / t);
|
|
19
|
+
return r;
|
|
20
|
+
}, u = (e) => Number.isInteger(e) ? `${e}` : e.toFixed(3), d = (e) => {
|
|
21
|
+
if (e.length === 0) return "";
|
|
22
|
+
let t = `M ${u(e[0].x)} ${u(e[0].y)}`;
|
|
23
|
+
for (let n = 1; n < e.length; n++) t += ` L ${u(e[n].x)} ${u(e[n].y)}`;
|
|
24
|
+
return t;
|
|
25
|
+
}, f = (e, t) => {
|
|
26
|
+
let n = Array(t + 1);
|
|
27
|
+
for (let e = 0; e <= t; e++) n[e] = {
|
|
28
|
+
x: 0,
|
|
29
|
+
y: 0
|
|
30
|
+
};
|
|
31
|
+
return (r) => {
|
|
32
|
+
let i = r;
|
|
33
|
+
for (let e = 0; e <= t; e++) {
|
|
34
|
+
let t = n[e], r = i[o(e)]?.[0]?.value, a = i[s(e)]?.[0]?.value;
|
|
35
|
+
if (r === void 0 || a === void 0) throw Error(`morph render: point ${e} lost its coordinate leaf (engine invariant violated — xKey/yKey seeded at construction)`);
|
|
36
|
+
t.x = r, t.y = a;
|
|
37
|
+
}
|
|
38
|
+
let a = d(n);
|
|
39
|
+
e.style.setProperty("--morph-d", a), e.style.setProperty("d", `path("${a}")`);
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
function p(e, i, u = {}) {
|
|
43
|
+
let { samples: d = a, target: p, orient: m = !1, autoPlay: h = !0, ...g } = u;
|
|
44
|
+
if (typeof e != "string" || e.length === 0) throw new t("from", e, "fromMorphSVG(): `from` must be a non-empty SVG path `d` string.");
|
|
45
|
+
if (typeof i != "string" || i.length === 0) throw new t("to", i, "fromMorphSVG(): `to` must be a non-empty SVG path `d` string.");
|
|
46
|
+
if (!Number.isInteger(d) || d < 2) throw new t("samples", d, "fromMorphSVG(): `samples` must be an integer >= 2 (a 1-sample morph is just the two endpoints, with no body to interpolate).");
|
|
47
|
+
let _ = new r(e), v = new r(i);
|
|
48
|
+
if (_.totalLength === 0) throw new t("from", e, "fromMorphSVG(): the `from` path has zero arc-length — a morph between a zero-length path and anything is malformed input, not an identity animation.");
|
|
49
|
+
if (v.totalLength === 0) throw new t("to", i, "fromMorphSVG(): the `to` path has zero arc-length — a morph between a zero-length path and anything is malformed input, not an identity animation.");
|
|
50
|
+
let y = l(_, d, m), b = l(v, d, m), x = {}, S = {};
|
|
51
|
+
for (let e = 0; e <= d; e++) x[o(e)] = y[e].x, x[s(e)] = y[e].y, S[o(e)] = b[e].x, S[s(e)] = b[e].y, m && (x[c(e)] = y[e].angle ?? 0, S[c(e)] = b[e].angle ?? 0);
|
|
52
|
+
let C = {
|
|
53
|
+
"0%": x,
|
|
54
|
+
"100%": S
|
|
55
|
+
}, w = p == null ? void 0 : f(p, d), T = new n(g).fromKeyframes(C, w);
|
|
56
|
+
return h && T.play(), T;
|
|
57
|
+
}
|
|
58
|
+
var m = class {
|
|
59
|
+
animation;
|
|
60
|
+
samples;
|
|
61
|
+
constructor(e, t, n = {}) {
|
|
62
|
+
this.animation = p(e, t, n), this.samples = n.samples ?? a;
|
|
63
|
+
}
|
|
64
|
+
sampleD(e) {
|
|
65
|
+
let t = (e < 0 ? 0 : e > 1 ? 1 : e) * this.animation.options.duration, n = this.animation.interpFrames(t, !1), r = Array(this.samples + 1);
|
|
66
|
+
for (let e = 0; e <= this.samples; e++) {
|
|
67
|
+
let t = n[o(e)]?.[0]?.value, i = n[s(e)]?.[0]?.value;
|
|
68
|
+
r[e] = {
|
|
69
|
+
x: t ?? 0,
|
|
70
|
+
y: i ?? 0
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return d(r);
|
|
74
|
+
}
|
|
75
|
+
play() {
|
|
76
|
+
return this.animation.play();
|
|
77
|
+
}
|
|
78
|
+
pause() {
|
|
79
|
+
return this.animation.pause(), this;
|
|
80
|
+
}
|
|
81
|
+
stop() {
|
|
82
|
+
return this.animation.stop(), this;
|
|
83
|
+
}
|
|
84
|
+
get finished() {
|
|
85
|
+
return this.animation.finished;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
//#endregion
|
|
89
|
+
export { p as n, i as r, m as t };
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { n as e } from "./presets-BG2Fczzq.js";
|
|
2
|
+
import { t } from "./engine-DEVgCTUy.js";
|
|
3
|
+
//#region src/animation/svg/motion-path.ts
|
|
4
|
+
var n = /* @__PURE__ */ e({
|
|
5
|
+
MotionPath: () => a,
|
|
6
|
+
fromMotionPath: () => i
|
|
7
|
+
}), r = (e) => typeof e == "number" ? `${e}%` : e;
|
|
8
|
+
function i(e, n) {
|
|
9
|
+
let { path: i, from: a = "0%", to: o = "100%", rotate: s, autoPlay: c = !0, ...l } = n;
|
|
6
10
|
if (typeof i != "string" || i.length === 0) throw Error("fromMotionPath(): `path` is required — pass an offset-path value (a path()/ray()/url(#id) string).");
|
|
7
|
-
let u = Array.isArray(
|
|
11
|
+
let u = Array.isArray(e) ? e : [e];
|
|
8
12
|
for (let e of u) e.style.offsetPath = i, s !== void 0 && (e.style.offsetRotate = s);
|
|
9
13
|
let d = {
|
|
10
|
-
"0%": { "offset-distance":
|
|
11
|
-
"100%": { "offset-distance":
|
|
12
|
-
}, f = new
|
|
14
|
+
"0%": { "offset-distance": r(a) },
|
|
15
|
+
"100%": { "offset-distance": r(o) }
|
|
16
|
+
}, f = new t(l).fromKeyframes(d);
|
|
13
17
|
return f.setTargets(...u), c && f.play(), f;
|
|
14
18
|
}
|
|
15
|
-
var
|
|
19
|
+
var a = class {
|
|
16
20
|
animation;
|
|
17
21
|
constructor(e, t) {
|
|
18
|
-
this.animation =
|
|
22
|
+
this.animation = i(e, t);
|
|
19
23
|
}
|
|
20
24
|
play() {
|
|
21
25
|
return this.animation.play();
|
|
@@ -28,4 +32,4 @@ var r = class {
|
|
|
28
32
|
}
|
|
29
33
|
};
|
|
30
34
|
//#endregion
|
|
31
|
-
export {
|
|
35
|
+
export { i as n, n as r, a as t };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { FunctionValue as e, ValueArray as t, ValueUnit as n, flattenObject as r, functionIdentityValue as i, memoize as a, normalizeValueUnits as o, parseCSSSubValue as s, prepareInterpVar as c, unflattenObjectToString as l } from "@mkbabb/value.js";
|
|
2
|
+
//#region src/animation/compile/parse-flatten.ts
|
|
3
|
+
var u = (e) => e.fnName, d = (r, i) => {
|
|
4
|
+
if (r instanceof n) {
|
|
5
|
+
let e = r.clone();
|
|
6
|
+
return i !== void 0 && (e.fnName = i), [e];
|
|
7
|
+
}
|
|
8
|
+
if (r instanceof e) return r.values.flatMap((e) => d(e, r.name));
|
|
9
|
+
if (r instanceof t) return r.flatMap((e) => d(e, i));
|
|
10
|
+
throw TypeError(`Expected ValueUnit/FunctionValue/ValueArray, got ${typeof r}`);
|
|
11
|
+
}, f = (e) => {
|
|
12
|
+
let t = e.split(".").pop(), n = e.split(".").shift();
|
|
13
|
+
if (!t || !n) throw Error(`Invalid flattened key: ${e}`);
|
|
14
|
+
return {
|
|
15
|
+
mainKey: n,
|
|
16
|
+
childKey: t
|
|
17
|
+
};
|
|
18
|
+
}, p = (e, t, n) => (e.setProperty(t), n !== t && e.setSubProperty(n), e), m = a((e, t) => d(s(t, { subProperty: e })), {
|
|
19
|
+
maxCacheSize: 2048,
|
|
20
|
+
keyFn: (e, t) => `${e}:${t}`
|
|
21
|
+
});
|
|
22
|
+
function h(i) {
|
|
23
|
+
let a = r(i), o = (r, i) => {
|
|
24
|
+
let { childKey: a, mainKey: s } = f(r);
|
|
25
|
+
return i instanceof n ? p(new t(...d(i)), s, a) : i instanceof e ? p(new t(...i.values.flatMap((e) => d(o(r, e), i.name))), s, a) : i instanceof t ? p(new t(...i.flatMap((e) => d(o(r, e)))), s, a) : p(new t(...m(a, String(i)).map((e) => e.clone())), s, a);
|
|
26
|
+
};
|
|
27
|
+
return Object.entries(a).reduce((e, [t, n]) => (e[t] = o(t, n), e), {});
|
|
28
|
+
}
|
|
29
|
+
var g = (e, t, r, a, s = "oklab", l) => {
|
|
30
|
+
let d = a[t], f = a[r];
|
|
31
|
+
if (!d || !f) throw Error(`Invalid interpolation frame bounds (${t} -> ${r}).`);
|
|
32
|
+
let p = d[e], m = f[e];
|
|
33
|
+
if (!p || !m) throw Error(`Missing variable "${e}" in interpolation bounds.`);
|
|
34
|
+
let h = Math.max(p.length, m.length), g = (t, r) => {
|
|
35
|
+
let a = t.map((t) => {
|
|
36
|
+
if (!(t instanceof n)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
|
|
37
|
+
return t;
|
|
38
|
+
});
|
|
39
|
+
for (; a.length < h;) {
|
|
40
|
+
let e = r[a.length], t = e instanceof n ? u(e) : void 0, o = t ? i(t) : void 0;
|
|
41
|
+
a.push(o ?? new n(0));
|
|
42
|
+
}
|
|
43
|
+
return a;
|
|
44
|
+
}, _ = g(p, m), v = g(m, p);
|
|
45
|
+
return _.map((t, r) => {
|
|
46
|
+
let i = v[r];
|
|
47
|
+
if (!i) throw Error(`Missing right-hand interpolation value at index ${r}.`);
|
|
48
|
+
if (!(t instanceof n) || !(i instanceof n)) throw TypeError(`Interpolation for "${e}" requires ValueUnit leaves.`);
|
|
49
|
+
let a = { colorSpace: s };
|
|
50
|
+
return l !== void 0 && (a.hueMethod = l), c(o(t, i, a));
|
|
51
|
+
});
|
|
52
|
+
}, _ = {};
|
|
53
|
+
function v(e, t, n = !0) {
|
|
54
|
+
e = n ? e : r(e);
|
|
55
|
+
let i = l(e, _);
|
|
56
|
+
t.forEach((e) => {
|
|
57
|
+
Object.entries(i).forEach(([t, n]) => {
|
|
58
|
+
e.style.setProperty(t, n);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { h as n, v as r, g as t };
|