@mkbabb/keyframes.js 4.4.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 +7 -7
- package/dist/{animate-CuUJt2Tb.js → animate-CTWr6K7j.js} +3 -3
- package/dist/{animations-5nf2kBkv.js → animations-CZxf0rep.js} +2 -2
- package/dist/{compile-DgNRG6Lo.js → compile-YRJRdpKF.js} +2 -2
- package/dist/{draw-svg-DYRDxBlL.js → draw-svg-Dat9mHgi.js} +1 -1
- package/dist/{engine-CNHvTgpw.js → engine-DQcb7CLW.js} +516 -289
- package/dist/{ingest-CNM5xkQT.js → ingest-CU-kdYcM.js} +1 -1
- package/dist/keyframes.d.ts +178 -115
- package/dist/keyframes.js +39 -39
- package/dist/morph-svg-83uyYxoW.js +84 -0
- package/dist/{motion-path-J-RSNmRQ.js → motion-path-C0OHqcA3.js} +1 -1
- package/dist/{scroll-scene-CXEgM49Q.js → scroll-scene-DQxhxn9I.js} +2 -2
- package/dist/{sequence-CF5hazqz.js → sequence-cBr7thU8.js} +1 -1
- package/dist/{springTimingFunction-CDHZ00JQ.js → springTimingFunction-D26gPkAy.js} +1 -1
- package/dist/{timeline-B7SV3T_E.js → timeline-vY3eD3Ax.js} +27 -39
- package/dist/{utils-D7nuAND5.js → utils-BPRImVl5.js} +28 -25
- package/dist/{validate-8r6Yo-uc.js → validate-B1pE-Y_T.js} +3 -3
- package/dist/{waapi-D9MHMm_9.js → waapi-D0ssxKy1.js} +90 -28
- package/package.json +35 -5
- package/dist/morph-svg-DRjl9Hfz.js +0 -62
package/README.md
CHANGED
|
@@ -133,7 +133,7 @@ bench/ # Vitest benchmarks
|
|
|
133
133
|
|
|
134
134
|
## Animation
|
|
135
135
|
|
|
136
|
-
The `
|
|
136
|
+
The `KeyframesAnimation` object (formerly `Animation`, renamed in 5.0.0 — see `docs/MIGRATION-5.0.0.md`) drives `CSSKeyframesAnimation` and `AnimationGroup`. It's composed of:
|
|
137
137
|
|
|
138
138
|
- **options** (`AnimationOptions`)
|
|
139
139
|
- **transform function**: interpolates between keyframes
|
|
@@ -243,7 +243,7 @@ anim.setTargets(element);
|
|
|
243
243
|
await anim.play();
|
|
244
244
|
```
|
|
245
245
|
|
|
246
|
-
The engine surface (`AnimationEngine`): `
|
|
246
|
+
The engine surface (`AnimationEngine`): `KeyframesAnimation`, `CSSKeyframesAnimation`, `AnimationGroup`, `getAnimationId`, `getTimingFunction`, `resolveKeyframes`, `animate`, `MotionPath`/`fromMotionPath`, `DrawSVG`/`fromDrawSVG`, `MorphSVG`/`fromMorphSVG`, `presets`, and the option constants `DIRECTIONS`, `FILL_MODES`, `defaultOptions`, `defaultLayerConfig`. The **type** surface stays on the static barrel — `import type { KeyframesAnimation } from "@mkbabb/keyframes.js"` costs no runtime edge.
|
|
247
247
|
|
|
248
248
|
### `animate`
|
|
249
249
|
|
|
@@ -304,7 +304,7 @@ Options: `from`/`to` (`"0%"`–`"100%"` strings or `0`–`1` numbers; default dr
|
|
|
304
304
|
|
|
305
305
|
Path-shape morphing — interpolate one SVG path `d` into another. value.js's `PathGeometry` owns the geometry (arc-length sampling via `getTotalLength()`/`getPointAtLength()`); keyframes samples both paths at `samples` uniform points and lerps the matched point sets, so the engine's native numeric interpolation *is* the morph (a true blend — the midpoint is distinct from both endpoints, not a cross-fade).
|
|
306
306
|
|
|
307
|
-
```ts
|
|
307
|
+
```ts run
|
|
308
308
|
const { fromMorphSVG, MorphSVG } = await loadAnimationEngine();
|
|
309
309
|
|
|
310
310
|
// Morph a triangle into a square over 600ms:
|
|
@@ -319,7 +319,7 @@ Options: `samples` (point count per path; default `64`), plus every `AnimationOp
|
|
|
319
319
|
|
|
320
320
|
## `CSSKeyframesAnimation`
|
|
321
321
|
|
|
322
|
-
An abstraction over `
|
|
322
|
+
An abstraction over `KeyframesAnimation` that parses CSS `@keyframes` into `TemplateAnimationFrame` objects, then adds them to a base `KeyframesAnimation`.
|
|
323
323
|
|
|
324
324
|
Three ways to create keyframes:
|
|
325
325
|
|
|
@@ -630,7 +630,7 @@ Abstract progress driver. Pipeline: `sample() → clamp → easing → boundary
|
|
|
630
630
|
|
|
631
631
|
```ts run
|
|
632
632
|
const easing = await resolveEasing("easeOutCubic");
|
|
633
|
-
const timeline = new
|
|
633
|
+
const timeline = new KeyframesScrollTimeline({
|
|
634
634
|
threshold: 0.35,
|
|
635
635
|
easing,
|
|
636
636
|
boundaryEpsilon: 0.005,
|
|
@@ -651,7 +651,7 @@ manual.tick(); // => 0.25
|
|
|
651
651
|
Options: `easing` (callable or `Easing`), `smoothing` (`SmoothProgressOptions` or `false`), `boundaryEpsilon` (snap eased values within this distance of 0/1 to the boundary — prevents scroll-endpoint oscillation, default 0.005).
|
|
652
652
|
|
|
653
653
|
Subclasses:
|
|
654
|
-
- **`
|
|
654
|
+
- **`KeyframesScrollTimeline`** — scroll position → progress. `threshold` sets viewport fraction for full progress (default 0.35). Injectable `getScrollY`/`getViewportHeight`.
|
|
655
655
|
- **`ManualTimeline`** — externally set value → progress. Smoothing off by default.
|
|
656
656
|
|
|
657
657
|
Where the platform ships native scroll-driven timelines, `createNativeTimeline({ kind: "scroll" | "view", … })` feature-detects and returns a native `AnimationTimeline` (or `null`) as an additive fast lane — the JS sampler stays the general fallback.
|
|
@@ -693,7 +693,7 @@ const stops = springLinearStops({ response: 0.5, dampingFraction: 0.45 });
|
|
|
693
693
|
stops.startsWith("linear(0, "); // => true
|
|
694
694
|
stops.endsWith(", 1)"); // => true
|
|
695
695
|
|
|
696
|
-
// JS: a typed Easing — feed it to NumericAnimation / ElementMorph /
|
|
696
|
+
// JS: a typed Easing — feed it to NumericAnimation / ElementMorph / KeyframesAnimation
|
|
697
697
|
const spring = springTimingFunction({ response: 0.5, dampingFraction: 0.45 });
|
|
698
698
|
spring.fn(0); // => 0
|
|
699
699
|
spring.fn(1); // => 1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as e } from "./sequence-
|
|
2
|
-
import { AnimationGroup as t, CSSKeyframesAnimation as n } from "./engine-
|
|
3
|
-
import { fromMotionPath as r } from "./motion-path-
|
|
1
|
+
import { t as e } from "./sequence-cBr7thU8.js";
|
|
2
|
+
import { AnimationGroup as t, CSSKeyframesAnimation as n } from "./engine-DQcb7CLW.js";
|
|
3
|
+
import { fromMotionPath as r } from "./motion-path-C0OHqcA3.js";
|
|
4
4
|
//#region src/animation/animate.ts
|
|
5
5
|
var i = (e) => typeof e == "object" && !!e && !Array.isArray(e) && !(e instanceof Map) && typeof e.path == "string", a = (e) => e instanceof Map || typeof e == "object" && !!e && !Array.isArray(e);
|
|
6
6
|
function o(o, s, c) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as e } from "./springTimingFunction-
|
|
2
|
-
import { CSSKeyframesAnimation as t } from "./engine-
|
|
1
|
+
import { t as e } from "./springTimingFunction-D26gPkAy.js";
|
|
2
|
+
import { CSSKeyframesAnimation as t } from "./engine-DQcb7CLW.js";
|
|
3
3
|
import { CSSCubicBezier as n, steppedEase as r } from "@mkbabb/value.js";
|
|
4
4
|
//#region src/animation/animations.ts
|
|
5
5
|
var ee = "\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n", i = (e) => new t({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as e } from "./sequence-
|
|
2
|
-
import { AnimationGroup as t, getAnimationId as n } from "./engine-
|
|
1
|
+
import { t as e } from "./sequence-cBr7thU8.js";
|
|
2
|
+
import { AnimationGroup as t, getAnimationId as n } from "./engine-DQcb7CLW.js";
|
|
3
3
|
import { a as r, i, n as a, t as o } from "./format-BUgCTjmr.js";
|
|
4
4
|
import { a as s } from "./scroll-grammar-B4kPvGh5.js";
|
|
5
5
|
import { COLOR_SPACE_RANGES as c, color2 as l, deltaEOK as u, formatCSS as d, normalizeColorUnit as f, reverseCSSTime as p, sampleColorRamp as m, scale as h } from "@mkbabb/value.js";
|