@pixodesk/svg-animator-web 1.0.19 → 1.0.21
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 +31 -14
- package/dist/index.cjs +4317 -3869
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -5331
- package/dist/index.d.ts +14 -5331
- package/dist/index.js +4315 -3869
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.umd.js +4315 -3869
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -56,25 +56,38 @@ Use `createAnimator` for full control:
|
|
|
56
56
|
```js
|
|
57
57
|
import { createAnimator } from '@pixodesk/svg-animator-web';
|
|
58
58
|
|
|
59
|
-
// From a URL — returns a proxy
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
// From a URL — returns a proxy immediately; control calls made before the
|
|
60
|
+
// document loads are queued and replayed once it's ready
|
|
61
|
+
const animator = createAnimator({
|
|
62
|
+
src: '/animation.json',
|
|
63
|
+
container: '#container',
|
|
64
|
+
callbacks: { onFinish: () => console.log('done') },
|
|
65
|
+
});
|
|
63
66
|
|
|
64
67
|
// Or from an already-loaded document object
|
|
65
|
-
const animator = createAnimator(animationDoc,
|
|
68
|
+
const animator = createAnimator({ data: animationDoc, container: '#container' });
|
|
66
69
|
|
|
67
70
|
animator.play();
|
|
68
71
|
animator.pause();
|
|
69
72
|
animator.setCurrentTime(500); // seek to 500ms
|
|
70
|
-
animator.setPlaybackRate(2); // 2x speed
|
|
73
|
+
animator.setPlaybackRate(2); // 2x speed (-1 plays in reverse)
|
|
71
74
|
animator.finish(); // jump to end
|
|
72
75
|
animator.destroy(); // cleanup
|
|
73
76
|
```
|
|
74
77
|
|
|
75
78
|
### API
|
|
76
79
|
|
|
77
|
-
`createAnimator(
|
|
80
|
+
`createAnimator(options)` takes a single options object:
|
|
81
|
+
|
|
82
|
+
| Option | Type | Description |
|
|
83
|
+
| ----------- | ------------------------- | -------------------------------------------------- |
|
|
84
|
+
| `src` | `string` | URL to fetch the animation document from (provide either `src` or `data`) |
|
|
85
|
+
| `data` | `PxAnimatedSvgDocument` | Inline animation document object |
|
|
86
|
+
| `container` | `string \| Element` | CSS selector or element to render the SVG into |
|
|
87
|
+
| `callbacks` | `PxAnimatorCallbacksConfig` | Lifecycle callbacks (see below) |
|
|
88
|
+
| `adapter` | `PxPlatformAdapter` | Custom attribute-writer for frame-loop rendering (advanced) |
|
|
89
|
+
|
|
90
|
+
It returns a `PxAnimatorAPI`:
|
|
78
91
|
|
|
79
92
|
| Method | Description |
|
|
80
93
|
| ----------------------- | ----------------------------------------------------------------- |
|
|
@@ -93,13 +106,17 @@ animator.destroy(); // cleanup
|
|
|
93
106
|
### Callbacks
|
|
94
107
|
|
|
95
108
|
```js
|
|
96
|
-
createAnimator(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
109
|
+
createAnimator({
|
|
110
|
+
data: doc,
|
|
111
|
+
container: '#container',
|
|
112
|
+
callbacks: {
|
|
113
|
+
onPlay: () => { /* started/resumed */ },
|
|
114
|
+
onPause: () => { /* paused */ },
|
|
115
|
+
onCancel: () => { /* cancelled */ },
|
|
116
|
+
onFinish: () => { /* finished naturally (or via finish()) */ },
|
|
117
|
+
onRemove: () => { /* destroyed / cleaned up */ },
|
|
118
|
+
},
|
|
119
|
+
});
|
|
103
120
|
```
|
|
104
121
|
|
|
105
122
|
### Engine modes
|