@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 CHANGED
@@ -133,7 +133,7 @@ bench/ # Vitest benchmarks
133
133
 
134
134
  ## Animation
135
135
 
136
- The `Animation` object drives `CSSKeyframesAnimation` and `AnimationGroup`. It's composed of:
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`): `Animation`, `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 { Animation } from "@mkbabb/keyframes.js"` costs no runtime edge.
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 `Animation` that parses CSS `@keyframes` into `TemplateAnimationFrame` objects, then adds them to a base `Animation`.
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 ScrollTimeline({
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
- - **`ScrollTimeline`** — scroll position → progress. `threshold` sets viewport fraction for full progress (default 0.35). Injectable `getScrollY`/`getViewportHeight`.
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 / Animation
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-CF5hazqz.js";
2
- import { AnimationGroup as t, CSSKeyframesAnimation as n } from "./engine-CNHvTgpw.js";
3
- import { fromMotionPath as r } from "./motion-path-J-RSNmRQ.js";
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-CDHZ00JQ.js";
2
- import { CSSKeyframesAnimation as t } from "./engine-CNHvTgpw.js";
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-CF5hazqz.js";
2
- import { AnimationGroup as t, getAnimationId as n } from "./engine-CNHvTgpw.js";
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";
@@ -1,4 +1,4 @@
1
- import { CSSKeyframesAnimation as e } from "./engine-CNHvTgpw.js";
1
+ import { CSSKeyframesAnimation as e } from "./engine-DQcb7CLW.js";
2
2
  //#region src/animation/draw-svg.ts
3
3
  var t = (e) => {
4
4
  if (typeof e == "number") {