@mkbabb/keyframes.js 5.0.0 → 5.2.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.
Files changed (46) hide show
  1. package/README.md +112 -217
  2. package/dist/backward-color-BtbRcnna.js +108 -0
  3. package/dist/compile-BHCTPerD.js +30 -0
  4. package/dist/{waapi-D0ssxKy1.js → delegation-BQYCrP2p.js} +117 -99
  5. package/dist/{draw-svg-Dat9mHgi.js → draw-svg-CK9Qrly8.js} +18 -26
  6. package/dist/easing-registry-DHV2-5gA.js +27 -0
  7. package/dist/easing-registry-y1p9McFy.js +2 -0
  8. package/dist/easing-serialize-D4LZCB6i.js +21 -0
  9. package/dist/engine/index.d.ts +3139 -0
  10. package/dist/engine/index.js +16 -0
  11. package/dist/engine-CPK_udUQ.js +1172 -0
  12. package/dist/engine-DlpimZtM.js +3 -0
  13. package/dist/entry-D82NKUhP.js +148 -0
  14. package/dist/format-BdIvdLzG.js +114 -0
  15. package/dist/group-HM7N4uOE.js +390 -0
  16. package/dist/handle-D4xrf_ya.js +21 -0
  17. package/dist/{ingest-CU-kdYcM.js → ingest-_g6tfk2e.js} +62 -56
  18. package/dist/keyframes.d.ts +1156 -1099
  19. package/dist/keyframes.js +412 -132
  20. package/dist/morph-svg-KUrH9KnK.js +79 -0
  21. package/dist/motion-path-wM5tPfrY.js +26 -0
  22. package/dist/parse-flatten-DRMHFytp.js +2 -0
  23. package/dist/parse-flatten-ZZUSEQEL.js +63 -0
  24. package/dist/presets-DeDJYL4G.js +275 -0
  25. package/dist/{scheduler-7eIr_q1g.js → scheduler-CfGIC3GX.js} +1 -1
  26. package/dist/scroll-BEyCx0b_.js +287 -0
  27. package/dist/sequence-s0bL7Uul.js +736 -0
  28. package/dist/{validate-B1pE-Y_T.js → validate-xFZ_Ld1k.js} +17 -13
  29. package/dist/view-transition-BPJQxUTC.js +305 -0
  30. package/package.json +123 -84
  31. package/dist/animate-CTWr6K7j.js +0 -26
  32. package/dist/animations-CZxf0rep.js +0 -224
  33. package/dist/compile-YRJRdpKF.js +0 -251
  34. package/dist/decay-BvNmFk51.js +0 -25
  35. package/dist/engine-DQcb7CLW.js +0 -1349
  36. package/dist/errors-W8zkvPw4.js +0 -21
  37. package/dist/format-BUgCTjmr.js +0 -123
  38. package/dist/morph-svg-83uyYxoW.js +0 -84
  39. package/dist/motion-path-C0OHqcA3.js +0 -31
  40. package/dist/rolldown-runtime-Dy4uBu1J.js +0 -11
  41. package/dist/scroll-grammar-B4kPvGh5.js +0 -23
  42. package/dist/scroll-scene-DQxhxn9I.js +0 -176
  43. package/dist/sequence-cBr7thU8.js +0 -198
  44. package/dist/springTimingFunction-D26gPkAy.js +0 -63
  45. package/dist/timeline-vY3eD3Ax.js +0 -430
  46. package/dist/utils-BPRImVl5.js +0 -100
