@pixodesk/svg-animator-web 1.0.6

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pixodesk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # animator-web
2
+ A lightweight JavaScript library for playing SVG animations in the browser. Pixodesk Animator runs animations created in the Pixodesk editor using the Web Animations API or requestAnimationFrame. It supports event triggers such as click, hover, and scroll. The library ships as ESM, CJS, and UMD bundles.
3
+
4
+
5
+ # 🚧 **Status - This project is currently under development.**
6
+
7
+ ## Usage
8
+
9
+ ### Embed/Inline SVG with animation
10
+
11
+ ```html
12
+ <body>
13
+ <svg width="200" height="200" viewBox="0 0 200 200">
14
+ <!-- animation here -->
15
+ </svg>
16
+ </body>
17
+ ```
18
+
19
+ #### CSS Keyframes
20
+
21
+ ```html
22
+ <body>
23
+ <svg width="200" height="200" viewBox="0 0 200 200">
24
+ <!-- animation here -->
25
+ </svg>
26
+ </body>
27
+ ```
28
+
29
+ #### JS
30
+
31
+
32
+ ### Declarative (HTML)
33
+
34
+ Add a `data-px-animation-src` attribute to any element pointing to your animation JSON file, then call `loadTagAnimators()`:
35
+
36
+ ```html
37
+ <div data-px-animation-src="/animation.json"></div>
38
+
39
+ <!-- UMD -->
40
+ <script src="pixodesk-svg-animator.umd.js"></script>
41
+ <script>
42
+ PixodeskAnimator.loadTagAnimators();
43
+ </script>
44
+ ```
45
+
46
+ Each element gets an animator instance stored on `element._px_animator`, which you can use for playback control.
47
+
48
+ ### Programmatic
49
+
50
+ Use `createAnimator` for full control:
51
+
52
+ ```js
53
+ import { createAnimator } from '@pixodesk/svg-animator-web';
54
+
55
+ // From a URL — returns a proxy that queues calls until the document is fetched
56
+ const animator = createAnimator('/animation.json', undefined, {
57
+ onFinish: () => console.log('done'),
58
+ }, '#container');
59
+
60
+ // Or from an already-loaded document object
61
+ const animator = createAnimator(animationDoc, undefined, undefined, '#container');
62
+
63
+ animator.play();
64
+ animator.pause();
65
+ animator.setCurrentTime(500); // seek to 500ms
66
+ animator.setPlaybackRate(2); // 2x speed
67
+ animator.finish(); // jump to end
68
+ animator.destroy(); // cleanup
69
+ ```
70
+
71
+ ### API
72
+
73
+ `createAnimator(docOrUrl, adapter?, callbacks?, containerElement?)` returns a `PxAnimatorAPI`:
74
+
75
+ | Method | Description |
76
+ | ----------------------- | ----------------------------------------------------------------- |
77
+ | `play()` | Start or resume playback |
78
+ | `pause()` | Pause at the current time |
79
+ | `cancel()` | Stop and reset to the start |
80
+ | `finish()` | Jump to the end |
81
+ | `setPlaybackRate(rate)` | Change speed (1 = normal, 2 = double, -1 = reverse) |
82
+ | `getCurrentTime()` | Current time in ms |
83
+ | `setCurrentTime(ms)` | Seek to a specific time |
84
+ | `isPlaying()` | Whether the animation is currently playing |
85
+ | `isReady()` | Whether the document has loaded (relevant for URL-based creation) |
86
+ | `getRootElement()` | The rendered SVG DOM element |
87
+ | `destroy()` | Remove the animation and clean up |
88
+
89
+ ### Callbacks
90
+
91
+ ```js
92
+ createAnimator(doc, undefined, {
93
+ onPlay: () => { /* started/resumed */ },
94
+ onPause: () => { /* paused */ },
95
+ onCancel: () => { /* cancelled */ },
96
+ onFinish: () => { /* finished */ },
97
+ onRemove: () => { /* cleaned up */ },
98
+ }, '#container');
99
+ ```
100
+