@pixodesk/svg-animator-web 1.0.34 → 1.0.35

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
@@ -67,7 +67,7 @@ const animator = createAnimator({
67
67
  });
68
68
 
69
69
  // Or from an already-loaded document object
70
- const animator = createAnimator({ data: animationDoc, container: '#container' });
70
+ const fromObject = createAnimator({ data: animationDoc, container: '#container' });
71
71
 
72
72
  animator.play();
73
73
  animator.pause();
@@ -88,6 +88,24 @@ animator.destroy(); // cleanup
88
88
  | `container` | `string \| Element` | CSS selector or element to render the SVG into |
89
89
  | `callbacks` | `PxAnimatorCallbacksConfig` | Lifecycle callbacks (see below) |
90
90
  | `adapter` | `PxPlatformAdapter` | Custom attribute-writer for frame-loop rendering (advanced) |
91
+ | `config` | `object \| string` | Per-instance playback override, deep-merged over the document's `animator` block — same shape as the file; `null` at a slot deletes that key. A JSON string is accepted too |
92
+ | `resetDocDefaults` | `boolean` | Ignore the document's playback settings and start from the player's defaults, with `config` on top |
93
+ | `duration` · `delay` | `number` | Shortcuts for `config.timeline.duration` / `.delay` (ms) |
94
+ | `iterations` | `number \| 'infinite'` | Shortcut for `config.timeline.iterations` |
95
+ | `startOn` | `StartOn` | Shortcut for `config.timeline.trigger.startOn` |
96
+
97
+ The document plays the way it was designed with no configuration at all; `config` is for when
98
+ one page needs it to play differently — the same file mounted twice at two speeds, or a file
99
+ that autostarts everywhere except inside your own transport UI:
100
+
101
+ ```js
102
+ const animator = createAnimator({
103
+ src: '/animation.json',
104
+ container: '#box',
105
+ config: { timeline: { iterations: 'infinite', trigger: { startOn: 'programmatic' } } },
106
+ });
107
+ animator.play();
108
+ ```
91
109
 
92
110
  It returns a `PxAnimatorAPI`:
93
111
 
@@ -121,13 +139,13 @@ createAnimator({
121
139
  });
122
140
  ```
123
141
 
124
- ### Engine modes
142
+ ### Engines
125
143
 
126
- `animator.mode` selects the playback engine:
144
+ `animator.timeline.engine` selects how the animated attributes get updated:
127
145
 
128
- - `'auto'` (default) — try the Web Animations API, fall back to `requestAnimationFrame`.
129
- - `'waapi'` — Web Animations API only.
130
- - `'frames'` — `requestAnimationFrame` only; honours `animator.frameRate`. Required for path morphing.
146
+ - `'auto'` (default) — the browser where it can (Web Animations API; its ScrollTimeline for scroll-driven documents), the player's frame loop where it must.
147
+ - `'native'` — the browser only (Web Animations API).
148
+ - `'js'` — the player's `requestAnimationFrame` loop only; honours `timeline.frameRate`. Required for path morphing in Safari < 18.5.
131
149
 
132
150
  ### Document format & effects
133
151
 
@@ -146,5 +164,5 @@ runtime before any other normalisation.
146
164
  See the [JSON format reference](../../docs/format/README.md#json-format-reference) and
147
165
  [Player effects](../../docs/format/README.md#player-effects) for the full schema and
148
166
  examples (compact printable schema: [SCHEMA.md](../../SCHEMA.md)). The wire
149
- types live in [`PxAnimatorTypes.ts`](../svg-animator-core/src/PxAnimatorTypes.ts).
167
+ types live in [`PxAnimatorTypes.ts`](../svg-animator-core/src/format/PxAnimatorTypes.ts).
150
168