@@ -0,0 +1,287 @@
1
+ import { n as e } from "./presets-DeDJYL4G.js";
2
+ import { c as t, f as n, i as r, r as i, s as a } from "./sequence-s0bL7Uul.js";
3
+ import { i as o, r as s, t as c } from "./delegation-BQYCrP2p.js";
4
+ import { extractTimelineOptions as l, parseAnimationRange as u, parseAnimationTimeline as d, parseCSSStylesheet as f, serializeTimelineOptions as p } from "@mkbabb/value.js";
5
+ //#region src/animation/scroll/range.ts
6
+ var m = {
7
+ entry: o.entry,
8
+ cover: o.cover,
9
+ contain: o.contain,
10
+ exit: o.exit,
11
+ normal: {
12
+ start: 0,
13
+ end: 1
14
+ },
15
+ "entry-crossing": {
16
+ start: 0,
17
+ end: .25
18
+ },
19
+ "exit-crossing": {
20
+ start: .75,
21
+ end: 1
22
+ }
23
+ };
24
+ function h(e) {
25
+ if (e == null) return null;
26
+ let t = e.trim();
27
+ if (t.endsWith("%")) {
28
+ let e = Number.parseFloat(t.slice(0, -1));
29
+ return Number.isFinite(e) ? e / 100 : null;
30
+ }
31
+ return null;
32
+ }
33
+ function g(e, t) {
34
+ if (e == null) return t;
35
+ let n = h(e.offset);
36
+ if (n != null) {
37
+ if (e.phase != null && e.phase !== "normal") {
38
+ let t = m[e.phase];
39
+ return t.start + n * (t.end - t.start);
40
+ }
41
+ return n;
42
+ }
43
+ return e.phase == null ? t : m[e.phase].start;
44
+ }
45
+ function _(e) {
46
+ if (e == null) return {
47
+ start: 0,
48
+ end: 1
49
+ };
50
+ let t = g(e.start, 0), n = g(e.end, 1);
51
+ return n > t ? {
52
+ start: t,
53
+ end: n
54
+ } : {
55
+ start: 0,
56
+ end: 1
57
+ };
58
+ }
59
+ //#endregion
60
+ //#region src/animation/scroll/scene.ts
61
+ var v = class {
62
+ resolvedRange;
63
+ snapPoints;
64
+ snapSpring;
65
+ scrubSeconds;
66
+ smoother;
67
+ rawScroll = 0;
68
+ localProgress = 0;
69
+ wasInside = !1;
70
+ subscribers = new Map([["enter", /* @__PURE__ */ new Set()], ["leave", /* @__PURE__ */ new Set()]]);
71
+ constructor(e = {}) {
72
+ if (this.resolvedRange = _(e.range), this.scrubSeconds = e.scrub ?? 0, this.snapPoints = e.snap != null && e.snap.length > 0 ? e.snap : void 0, this.scrubSeconds > 0) {
73
+ let r = n(1 / (this.scrubSeconds * 60 + 1), .01, 1);
74
+ this.smoother = new t({
75
+ damping: r,
76
+ clamp: !0,
77
+ ...e.smoothing
78
+ });
79
+ }
80
+ this.snapPoints != null && (this.snapSpring = new a({ ...e.snapSpring }));
81
+ }
82
+ get range() {
83
+ return this.resolvedRange;
84
+ }
85
+ scrollProgress(e) {
86
+ this.rawScroll = n(e, 0, 1);
87
+ let { start: t, end: r } = this.resolvedRange, i = r - t, a = i > 0 ? n((this.rawScroll - t) / i, 0, 1) : 0, o = this.rawScroll >= t && this.rawScroll <= r;
88
+ return o && !this.wasInside && this.fire("enter", a), !o && this.wasInside && this.fire("leave", a), this.wasInside = o, this.smoother ? (this.smoother.setTarget(a), this.localProgress = this.smoother.current) : this.localProgress = a, this.localProgress;
89
+ }
90
+ tick(e) {
91
+ return this.smoother && (this.smoother.tickDt(e), this.localProgress = this.smoother.current), this.localProgress;
92
+ }
93
+ get progress() {
94
+ return this.localProgress;
95
+ }
96
+ get settled() {
97
+ return this.smoother == null || this.smoother.settled;
98
+ }
99
+ snapTo(e = 0) {
100
+ if (this.snapPoints == null || this.snapSpring == null) return null;
101
+ let t = n(i({
102
+ initial: this.localProgress,
103
+ velocity: e
104
+ }), 0, 1), r = this.snapPoints[0], a = Math.abs(t - r);
105
+ for (let e of this.snapPoints) {
106
+ let n = Math.abs(t - e);
107
+ n < a && (a = n, r = e);
108
+ }
109
+ return this.snapSpring.reset(this.localProgress, e), this.snapSpring.target = r, r;
110
+ }
111
+ tickSnap(e) {
112
+ return this.snapSpring && !this.snapSpring.settled && (this.snapSpring.tickDt(e), this.localProgress = this.snapSpring.value), this.localProgress;
113
+ }
114
+ on(e, t) {
115
+ let n = this.subscribers.get(e);
116
+ return n.add(t), () => n.delete(t);
117
+ }
118
+ fire(e, t) {
119
+ for (let n of this.subscribers.get(e)) n(t);
120
+ }
121
+ };
122
+ function y(e = {}) {
123
+ return new v(e);
124
+ }
125
+ //#endregion
126
+ //#region src/animation/scroll/dispatch.ts
127
+ function b(e) {
128
+ let { animation: t, nativeSpec: n, scrub: i, snap: a, velocity: o } = e;
129
+ if (i) return {
130
+ backend: "js",
131
+ reason: "scrub smoothing requested (native scroll has no SmoothProgress smoother)"
132
+ };
133
+ if (a) return {
134
+ backend: "js",
135
+ reason: "physics snap requested (native scroll has no decay/spring settle)"
136
+ };
137
+ if (o) return {
138
+ backend: "js",
139
+ reason: "scroll velocity / non-DOM driving requested (JS-only capability)"
140
+ };
141
+ if (t == null || n == null) return {
142
+ backend: "js",
143
+ reason: "non-DOM target or no native timeline spec (the universal JS driver)"
144
+ };
145
+ let l = s(t);
146
+ if (!l.eligible) return {
147
+ backend: "js",
148
+ reason: l.reason
149
+ };
150
+ if (r(n) == null) return {
151
+ backend: "js",
152
+ reason: "native scroll/view timeline unavailable (feature absent)"
153
+ };
154
+ let u = c(t, n);
155
+ return u.attached ? {
156
+ backend: "native",
157
+ attachment: u
158
+ } : {
159
+ backend: "js",
160
+ reason: u.reason
161
+ };
162
+ }
163
+ function x(e) {
164
+ let t = ["position: sticky;"];
165
+ return e?.bottom == null ? t.push(`top: ${e?.top ?? 0}px;`) : t.push(`bottom: ${e.bottom}px;`), t.join(" ");
166
+ }
167
+ //#endregion
168
+ //#region src/animation/scroll/trigger.ts
169
+ function S() {
170
+ let e = globalThis.CSS;
171
+ if (e == null || typeof e.supports != "function") return !1;
172
+ try {
173
+ return e.supports("animation-trigger-behavior", "once") || e.supports("animation-trigger", "once");
174
+ } catch {
175
+ return !1;
176
+ }
177
+ }
178
+ var C = class {
179
+ type;
180
+ triggerRange;
181
+ _state = "idle";
182
+ _direction = "forward";
183
+ _playhead = 0;
184
+ _cycles = 0;
185
+ wasInside = !1;
186
+ everEntered = !1;
187
+ constructor(e = {}) {
188
+ this.type = e.type ?? "once", this.triggerRange = _(e.range);
189
+ }
190
+ get state() {
191
+ return this._state;
192
+ }
193
+ get direction() {
194
+ return this._direction;
195
+ }
196
+ get playhead() {
197
+ return this._playhead;
198
+ }
199
+ get cycles() {
200
+ return this._cycles;
201
+ }
202
+ get range() {
203
+ return this.triggerRange;
204
+ }
205
+ get usesNative() {
206
+ return S();
207
+ }
208
+ triggerProgress(e) {
209
+ let t = n(e, 0, 1), { start: r, end: i } = this.triggerRange, a = i - r, o = a > 0 ? n((t - r) / a, 0, 1) : 0, s = t >= r && t <= i, c = s && !this.wasInside, l = !s && this.wasInside, u = l && t > i;
210
+ switch (this.type) {
211
+ case "repeat":
212
+ this.stepRepeat(s, c, l, o);
213
+ break;
214
+ case "alternate":
215
+ this.stepAlternate(s, c, l, o);
216
+ break;
217
+ case "state":
218
+ this.stepState(s, o);
219
+ break;
220
+ default:
221
+ this.stepOnce(c, u, o);
222
+ break;
223
+ }
224
+ return this.wasInside = s, this._state;
225
+ }
226
+ reset() {
227
+ this._state = "idle", this._direction = "forward", this._playhead = 0, this._cycles = 0, this.wasInside = !1, this.everEntered = !1;
228
+ }
229
+ stepOnce(e, t, n) {
230
+ this._state !== "done" && (e && this._state === "idle" && (this._state = "active", this._direction = "forward", this._cycles = 1), this._state === "active" && (this._playhead = n, t && (this._state = "done", this._playhead = 1)));
231
+ }
232
+ stepRepeat(e, t, n, r) {
233
+ t ? (this._state = "active", this._direction = "forward", this._cycles += 1, this._playhead = r) : n ? (this._state = "idle", this._playhead = 0) : e && (this._playhead = r);
234
+ }
235
+ stepAlternate(e, t, n, r) {
236
+ t ? (this._direction = this._cycles % 2 == 0 ? "forward" : "backward", this._state = "active", this._cycles += 1, this._playhead = this.directedPlayhead(r)) : n ? this._state = "done" : e && (this._playhead = this.directedPlayhead(r));
237
+ }
238
+ stepState(e, t) {
239
+ e ? (this._state = "active", this._direction = "forward", this._playhead = t, this.everEntered = !0) : this._state = this.everEntered ? "done" : "idle";
240
+ }
241
+ directedPlayhead(e) {
242
+ return this._direction === "forward" ? e : 1 - e;
243
+ }
244
+ };
245
+ function w(e = {}) {
246
+ return new C("trigger" in e && e.trigger != null ? e.trigger : e);
247
+ }
248
+ //#endregion
249
+ //#region src/animation/scroll/grammar.ts
250
+ function T(e) {
251
+ return d(e);
252
+ }
253
+ function E(e) {
254
+ return u(e);
255
+ }
256
+ function D(e) {
257
+ return l(typeof e == "string" ? f(e) : e);
258
+ }
259
+ function O(e) {
260
+ return p(e);
261
+ }
262
+ function k(e) {
263
+ let t = D(e);
264
+ return {
265
+ options: t,
266
+ declarations: O(t)
267
+ };
268
+ }
269
+ //#endregion
270
+ //#region src/animation/scroll/index.ts
271
+ var A = /* @__PURE__ */ e({
272
+ ScrollScene: () => v,
273
+ TriggerScene: () => C,
274
+ createScrollScene: () => y,
275
+ createTriggerScene: () => w,
276
+ dispatchScrollBackend: () => b,
277
+ parseScrollCSS: () => D,
278
+ parseScrollRange: () => E,
279
+ parseScrollTimeline: () => T,
280
+ pinCSS: () => x,
281
+ resolveRange: () => _,
282
+ roundTripScrollCSS: () => k,
283
+ serializeScrollOptions: () => O,
284
+ supportsNativeTrigger: () => S
285
+ });
286
+ //#endregion
287
+ export { k as a, w as c, x as d, v as f, T as i, S as l, _ as m, D as n, O as o, y as p, E as r, C as s, A as t, b as u };