@weasel-js/animator 1.9.4 → 1.10.1

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
@@ -4,7 +4,7 @@ Tweens, springs, holds, staggers, and timelines on one frame loop, with no scene
4
4
 
5
5
  Part of [weasel](https://github.com/orochi235/weasel), a domain-agnostic 2D
6
6
  scene-graph canvas kit for React. See the
7
- [API reference](https://orochi235.github.io/weasel/api/).
7
+ [API reference](https://orochi235.github.io/weasel/#pkg/animator).
8
8
 
9
9
  ```sh
10
10
  npm install @weasel-js/animator
@@ -23,14 +23,32 @@ animator.spring({ target, to: 40 }); // bends the motion; neither cancels the ot
23
23
 
24
24
  | Export | What it is |
25
25
  |---|---|
26
- | `useAnimator()` | The animator: `tween`, `spring`, `physics`, `decay`, `hold`, `loop`, `stagger`, `timeline`, and `watch`. The frame loop stops while its host is unseen. |
27
- | `createTarget(opts)` | One value an animator moves. Animations on a target add, so a second one bends the first. |
26
+ | `useAnimator()` | The animator: `tween`, `spring`, `physics`, `decay`, `hold`, `loop`, `stagger`, `timeline`, `watch`, and `live`, with `pause`, `resume`, and `setTimeScale` over everything it runs. The frame loop stops while its host is unseen. |
27
+ | `createTarget(opts)` | One value an animator moves. Animations on a target add, so a second one bends the first. `target.axisIndexes(['y'])` answers where the axes it names sit among the target's numbers. |
28
28
  | `createTargetTable(opts)` | Many like values as rows of flat arrays, shown in one pass. |
29
29
  | `sampleTrack`, the `Track` types | Keyframe tracks for `animator.timeline`. |
30
30
  | `resolveSkeleton`, `skeletonAxes`, `solveIk`, `mirrorPose` | Skeleton math: joints to matrices, a skeleton pose as a target's axes, two-bone IK. |
31
31
  | `tweenVertexColors` and its siblings, `ColorOverrideRegistry` | Per-vertex color animation, and the table a renderer reads the colors from. |
32
32
  | `createSlew`, `slewToward` | A value that follows another at a bounded rate. |
33
33
 
34
+ A hold or a timeline track over part of a target names the axes it holds, by the value's own
35
+ fields or by index. A rig's pose target names its axes `<joint>.<field>`, so a joint's name
36
+ reaches all five of its axes:
37
+
38
+ ```tsx
39
+ animator.hold({ target, value: { x: 0, y: 120 }, axes: ['y'] });
40
+ animator.hold({ target: rig.target, value: pose, axes: ['armL', 'foreL.rotation'] });
41
+ ```
42
+
43
+ `animator.stagger(items, delay)` answers a builder. Its `.tween` and `.spring` move the items
44
+ themselves where they are targets, a `target` named per item otherwise, and hand values to
45
+ `onTick` with neither; `.each` runs any factory.
46
+
47
+ ```tsx
48
+ animator.stagger(targets, 80).spring({ to: (target) => ({ ...target.committed(), y: 200 }), preset: 'wobbly' });
49
+ animator.stagger(rows, 80).tween({ target: (row) => row.target, to: 1, ms: 300 });
50
+ ```
51
+
34
52
  Moving a scene node's pose is `@weasel-js/core`'s half: `tweenPose`, `springPose`,
35
53
  `momentum`, `bindRig`, and `useAnimatedReflow` drive this animator against a scene. How
36
54
  animations combine on a target is in