@pixodesk/svg-animator-web 1.0.30 โ†’ 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
@@ -1,5 +1,7 @@
1
1
  # animator-web
2
2
 
3
+ > ๐Ÿ“– Full user guide: [docs/library/web-player.md](../../docs/library/web-player.md) ยท [all docs](../../README.md#documentation)
4
+
3
5
  [![CI](https://github.com/pixodesk/pixodesk-svg-animator/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/pixodesk/pixodesk-svg-animator/actions/workflows/ci.yml)
4
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
7
 
@@ -65,11 +67,11 @@ const animator = createAnimator({
65
67
  });
66
68
 
67
69
  // Or from an already-loaded document object
68
- const animator = createAnimator({ data: animationDoc, container: '#container' });
70
+ const fromObject = createAnimator({ data: animationDoc, container: '#container' });
69
71
 
70
72
  animator.play();
71
73
  animator.pause();
72
- animator.setCurrentTime(500); // seek to 500ms
74
+ animator.setCurrentTime(500); // jump to 0.5 s from the start
73
75
  animator.setPlaybackRate(2); // 2x speed (-1 plays in reverse)
74
76
  animator.finish(); // jump to end
75
77
  animator.destroy(); // cleanup
@@ -86,6 +88,24 @@ animator.destroy(); // cleanup
86
88
  | `container` | `string \| Element` | CSS selector or element to render the SVG into |
87
89
  | `callbacks` | `PxAnimatorCallbacksConfig` | Lifecycle callbacks (see below) |
88
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
+ ```
89
109
 
90
110
  It returns a `PxAnimatorAPI`:
91
111
 
@@ -97,7 +117,7 @@ It returns a `PxAnimatorAPI`:
97
117
  | `finish()` | Jump to the end |
98
118
  | `setPlaybackRate(rate)` | Change speed (1 = normal, 2 = double, -1 = reverse) |
99
119
  | `getCurrentTime()` | Current time in ms |
100
- | `setCurrentTime(ms)` | Seek to a specific time |
120
+ | `setCurrentTime(ms)` | Jump to a point in the animation, in milliseconds from its start |
101
121
  | `isPlaying()` | Whether the animation is currently playing |
102
122
  | `isReady()` | Whether the document has loaded (relevant for URL-based creation) |
103
123
  | `getRootElement()` | The rendered SVG DOM element |
@@ -119,30 +139,30 @@ createAnimator({
119
139
  });
120
140
  ```
121
141
 
122
- ### Engine modes
142
+ ### Engines
123
143
 
124
- `animator.mode` selects the playback engine:
144
+ `animator.timeline.engine` selects how the animated attributes get updated:
125
145
 
126
- - `'auto'` (default) โ€” try the Web Animations API, fall back to `requestAnimationFrame`.
127
- - `'waapi'` โ€” Web Animations API only.
128
- - `'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.
129
149
 
130
150
  ### Document format & effects
131
151
 
132
152
  The `doc` passed to `createAnimator` is a `PxAnimatedSvgDocument` (`type: 'svg'`), the
133
153
  same shape as the JSON export. It comes in two modes:
134
154
 
135
- - **Mode A** โ€” has `children`: the player renders the SVG tree and animates it.
136
- - **Mode B** โ€” no `children`: the player animates a pre-existing SVG DOM, mapping
155
+ - **Self-contained document** โ€” has `children`: the player renders the SVG tree and animates it.
156
+ - **Bind-by-id document** โ€” no `children`: the player animates a pre-existing SVG DOM, mapping
137
157
  element ids to animation specs via `animator.animateById`.
138
158
 
139
159
  Elements may also carry a `node.effects` bucket (structural effects such as
140
160
  `transformBy`, `repeater`, `maskedBy`, `strokeTrim`, `clone`, `fillGradient` /
141
- `strokeGradient`, `textAlongPath`). This player materialises and removes them at
161
+ `strokeGradient`, `textPath`). This player materialises and removes them at
142
162
  runtime before any other normalisation.
143
163
 
144
- See the [file-format reference](../../README.md#file-formats) and the
145
- [Player effects](../../README.md#player-effects-nodeeffects) section in the root
146
- README for the full schema and examples. The wire types live in
147
- [`PxAnimatorTypes.ts`](src/PxAnimatorTypes.ts).
164
+ See the [JSON format reference](../../docs/format/README.md#json-format-reference) and
165
+ [Player effects](../../docs/format/README.md#player-effects) for the full schema and
166
+ examples (compact printable schema: [SCHEMA.md](../../SCHEMA.md)). The wire
167
+ types live in [`PxAnimatorTypes.ts`](../svg-animator-core/src/format/PxAnimatorTypes.ts).
148
168