@mkbabb/keyframes.js 3.0.0 → 4.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 CHANGED
@@ -282,14 +282,19 @@ The group manages its own `requestAnimationFrame` loop and marks child animation
282
282
 
283
283
  ## Presets
284
284
 
285
- 30+ ready-to-use animations in [`animations.ts`](src/animation/animations.ts). All return `CSSKeyframesAnimation` instances and accept optional `InputAnimationOptions`:
285
+ 30+ ready-to-use animations in [`animations.ts`](src/animation/animations.ts). All return `CSSKeyframesAnimation` instances and accept optional `InputAnimationOptions`. Each builds a value.js-bearing `CSSKeyframesAnimation`, so the presets ride the heavy dynamic boundary (the `presets` namespace on `loadAnimationEngine()`) rather than the value.js-free static barrel:
286
286
 
287
287
  ```ts
288
- import { fadeIn, bounce, spinner } from "@mkbabb/keyframes.js";
288
+ import { loadAnimationEngine } from "@mkbabb/keyframes.js";
289
289
 
290
- const anim = fadeIn({ duration: 500 });
290
+ const { presets } = await loadAnimationEngine();
291
+ const anim = presets.fadeIn({ duration: 500 });
291
292
  anim.setTargets(element);
292
293
  anim.play();
294
+
295
+ // …or the single-call front door (auto-target + auto-play):
296
+ const { animate } = await loadAnimationEngine();
297
+ animate(element, presets.fadeIn());
293
298
  ```
294
299
 
295
300
  **Fade**: `fadeIn`, `fadeOut` · **Attention**: `pulse`, `heartbeat`, `glow`, `shake`, `bounce` · **Entrance/Exit**: `flip`, `rotateIn`, `slideIn`, `slideInLeft/Right`, `slideOutLeft/Right`, `blurIn/Out/InOut`, `jumpUp/Down`, `warpLeft/Right` · **Effects**: `hover`, `typewriter`, `typingCursor`, `rainbowText`, `progressBar`, `skeletonLoading`, `spinner`, `parallaxScroll`, `gradientBackground`, `rotateScale`, `accordionExpand`, `notificationBounce`, `textFocusBlur`
