@mkbabb/keyframes.js 2.2.0 → 3.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 +26 -0
- package/dist/{leaves-Bu89334e.js → css-easing-DoPNckiS.js} +17 -1
- package/dist/{engine-DuAFoqZF.js → engine-B7JGZTdU.js} +153 -110
- package/dist/keyframes.d.ts +104 -34
- package/dist/keyframes.js +100 -102
- package/package.json +9 -4
- package/dist/_redirects +0 -1
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@ Plucked directly from the [`demo/simple`](demo/simple/App.vue) Vue file.
|
|
|
52
52
|
- [AnimationGroup](#animationgroup)
|
|
53
53
|
- [Presets](#presets)
|
|
54
54
|
- [Web Animations API](#web-animations-api)
|
|
55
|
+
- [Baseline, tree-shaking & reduced motion](#baseline-tree-shaking--reduced-motion)
|
|
55
56
|
- [Beyond CSS](#beyond-css)
|
|
56
57
|
- [NumericAnimation](#numericanimation)
|
|
57
58
|
- [SmoothProgress](#smoothprogress)
|
|
@@ -297,6 +298,31 @@ anim.play();
|
|
|
297
298
|
|
|
298
299
|
When `useWAAPI` is `true` (default), eligible animations run on the compositor thread via `Element.animate()`. Eligibility requires: DOM targets, uniform timing function across frames, no computed units, no custom transform function, no color interpolation. Falls back to `requestAnimationFrame` silently.
|
|
299
300
|
|
|
301
|
+
A spring timing function (`springTimingFunction`) carries its CSS `linear()` equivalent, so a WAAPI-delegated spring animation runs the true overshoot/settle curve on the compositor instead of a flattened `linear` ramp — the JS easing and the compositor curve are one solver.
|
|
302
|
+
|
|
303
|
+
## Baseline, tree-shaking & reduced motion
|
|
304
|
+
|
|
305
|
+
keyframes.js targets a modern-web Baseline and documents the tier of every platform facility it leans on:
|
|
306
|
+
|
|
307
|
+
| Facility | Baseline tier | Behavior |
|
|
308
|
+
|---|---|---|
|
|
309
|
+
| `prefers-reduced-motion` | Widely available | Native `matchMedia`; SSR-safe no-op off-DOM |
|
|
310
|
+
| `scheduler.yield()` | Newly available | Feature-detected; falls back to a `MessageChannel` macrotask (≤20 LOC) |
|
|
311
|
+
| WAAPI `linear()` springs | Newly available | Feature-detected; the rAF spring path is the default fallback |
|
|
312
|
+
| `Element.animate()` (WAAPI) | Widely available | Opt-out via `useWAAPI: false` |
|
|
313
|
+
|
|
314
|
+
**Tree-shaking — the value.js boundary.** The package is `"sideEffects": false` and splits along a static/dynamic boundary. The light physics/interpolation engines — `SpringProgress`, `SmoothProgress`, `NumericAnimation`, `ElementMorph`, the `Timeline` family, `RAFPlayback`, and the spring-stop helpers — carry **zero** static import edge to `@mkbabb/value.js`. A consumer that imports only these never pulls value.js (or the heavy CSS-keyframe parser) into its graph; the heavy engine (`Animation`, `CSSKeyframesAnimation`, `AnimationGroup`) is reached only through `loadAnimationEngine()`'s dynamic `import()`. This boundary is **gated in CI** by `proof:boundary`, which builds a spring-only entry and fails the build if any light module reintroduces a static value.js edge.
|
|
315
|
+
|
|
316
|
+
**Reduced motion.** Both the light and heavy engines honor `prefers-reduced-motion: reduce`. Opt in per surface:
|
|
317
|
+
|
|
318
|
+
- **Light interpolators** (`NumericAnimation`, `SmoothProgress`, `SpringProgress`, `ElementMorph`) — pass `respectReducedMotion: true`. `RAFPlayback` owns the shared snap-to-final gate, so the managed `.play()` path skips the rAF loop and lands on the final value in a single paint.
|
|
319
|
+
- **Heavy engine** (`Animation` / `CSSKeyframesAnimation`) — pass `respectReducedMotion: true`; `play()` snaps to the final frame (a single paint, `animationstart` → `animationend`) instead of running the rAF/WAAPI loop.
|
|
320
|
+
- **`AnimationGroup`** — set `group.respectReducedMotion = true`; `play()` composites every child's final frame once rather than driving the draw loop.
|
|
321
|
+
|
|
322
|
+
Off-DOM (SSR / Node) the check is a no-op and animations proceed normally.
|
|
323
|
+
|
|
324
|
+
**INP.** `AnimationGroup` composites N children per frame; for large groups (`> AnimationGroup.YIELD_BATCH`) `tick()` yields to the main thread between batches via `scheduler.yield()` (feature-detected) so a big composite doesn't run as one long task.
|
|
325
|
+
|
|
300
326
|
## Beyond CSS
|
|
301
327
|
|
|
302
328
|
The library also ships general-purpose interpolation primitives, decoupled from CSS and the DOM. These compose into a pipeline: `timeline → progress → interpolator → values → apply`.
|
|
@@ -36,4 +36,20 @@ function o(e) {
|
|
|
36
36
|
clearTimeout(e);
|
|
37
37
|
}
|
|
38
38
|
//#endregion
|
|
39
|
-
|
|
39
|
+
//#region src/animation/internal/reduced-motion.ts
|
|
40
|
+
function s() {
|
|
41
|
+
return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/animation/internal/css-easing.ts
|
|
45
|
+
var c = Symbol.for("keyframes.cssEasing");
|
|
46
|
+
function l(e, t) {
|
|
47
|
+
return e[c] = t, e;
|
|
48
|
+
}
|
|
49
|
+
function u(e) {
|
|
50
|
+
if (typeof e != "function") return;
|
|
51
|
+
let t = e[c];
|
|
52
|
+
return typeof t == "string" ? t : void 0;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { n as a, r as c, o as i, e as l, l as n, i as o, s as r, a as s, u as t };
|