@pixodesk/svg-animator-web 1.0.34 → 1.0.39
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 +41 -21
- package/dist/index.cjs +1538 -679
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -37
- package/dist/index.d.ts +67 -37
- package/dist/index.js +1473 -664
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.prerendered-waapi.umd.js +1278 -126
- package/dist/index.prerendered-waapi.umd.js.map +1 -1
- package/dist/index.prerendered-waapi.umd.min.js +1 -1
- package/dist/index.prerendered.umd.js +1343 -172
- package/dist/index.prerendered.umd.js.map +1 -1
- package/dist/index.prerendered.umd.min.js +1 -1
- package/dist/pixodesk-svg-animator.umd.js +1212 -637
- package/dist/pixodesk-svg-animator.umd.js.map +1 -1
- package/dist/pixodesk-svg-animator.umd.min.js +1 -1
- package/mangle-reserved.json +244 -0
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -63,11 +63,11 @@ import { createAnimator } from '@pixodesk/svg-animator-web';
|
|
|
63
63
|
const animator = createAnimator({
|
|
64
64
|
src: '/animation.json',
|
|
65
65
|
container: '#container',
|
|
66
|
-
|
|
66
|
+
onFinish: () => console.log('done'),
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
// Or from an already-loaded document object
|
|
70
|
-
const
|
|
70
|
+
const fromObject = createAnimator({ doc: animationDoc, container: '#container' });
|
|
71
71
|
|
|
72
72
|
animator.play();
|
|
73
73
|
animator.pause();
|
|
@@ -81,16 +81,36 @@ animator.destroy(); // cleanup
|
|
|
81
81
|
|
|
82
82
|
`createAnimator(options)` takes a single options object:
|
|
83
83
|
|
|
84
|
+
<!-- px-check props PxAnimatorOptions pkg=web -->
|
|
84
85
|
| Option | Type | Description |
|
|
85
86
|
| ----------- | ------------------------- | -------------------------------------------------- |
|
|
86
|
-
| `src` | `string` | URL to fetch the animation document from (provide either `src` or `
|
|
87
|
-
| `
|
|
87
|
+
| `src` | `string` | URL to fetch the animation document from (provide either `src` or `doc`) |
|
|
88
|
+
| `doc` | `PxAnimatedSvgDocument` | Inline animation document object |
|
|
88
89
|
| `container` | `string \| Element` | CSS selector or element to render the SVG into |
|
|
89
|
-
| `
|
|
90
|
+
| `onPlay` · `onPause` · `onCancel` · `onFinish` · `onRemove` · `onStop` | `() => void` | the lifecycle callbacks, inline — the same names the components take; plus `onWarn`, `onError`, `silent` for diagnostics. See [Callbacks](#callbacks) | <!-- px names=onPlay,onPause,onCancel,onFinish,onRemove,onStop,onWarn,onError,silent -->
|
|
90
91
|
| `adapter` | `PxPlatformAdapter` | Custom attribute-writer for frame-loop rendering (advanced) |
|
|
92
|
+
| `timeline` | `object \| string` | per-instance override of the document's `timeline` block, deep-merged over it — same shape as the file; `null` at any slot deletes that key. A JSON string is accepted too. See [Playback overrides](#playback-overrides) |
|
|
93
|
+
| `resetTimeline` | `boolean` | ignore the document's own timeline and start from the player's default timeline, with `timeline` on top |
|
|
94
|
+
| `duration` · `delay` | `number` | Shortcuts for `timeline.duration` / `.delay` (ms) | <!-- px names=duration,delay -->
|
|
95
|
+
| `iterations` | `number \| 'infinite'` | Shortcut for `timeline.iterations` |
|
|
96
|
+
| `startOn` | `PxStartOn` | Shortcut for `timeline.trigger.startOn` |
|
|
97
|
+
|
|
98
|
+
The document plays the way it was designed with no configuration at all; `timeline` is for when
|
|
99
|
+
one page needs it to play differently — the same file mounted twice at two speeds, or a file
|
|
100
|
+
that autostarts everywhere except inside your own transport UI:
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
const animator = createAnimator({
|
|
104
|
+
src: '/animation.json',
|
|
105
|
+
container: '#box',
|
|
106
|
+
timeline: { iterations: 'infinite', trigger: { startOn: 'programmatic' } },
|
|
107
|
+
});
|
|
108
|
+
animator.play();
|
|
109
|
+
```
|
|
91
110
|
|
|
92
111
|
It returns a `PxAnimatorAPI`:
|
|
93
112
|
|
|
113
|
+
<!-- px-check props PxAnimatorAPI pkg=web -->
|
|
94
114
|
| Method | Description |
|
|
95
115
|
| ----------------------- | ----------------------------------------------------------------- |
|
|
96
116
|
| `play()` | Start or resume playback |
|
|
@@ -100,6 +120,8 @@ It returns a `PxAnimatorAPI`:
|
|
|
100
120
|
| `setPlaybackRate(rate)` | Change speed (1 = normal, 2 = double, -1 = reverse) |
|
|
101
121
|
| `getCurrentTime()` | Current time in ms |
|
|
102
122
|
| `setCurrentTime(ms)` | Jump to a point in the animation, in milliseconds from its start |
|
|
123
|
+
| `getCurrentProgress()` | The same position as 0–1 of the whole run (`null` before ready) |
|
|
124
|
+
| `setCurrentProgress(p)` | Jump to 0–1 of the whole run |
|
|
103
125
|
| `isPlaying()` | Whether the animation is currently playing |
|
|
104
126
|
| `isReady()` | Whether the document has loaded (relevant for URL-based creation) |
|
|
105
127
|
| `getRootElement()` | The rendered SVG DOM element |
|
|
@@ -109,25 +131,23 @@ It returns a `PxAnimatorAPI`:
|
|
|
109
131
|
|
|
110
132
|
```js
|
|
111
133
|
createAnimator({
|
|
112
|
-
|
|
134
|
+
doc: doc,
|
|
113
135
|
container: '#container',
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
onRemove: () => { /* destroyed / cleaned up */ },
|
|
120
|
-
},
|
|
136
|
+
onPlay: () => { /* started/resumed */ },
|
|
137
|
+
onPause: () => { /* paused */ },
|
|
138
|
+
onCancel: () => { /* canceled */ },
|
|
139
|
+
onFinish: () => { /* finished naturally (or via finish()) */ },
|
|
140
|
+
onRemove: () => { /* destroyed / cleaned up */ },
|
|
121
141
|
});
|
|
122
142
|
```
|
|
123
143
|
|
|
124
|
-
###
|
|
144
|
+
### Engines
|
|
125
145
|
|
|
126
|
-
`animator.
|
|
146
|
+
`animator.timeline.engine` selects how the animated attributes get updated:
|
|
127
147
|
|
|
128
|
-
- `'auto'` (default) —
|
|
129
|
-
- `'
|
|
130
|
-
- `'
|
|
148
|
+
- `'auto'` (default) — the browser where it can (Web Animations API; its ScrollTimeline for scroll-driven documents), the player's frame loop where it must.
|
|
149
|
+
- `'native'` — the browser only (Web Animations API).
|
|
150
|
+
- `'js'` — the player's `requestAnimationFrame` loop only; honors `timeline.frameRate`. Required for path morphing in Safari < 18.5.
|
|
131
151
|
|
|
132
152
|
### Document format & effects
|
|
133
153
|
|
|
@@ -140,11 +160,11 @@ same shape as the JSON export. It comes in two modes:
|
|
|
140
160
|
|
|
141
161
|
Elements may also carry a `node.effects` bucket (structural effects such as
|
|
142
162
|
`transformBy`, `repeater`, `maskedBy`, `strokeTrim`, `clone`, `fillGradient` /
|
|
143
|
-
`strokeGradient`, `textPath`). This player
|
|
144
|
-
runtime before any other
|
|
163
|
+
`strokeGradient`, `textPath`). This player materializes and removes them at
|
|
164
|
+
runtime before any other normalization.
|
|
145
165
|
|
|
146
166
|
See the [JSON format reference](../../docs/format/README.md#json-format-reference) and
|
|
147
167
|
[Player effects](../../docs/format/README.md#player-effects) for the full schema and
|
|
148
168
|
examples (compact printable schema: [SCHEMA.md](../../SCHEMA.md)). The wire
|
|
149
|
-
types live in [`PxAnimatorTypes.ts`](../svg-animator-core/src/PxAnimatorTypes.ts).
|
|
169
|
+
types live in [`PxAnimatorTypes.ts`](../svg-animator-core/src/format/PxAnimatorTypes.ts).
|
|
150
170
|
|