@@ -0,0 +1,21 @@
1
+ import { CSSKeyframesAnimation as e } from "./engine-Cj0T6OIH.js";
2
+ import { fromMotionPath as t } from "./motion-path-683GcEZK.js";
3
+ //#region src/animation/animate.ts
4
+ var n = (e) => typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof Map) && typeof e.path == "string", r = (e) => e instanceof Map || typeof e == "object" && !!e && !Array.isArray(e);
5
+ function i(i, a, o) {
6
+ let { transform: s, autoPlay: c = !0, ...l } = o ?? {};
7
+ if (n(a)) return t(i, {
8
+ ...a,
9
+ ...l,
10
+ autoPlay: c
11
+ });
12
+ let u = new e(l);
13
+ if (typeof a == "string") u.fromString(a, s);
14
+ else if (Array.isArray(a)) u.fromVars(a, s);
15
+ else if (r(a)) u.fromKeyframes(a, s);
16
+ else throw Error("animate(): unrecognized input — pass a CSS @keyframes string, a keyframe map ({ \"0%\": {...} }), a vars array ([from, to]), or a MotionPath spec ({ path }).");
17
+ let d = Array.isArray(i) ? i : [i];
18
+ return u.setTargets(...d), c && u.play(), u;
19
+ }
20
+ //#endregion
21
+ export { i as animate };
@@ -0,0 +1,224 @@
1
+ import { t as e } from "./springTimingFunction-cMJnhbug.js";
2
+ import { CSSKeyframesAnimation as t } from "./engine-Cj0T6OIH.js";
3
+ import { CSSCubicBezier as n, steppedEase as r } from "@mkbabb/value.js";
4
+ //#region src/animation/animations.ts
5
+ var ee = "\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n", i = (e) => new t({
6
+ duration: 700,
7
+ timingFunction: "ease-in-out",
8
+ ...e ?? {}
9
+ }).fromString(ee), te = "\n from {\n opacity: 1;\n }\n to {\n opacity: 0;\n }\n", a = (e) => new t({
10
+ duration: 700,
11
+ timingFunction: "ease-in-out",
12
+ ...e ?? {}
13
+ }).fromString(te), ne = "\n 0%, 100% {\n transform: scale(1);\n }\n 50% {\n transform: scale(1.05);\n }\n", o = (e) => new t({
14
+ duration: 1e3,
15
+ timingFunction: "ease-in-out",
16
+ iterationCount: Infinity,
17
+ ...e ?? {}
18
+ }).fromString(ne), re = "\n8%,\n41% {\n transform: translateX(-10px);\n}\n25%,\n58% {\n transform: translateX(10px);\n}\n75% {\n transform: translateX(-5px);\n}\n92% {\n transform: translateX(5px);\n}\n0%,\n100% {\n transform: translateX(0);\n}\n", s = (e) => new t({
19
+ duration: 820,
20
+ timingFunction: "ease-in-out",
21
+ ...e ?? {}
22
+ }).fromString(re), c = "\n 0%, 20%, 50%, 80%, 100% {\n transform: translateY(0);\n }\n 40% {\n transform: translateY(-30px);\n }\n 60% {\n transform: translateY(-15px);\n }\n", l = (e) => new t({
23
+ duration: 1e3,
24
+ timingFunction: n(.28, .84, .42, 1),
25
+ ...e ?? {}
26
+ }).fromString(c), ie = "\n 0% {\n transform: perspective(400px) rotateY(0);\n animation-timing-function: ease-out;\n }\n 40% {\n transform: perspective(400px) translateZ(150px) rotateY(170deg);\n animation-timing-function: ease-out;\n }\n 50% {\n transform: perspective(400px) translateZ(150px) rotateY(190deg) scale(1);\n animation-timing-function: ease-in;\n }\n 80% {\n transform: perspective(400px) rotateY(360deg) scale(.95);\n animation-timing-function: ease-in;\n }\n 100% {\n transform: perspective(400px) scale(1);\n animation-timing-function: ease-in;\n }\n", u = (e) => new t({
27
+ duration: 1e3,
28
+ timingFunction: "ease-in-out",
29
+ ...e ?? {}
30
+ }).fromString(ie), ae = "\n 0% {\n transform-origin: center;\n transform: rotate3d(0, 0, 1, -200deg);\n opacity: 0;\n }\n 100% {\n transform-origin: center;\n transform: none;\n opacity: 1;\n }\n", d = (e) => new t({
31
+ duration: 1e3,
32
+ timingFunction: n(.25, .46, .45, .94),
33
+ ...e ?? {}
34
+ }).fromString(ae), oe = "\n 0% {\n transform: translateY(1000px);\n opacity: 0;\n }\n 100% {\n transform: translateY(0);\n opacity: 1;\n }\n", f = (e) => new t({
35
+ duration: 1e3,
36
+ timingFunction: n(.25, .46, .45, .94),
37
+ ...e ?? {}
38
+ }).fromString(oe), p = "\n 0% {\n transform: scale(1);\n }\n 14% {\n transform: scale(1.3);\n }\n 28% {\n transform: scale(1);\n }\n 42% {\n transform: scale(1.3);\n }\n 70% {\n transform: scale(1);\n }\n", m = (e) => new t({
39
+ duration: 1500,
40
+ timingFunction: "ease-in-out",
41
+ iterationCount: Infinity,
42
+ ...e ?? {}
43
+ }).fromString(p), h = "\n 0%, 100% {\n box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);\n }\n 50% {\n box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);\n }\n", g = (e) => new t({
44
+ duration: 2e3,
45
+ timingFunction: "ease-in-out",
46
+ iterationCount: Infinity,
47
+ ...e ?? {}
48
+ }).fromString(h), se = "\n 0% {\n width: 0;\n }\n 100% {\n width: 100%;\n }\n", ce = (e) => new t({
49
+ duration: 3e3,
50
+ timingFunction: r(40, "jump-end"),
51
+ fillMode: "forwards",
52
+ ...e ?? {}
53
+ }).fromString(se), le = "\n 0% {\n color: red;\n }\n 15% {\n color: orange;\n }\n 30% {\n color: yellow;\n }\n 45% {\n color: green;\n }\n 60% {\n color: blue;\n }\n 75% {\n color: indigo;\n }\n 90% {\n color: violet;\n }\n 100% {\n color: red;\n }\n", _ = (e) => new t({
54
+ duration: 5e3,
55
+ timingFunction: "linear",
56
+ iterationCount: Infinity,
57
+ ...e ?? {}
58
+ }).fromString(le), ue = "@keyframes keyframeDelete {\n 0% {\n transform: translateX(0%) rotate(0deg);\n opacity: 1;\n }\n 25% {\n transform: translateX(0%) rotate(5deg);\n opacity: 1;\n }\n 50% {\n transform: translateX(25%) rotate(10deg);\n opacity: 0.5;\n }\n 75% {\n transform: translateX(0%) rotate(0deg);\n opacity: 0.25;\n }\n 100% {\n transform: translateX(-100%);\n opacity: 0;\n }\n}", v = (e) => new t({
59
+ duration: 700,
60
+ timingFunction: "bounce-in-ease",
61
+ ...e ?? {}
62
+ }).fromString(ue), de = "@keyframes keyframeDelete {\n 0% {\n transform: translateX(0%) rotate(0deg);\n opacity: 1;\n }\n 25% {\n transform: translateX(0%) rotate(-5deg);\n opacity: 1;\n }\n 50% {\n transform: translateX(-25%) rotate(-10deg);\n opacity: 0.5;\n }\n 100% {\n transform: translateX(100%);\n opacity: 0;\n }\n}", y = (e) => new t({
63
+ duration: 700,
64
+ timingFunction: "bounce-in-ease",
65
+ ...e ?? {}
66
+ }).fromString(de), fe = "\n0% {\n filter: blur(10px);\n opacity: 0;\n}\n100% {\n filter: blur(0px);\n opacity: 1;\n}\n", b = (e) => new t({
67
+ duration: 2e3,
68
+ timingFunction: "ease-in-out",
69
+ ...e ?? {}
70
+ }).fromString(fe), pe = "\n0% {\n filter: blur(0px);\n opacity: 1;\n}\n100% {\n filter: blur(10px);\n opacity: 0;\n}\n", x = (e) => new t({
71
+ duration: 2e3,
72
+ timingFunction: "ease-in-out",
73
+ ...e ?? {}
74
+ }).fromString(pe), me = "\n0% {\n filter: blur(0px);\n}\n50% {\n filter: blur(10px);\n}\n100% {\n filter: blur(0px);\n}\n", he = (e) => new t({
75
+ duration: 2e3,
76
+ timingFunction: "ease-in-out",
77
+ ...e ?? {}
78
+ }).fromString(me), ge = "\n0% {\n width: 0%;\n background-color: #ff9999;\n}\n25% {\n width: 25%;\n background-color: #ffcc99;\n}\n50% {\n width: 50%;\n background-color: #ffff99;\n}\n75% {\n width: 75%;\n background-color: #99ff99;\n}\n100% {\n width: 100%;\n background-color: #99ccff;\n}\n", _e = (e) => new t({
79
+ duration: 3e3,
80
+ timingFunction: "linear",
81
+ fillMode: "forwards",
82
+ ...e ?? {}
83
+ }).fromString(ge), ve = "\n0% {\n background-position: -200% 0;\n}\n100% {\n background-position: 200% 0;\n}\n", S = (e) => new t({
84
+ duration: 1500,
85
+ timingFunction: "linear",
86
+ iterationCount: Infinity,
87
+ ...e ?? {}
88
+ }).fromString(ve), ye = "\n0%, 100% {\n filter: blur(0px);\n opacity: 1;\n}\n50% {\n filter: blur(4px);\n opacity: 0.5;\n}\n", be = (e) => new t({
89
+ duration: 2e3,
90
+ timingFunction: "ease-in-out",
91
+ ...e ?? {}
92
+ }).fromString(ye), xe = "\n0% {\n background-position: 0% 50%;\n}\n50% {\n background-position: 100% 50%;\n}\n100% {\n background-position: 0% 50%;\n}\n", C = (e) => new t({
93
+ duration: 5e3,
94
+ timingFunction: "ease-in-out",
95
+ iterationCount: Infinity,
96
+ ...e ?? {}
97
+ }).fromString(xe), w = "\n0% {\n transform: rotate(0deg) scale(1);\n}\n25% {\n transform: rotate(90deg) scale(1.1);\n}\n50% {\n transform: rotate(180deg) scale(1);\n}\n75% {\n transform: rotate(270deg) scale(0.9);\n}\n100% {\n transform: rotate(360deg) scale(1);\n}\n", T = (e) => new t({
98
+ duration: 2500,
99
+ timingFunction: n(.68, -.55, .265, 1.55),
100
+ ...e ?? {}
101
+ }).fromString(w), E = "\n0%, 100% {\n border-right-color: transparent;\n}\n50% {\n border-right-color: black;\n}\n", D = (e) => new t({
102
+ duration: 800,
103
+ timingFunction: r(2, "jump-start"),
104
+ iterationCount: Infinity,
105
+ ...e ?? {}
106
+ }).fromString(E), O = "\n0% {\n max-height: 0;\n opacity: 0;\n}\n100% {\n max-height: 1000px;\n opacity: 1;\n}\n", k = (e) => new t({
107
+ duration: 500,
108
+ timingFunction: n(.25, .46, .45, .94),
109
+ fillMode: "forwards",
110
+ ...e ?? {}
111
+ }).fromString(O), A = "\n0%, 100% {\n transform: translateY(0);\n}\n25% {\n transform: translateY(-10px);\n}\n50% {\n transform: translateY(0);\n}\n75% {\n transform: translateY(-5px);\n}\n", j = (e) => new t({
112
+ duration: 1e3,
113
+ timingFunction: n(.28, .84, .42, 1),
114
+ ...e ?? {}
115
+ }).fromString(A), M = "\n0% {\n transform: rotate(0deg);\n border-radius: 50%;\n}\n25% {\n transform: rotate(90deg);\n border-radius: 40% 60% 60% 40% / 40% 40% 60% 60%;\n}\n50% {\n transform: rotate(180deg);\n border-radius: 50%;\n}\n75% {\n transform: rotate(270deg);\n border-radius: 60% 40% 40% 60% / 60% 60% 40% 40%;\n}\n100% {\n transform: rotate(360deg);\n border-radius: 50%;\n}\n", N = (e) => new t({
116
+ duration: 2e3,
117
+ timingFunction: "linear",
118
+ iterationCount: Infinity,
119
+ ...e ?? {}
120
+ }).fromString(M), Se = "\n0% {\n background-position: 50% 0%;\n}\n100% {\n background-position: 50% 100%;\n}\n", P = (e) => new t({
121
+ duration: 1e4,
122
+ timingFunction: "linear",
123
+ iterationCount: Infinity,
124
+ ...e ?? {}
125
+ }).fromString(Se), F = "\n0% {\n transform: translateX(-100%);\n opacity: 0;\n}\n100% {\n transform: translateX(0);\n opacity: 1;\n}\n", I = (e) => new t({
126
+ duration: 1e3,
127
+ timingFunction: n(.25, .46, .45, .94),
128
+ ...e ?? {}
129
+ }).fromString(F), Ce = "\n0% {\n transform: translateX(0);\n opacity: 1;\n}\n100% {\n transform: translateX(-100%);\n opacity: 0;\n}\n", L = (e) => new t({
130
+ duration: 1e3,
131
+ timingFunction: n(.25, .46, .45, .94),
132
+ ...e ?? {}
133
+ }).fromString(Ce), R = "\n0% {\n transform: translateX(100%);\n opacity: 0;\n}\n100% {\n transform: translateX(0);\n opacity: 1;\n}\n", z = (e) => new t({
134
+ duration: 1e3,
135
+ timingFunction: n(.25, .46, .45, .94),
136
+ ...e ?? {}
137
+ }).fromString(R), we = "\n0% {\n transform: translateX(0%);\n opacity: 1;\n\n}\n100% {\n transform: translateX(100%);\n opacity: 0;\n}\n", B = (e) => new t({
138
+ duration: 1e3,
139
+ timingFunction: n(.25, .46, .45, .94),
140
+ ...e ?? {}
141
+ }).fromString(we), Te = "\n0% {\n transform: translateY(0px);\n}\n50% {\n transform: translateY(5px);\n}\n100% {\n transform: translateY(0px);\n}\n", V = (e) => new t({
142
+ duration: 3e3,
143
+ timingFunction: "ease-in-out",
144
+ iterationCount: Infinity,
145
+ fillMode: "none",
146
+ direction: "alternate",
147
+ ...e ?? {}
148
+ }).fromString(Te), Ee = "@keyframes keyframeShift {\n0% {\n transform: translateY(0%);\n opacity: 1;\n}\n\n50% {\n transform: translateY(-50%);\n opacity: 0.75;\n}\n\n100% {\n transform: translateY(-100%);\n opacity: 1;\n}\n}", H = (e) => new t({
149
+ duration: 700,
150
+ timingFunction: "bounce-in-ease",
151
+ ...e ?? {}
152
+ }).fromString(Ee), De = "@keyframes keyframeShift {\n0% {\n transform: translateY(0%);\n opacity: 1;\n}\n\n50% {\n transform: translateY(50%);\n opacity: 0.75;\n}\n\n100% {\n transform: translateY(100%);\n opacity: 1;\n}\n}", U = (e) => new t({
153
+ duration: 700,
154
+ timingFunction: "bounce-in-ease",
155
+ ...e ?? {}
156
+ }).fromString(De), Oe = {
157
+ response: .35,
158
+ dampingFraction: .78
159
+ }, W = {
160
+ response: .5,
161
+ dampingFraction: .5
162
+ }, ke = {
163
+ response: .7,
164
+ dampingFraction: .95
165
+ }, Ae = "\n 0% {\n transform: scale(0.6);\n opacity: 0;\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n", G = (n) => new t({
166
+ duration: 600,
167
+ timingFunction: e(W),
168
+ ...n ?? {}
169
+ }).fromString(Ae), je = "\n 0% {\n transform: translateY(40px);\n opacity: 0;\n }\n 100% {\n transform: translateY(0);\n opacity: 1;\n }\n", K = (n) => new t({
170
+ duration: 600,
171
+ timingFunction: e(Oe),
172
+ ...n ?? {}
173
+ }).fromString(je), Me = "\n 0%, 100% {\n transform: scale(1);\n }\n 50% {\n transform: scale(1.15);\n }\n", q = (n) => new t({
174
+ duration: 700,
175
+ timingFunction: e(W),
176
+ ...n ?? {}
177
+ }).fromString(Me), J = "\n 0%, 100% {\n transform: rotate(0deg);\n }\n 50% {\n transform: rotate(8deg);\n }\n", Y = (n) => new t({
178
+ duration: 800,
179
+ timingFunction: e(ke),
180
+ ...n ?? {}
181
+ }).fromString(J), X = {
182
+ fadeIn: i,
183
+ slideIn: f,
184
+ slideInLeft: I,
185
+ slideInRight: z,
186
+ rotateIn: d,
187
+ blurIn: b,
188
+ springScaleIn: G,
189
+ springSlideIn: K,
190
+ jumpUp: H
191
+ }, Z = {
192
+ fadeOut: a,
193
+ slideOutLeft: L,
194
+ slideOutRight: B,
195
+ blurOut: x,
196
+ warpLeft: v,
197
+ warpRight: y,
198
+ jumpDown: U
199
+ }, Q = {
200
+ pulse: o,
201
+ shake: s,
202
+ bounce: l,
203
+ flip: u,
204
+ notificationBounce: j,
205
+ springPop: q,
206
+ springWobble: Y
207
+ }, $ = {
208
+ heartbeat: m,
209
+ glow: g,
210
+ spinner: N,
211
+ rainbowText: _,
212
+ skeletonLoading: S,
213
+ gradientBackground: C,
214
+ parallaxScroll: P,
215
+ hover: V,
216
+ typingCursor: D
217
+ }, Ne = {
218
+ enter: X,
219
+ exit: Z,
220
+ attention: Q,
221
+ loop: $
222
+ };
223
+ //#endregion
224
+ export { k as accordionExpand, Q as attentionPresets, b as blurIn, he as blurInOut, x as blurOut, l as bounce, X as enterPresets, Z as exitPresets, i as fadeIn, a as fadeOut, u as flip, g as glow, C as gradientBackground, m as heartbeat, V as hover, U as jumpDown, H as jumpUp, $ as loopPresets, j as notificationBounce, P as parallaxScroll, Ne as presetTaxonomy, _e as progressBar, o as pulse, _ as rainbowText, d as rotateIn, T as rotateScale, s as shake, S as skeletonLoading, f as slideIn, I as slideInLeft, F as slideInLeftKeyframes, z as slideInRight, R as slideInRightKeyframes, L as slideOutLeft, B as slideOutRight, N as spinner, q as springPop, G as springScaleIn, K as springSlideIn, Y as springWobble, be as textFocusBlur, ce as typewriter, D as typingCursor, v as warpLeft, y as warpRight };
@@ -0,0 +1,41 @@
1
+ import { CSSKeyframesAnimation as e } from "./engine-Cj0T6OIH.js";
2
+ //#region src/animation/draw-svg.ts
3
+ var t = (e) => {
4
+ if (typeof e == "number") {
5
+ if (!Number.isFinite(e) || e < 0 || e > 1) throw Error(`fromDrawSVG(): a numeric draw position is a 0..1 fraction, got ${JSON.stringify(e)} — pass a fraction in [0, 1] or a percent string ("0%".."100%").`);
6
+ return e;
7
+ }
8
+ if (!/^\s*\d*\.?\d+\s*%\s*$/.test(e)) throw Error(`fromDrawSVG(): invalid draw position ${JSON.stringify(e)} — pass a percent string ("0%".."100%") or a 0..1 number.`);
9
+ return parseFloat(e) / 100;
10
+ };
11
+ function n(n, r = {}) {
12
+ let { from: i = "0%", to: a = "100%", autoPlay: o = !0, ...s } = r;
13
+ if (n == null || typeof n.getTotalLength != "function") throw Error("fromDrawSVG(): `target` must be an SVG geometry element exposing getTotalLength() (a <path>/<line>/<circle>/<rect>/<polygon>/…).");
14
+ let c = t(i), l = t(a), u = n.getTotalLength();
15
+ n.style.strokeDasharray = `${u}`;
16
+ let d = {
17
+ "0%": { "stroke-dashoffset": u * (1 - c) },
18
+ "100%": { "stroke-dashoffset": u * (1 - l) }
19
+ }, f = new e(s).fromKeyframes(d);
20
+ return f.setTargets(n), o && f.play(), f;
21
+ }
22
+ var r = class {
23
+ animation;
24
+ constructor(e, t = {}) {
25
+ this.animation = n(e, t);
26
+ }
27
+ play() {
28
+ return this.animation.play();
29
+ }
30
+ pause() {
31
+ return this.animation.pause(), this;
32
+ }
33
+ stop() {
34
+ return this.animation.stop(), this;
35
+ }
36
+ get finished() {
37
+ return this.animation.finished;
38
+ }
39
+ };
40
+ //#endregion
41
+ export { r as DrawSVG, n as fromDrawSVG };