awd-skill 0.0.0-stage → 1.0.0

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.
Files changed (36) hide show
  1. package/README.md +324 -3
  2. package/bin/install.js +756 -0
  3. package/commands/awd-skill-assets.md +25 -0
  4. package/commands/awd-skill-backend.md +12 -0
  5. package/commands/awd-skill-content.md +12 -0
  6. package/commands/awd-skill-deploy.md +12 -0
  7. package/commands/awd-skill-design.md +12 -0
  8. package/commands/awd-skill-frontend.md +12 -0
  9. package/commands/awd-skill-growth.md +12 -0
  10. package/commands/awd-skill-launch.md +12 -0
  11. package/commands/awd-skill-list.md +12 -0
  12. package/commands/awd-skill-mode-e.md +18 -0
  13. package/commands/awd-skill-mode-f.md +16 -0
  14. package/commands/awd-skill-motion.md +12 -0
  15. package/commands/awd-skill-qa.md +12 -0
  16. package/commands/awd-skill-research.md +12 -0
  17. package/commands/awd-skill-strategy.md +12 -0
  18. package/commands/awd-skill-taste.md +18 -0
  19. package/commands/awd-skill-template-submit.md +16 -0
  20. package/commands/awd-skill-template-use.md +15 -0
  21. package/commands/awd-skill.md +11 -0
  22. package/docs/EXAMPLES.md +124 -0
  23. package/docs/INSTALL.md +203 -0
  24. package/docs/LICENSING.md +150 -0
  25. package/docs/PRODUCTION.md +921 -0
  26. package/docs/TEMPLATES.md +105 -0
  27. package/docs/VISUAL-GATES.md +131 -0
  28. package/docs/animotion/AGENTIC-MODE.md +537 -0
  29. package/docs/animotion/API-REFERENCE.md +2457 -0
  30. package/docs/animotion/DECLARATIVE-ATTRIBUTES.md +8563 -0
  31. package/docs/animotion/EFFECTS-PLAYBOOK.md +377 -0
  32. package/docs/animotion/IMPERATIVE-API.md +9056 -0
  33. package/docs/design-editor-plan.md +259 -0
  34. package/docs/generative-ai-canvas-plan.md +144 -0
  35. package/docs/target-state-plan.md +466 -0
  36. package/package.json +68 -4
@@ -0,0 +1,2457 @@
1
+ # AnimotionJS+ API Reference
2
+
3
+ **Package:** `animotionjs-plus`
4
+ **Version:** 1.1.9
5
+ **License:** MIT
6
+
7
+ - [Installation & Setup](#installation--setup)
8
+ - [Core Animation Engine](#core-animation-engine)
9
+ - [Tween](#tween)
10
+ - [Timeline](#timeline)
11
+ - [Keyframes](#keyframes)
12
+ - [Easing](#easing)
13
+ - [AnimationCore](#animationcore)
14
+ - [AnimationContext](#animationcontext)
15
+ - [Scroll & View Features](#scroll--view-features)
16
+ - [ScrollTrigger](#scrolltrigger)
17
+ - [SmoothScroll](#smoothscroll)
18
+ - [ParallaxEffect](#parallaxeffect)
19
+ - [Text Features](#text-features)
20
+ - [SplitText](#splittext)
21
+ - [TextEffects](#texteffects)
22
+ - [Interaction & Physics](#interaction--physics)
23
+ - [Draggable](#draggable)
24
+ - [SpringPhysics](#springphysics)
25
+ - [Interactions](#interactions)
26
+ - [MotionPath](#motionpath)
27
+ - [SceneSequence](#scenesequence)
28
+ - [Media Features](#media-features)
29
+ - [VideoAnimation](#videoanimation)
30
+ - [AudioAnimation](#audioanimation)
31
+ - [PNGSequence](#pngsequence)
32
+ - [Layouts](#layouts)
33
+ - [Layout Types](#layout-types)
34
+ - [Integrations](#integrations)
35
+ - [WebGLSupport](#webglsupport)
36
+ - [ThreeJsSupport](#threejssupport)
37
+ - [LottieSupport](#lottiesupport)
38
+ - [DotLottieSupport](#dotlottiesupport)
39
+ - [Data & State](#data--state)
40
+ - [ViewModel](#viewmodel)
41
+ - [StateMachine](#statemachine)
42
+ - [Binding](#binding)
43
+ - [ConditionEvaluator](#conditionevaluator)
44
+ - [License Manager](#license-manager)
45
+ - [LicenseManager](#licensemanager)
46
+ - [Framework Integrations](#framework-integrations)
47
+ - [React Hooks](#react-hooks)
48
+ - [Next.js](#nextjs)
49
+ - [HTML Attributes (data-anim-*)](#html-attributes-data-anim-)
50
+ - [animotionAttrs](#animotionattrs)
51
+ - [Utilities](#utilities)
52
+ - [DomUtils](#domutils)
53
+ - [MathUtils](#mathutils)
54
+ - [ParserUtils](#parserutils)
55
+ - [EnvironmentUtils](#environmentutils)
56
+ - [Logger](#logger)
57
+ - [CSS Styles](#css-styles)
58
+ - [Built-in Keyframe Animations](#built-in-keyframe-animations)
59
+ - [Utility Classes](#utility-classes)
60
+
61
+ ---
62
+
63
+ ## Installation & Setup
64
+
65
+ ```bash
66
+ npm install animotionjs-plus
67
+ ```
68
+
69
+ ### Entry Points
70
+
71
+ | Path | Format | Use |
72
+ |------|--------|-----|
73
+ | `animotionjs-plus` (default) | ESM (`src/index.core.js`) / UMD (`dist/animotion.min.js`) | Main library |
74
+ | `animotionjs-plus/react` | ESM | React hooks |
75
+ | `animotionjs-plus/next` | ESM | Next.js (re-exports React hooks) |
76
+ | `animotionjs-plus/attrs` | ESM | HTML attribute rendering utility |
77
+ | `animotionjs-plus/styles.css` | CSS | Built-in styles |
78
+
79
+ ### Quick Start (Vanilla JS)
80
+
81
+ ```js
82
+ import Animotion from 'animotionjs-plus';
83
+
84
+ // Static convenience methods
85
+ Animotion.to('.box', { x: 200, opacity: 0.5 }, { duration: 1, ease: 'ease-out' });
86
+
87
+ // Singleton instance (singleton pattern)
88
+ Animotion.init({ attributePrefix: 'am' });
89
+ ```
90
+
91
+ ### Quick Start (UMD via CDN)
92
+
93
+ ```html
94
+ <script src="dist/animotion.min.js" data-anim-init></script>
95
+ ```
96
+
97
+ ### Quick Start (React)
98
+
99
+ ```jsx
100
+ import { useAnimotion } from 'animotionjs-plus/react';
101
+
102
+ function Component() {
103
+ const scopeRef = useAnimotion((ctx, scope) => {
104
+ ctx.to('.title', { opacity: 1, y: 0 }, { duration: 0.8 });
105
+ });
106
+ return <div ref={scopeRef}>...</div>;
107
+ }
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Core Animation Engine
113
+
114
+ ### Tween
115
+
116
+ Animates a target (DOM element(s), plain object, or Three.js object) from current state to target state.
117
+
118
+ ```js
119
+ import Animotion from 'animotionjs-plus';
120
+
121
+ // From the singleton
122
+ Animotion.to('.box', { x: 200, opacity: 0.5 }, { duration: 1 });
123
+
124
+ // Direct constructor
125
+ import { Tween } from 'animotionjs-plus';
126
+ const tween = new Tween('.box', { x: 200 }, { duration: 1 });
127
+ ```
128
+
129
+ #### Constructor
130
+
131
+ ```
132
+ new Tween(target, props, options?)
133
+ ```
134
+
135
+ #### Parameters
136
+
137
+ | Param | Type | Description |
138
+ |-------|------|-------------|
139
+ | `target` | `string \| Element \| Record<string,any> \| any[]` | CSS selector, element, object, or array of targets |
140
+ | `props` | `Record<string, any>` | Properties to animate (x, y, opacity, rotation, CSS custom props, nested paths) |
141
+ | `options` | `TweenOptions` | Animation configuration |
142
+
143
+ #### TweenOptions
144
+
145
+ | Option | Type | Default | Description |
146
+ |--------|------|---------|-------------|
147
+ | `duration` | `number` | `1` | Duration in seconds |
148
+ | `ease` | `string` | `'ease-out'` | Easing function name |
149
+ | `delay` | `number` | `0` | Delay before start (seconds) |
150
+ | `repeat` | `number` | `0` | Repeat count (-1 = infinite) |
151
+ | `yoyo` | `boolean` | `true` | Reverse on repeat |
152
+ | `stagger` | `number \| StaggerConfig` | `0` | Per-target stagger: `each` (seconds), `amount` (total span), `from` (`'start' \| 'center' \| 'edges' \| 'end' \| 'random' \| number[]`), `grid: [rows, cols]`, `axis: 'x' \| 'y'` |
153
+ | `paused` | `boolean` | `false` | Start paused |
154
+ | `from` | `boolean` | `false` | Animate *from* the given props |
155
+ | `fromTo` | `Record<string, any>` | `null` | Explicit from-props for fromTo |
156
+ | `scope` | `Element \| null` | `null` | Scoped query root |
157
+ | `render` | `(tween) => void` | `null` | Per-frame render callback |
158
+ | `onStart` | `(tween) => void` | `null` | Animation start callback |
159
+ | `onUpdate` | `(tween) => void` | `null` | Per-frame update callback |
160
+ | `onRepeat` | `(tween) => void` | `null` | Repeat callback |
161
+ | `onComplete` | `(tween) => void` | `null` | Completion callback |
162
+
163
+ #### Methods
164
+
165
+ | Method | Returns | Description |
166
+ |--------|---------|-------------|
167
+ | `.play()` | `void` | Start/resume animation |
168
+ | `.pause()` | `void` | Pause animation |
169
+ | `.reverse()` | `void` | Toggle reverse direction |
170
+ | `.restart()` | `void` | Restart from beginning |
171
+ | `.seek(progress)` | `this` | Jump to 0–1 progress |
172
+ | `.progress(value?)` | `number \| void` | Getter/setter for 0–1 progress |
173
+ | `.kill()` | `void` | Destroy tween and clean up |
174
+
175
+ #### Static Convenience Methods (on Animotion singleton)
176
+
177
+ ```js
178
+ Animotion.to(target, props, options) // Standard tween (plays immediately)
179
+ Animotion.from(target, props, options) // Animate from props → current
180
+ Animotion.fromTo(target, fromProps, toProps, options) // Animate from → to
181
+ Animotion.set(target, props) // Instant set (duration = 0)
182
+ Animotion.inOut(target, inProps, outProps, options)
183
+ // Returns { enter, leave, playIn, playOut, reverse, kill }
184
+ Animotion.timeline(options) // Create a Timeline
185
+ Animotion.tween(target, props, options) // Create Tween (paused)
186
+ Animotion.spring(target, props, options) // Create SpringPhysics
187
+ Animotion.keyframes(target, frames, options)
188
+ Animotion.variants(target, variantMap, options) // Named variant states → { set, get, animate }
189
+ Animotion.path(target, options) // Create motion path Tween
190
+ Animotion.motionPath(target, options) // Alias for .path()
191
+ Animotion.sequence(scenes, options) // Create SceneSequence
192
+ ```
193
+
194
+ #### Animated Properties
195
+
196
+ **Transform properties** (auto-compose into `transform` CSS):
197
+ `x`, `y`, `z`, `scale`, `scaleX`, `scaleY`, `scaleZ`, `rotate`, `rotateX`, `rotateY`, `rotateZ`, `skewX`, `skewY`
198
+
199
+ **Filter properties** (auto-compose into `filter` CSS):
200
+ `blur`, `brightness`, `contrast`, `grayscale`, `hueRotate`, `invert`, `saturate`, `sepia`
201
+
202
+ **Other CSS properties**: `opacity`, `backgroundColor`, `color`, `width`, `height`, `padding`, `margin`, `borderRadius`, `boxShadow`, `top`, `left`, `right`, `bottom`, `scrollTop`, `scrollLeft`
203
+
204
+ **Custom CSS properties**: `--custom-prop`
205
+
206
+ **DOM attributes**: `attr.data-foo`
207
+ **Style sub-properties**: `style.someProperty`
208
+ **Nested object paths**: `object.nested.prop`
209
+
210
+ ---
211
+
212
+ ### Timeline
213
+
214
+ Sequences multiple tweens, labels, and callbacks.
215
+
216
+ ```js
217
+ import { Timeline } from 'animotionjs-plus';
218
+ const tl = new Timeline({ repeat: 1, yoyo: true });
219
+
220
+ tl.to('.box1', { x: 100 }, 0.5)
221
+ .to('.box2', { opacity: 0 }, 0.3, 'ease-in', '>')
222
+ .addLabel('middle')
223
+ .from('.box3', { scale: 0 }, 0.4, 'back-out')
224
+ .call(() => console.log('done!'), '+=0.5');
225
+ ```
226
+
227
+ #### Constructor
228
+
229
+ ```
230
+ new Timeline(config?)
231
+ ```
232
+
233
+ | Option | Type | Default | Description |
234
+ |--------|------|---------|-------------|
235
+ | `id` | `string` | auto | Timeline identifier |
236
+ | `autoplay` | `boolean` | `true` | Auto-start |
237
+ | `paused` | `boolean` | `false` | Start paused |
238
+ | `repeat` | `number` | `0` | Repeat count |
239
+ | `yoyo` | `boolean` | `true` | Reverse on repeat |
240
+ | `scope` | `Element \| null` | `null` | Query scope |
241
+ | `onComplete` | `() => void` | `null` | Completion callback |
242
+
243
+ #### Methods
244
+
245
+ | Method | Returns | Description |
246
+ |--------|---------|-------------|
247
+ | `.to(target, props, duration?, ease?, position?)` | `this` | Add tween |
248
+ | `.from(target, props, duration?, ease?, position?)` | `this` | Add from-tween |
249
+ | `.fromTo(target, fromProps, toProps, duration?, ease?, position?)` | `this` | Add fromTo tween |
250
+ | `.set(target, props, position?)` | `this` | Add instant set |
251
+ | `.call(callback, position?)` | `this` | Add function call |
252
+ | `.addLabel(name, position?)` | `this` | Add label |
253
+ | `.play()` | `void` | Play timeline |
254
+ | `.pause()` | `void` | Pause timeline |
255
+ | `.reverse()` | `void` | Toggle reverse |
256
+ | `.restart()` | `void` | Restart from 0 |
257
+ | `.seek(progress)` | `this` | Jump to 0–1 |
258
+ | `.progress(value?)` | `number \| void` | Get/set 0–1 progress |
259
+ | `.kill()` | `void` | Destroy timeline |
260
+
261
+ #### Position Parameter
262
+
263
+ | Value | Behavior |
264
+ |-------|----------|
265
+ | `number` | Absolute time in seconds |
266
+ | `'>'` (default) | End of timeline (append) |
267
+ | `'<'` | Start of previous item |
268
+ | `'+=N'` | N seconds after end |
269
+ | `'-=N'` | N seconds before end |
270
+ | `'label+=N'` | N seconds after label |
271
+ | Label name | At that label's position |
272
+
273
+ ---
274
+
275
+ ### Keyframes
276
+
277
+ Creates a Timeline from an array of frame objects.
278
+
279
+ ```js
280
+ import { Keyframes } from 'animotionjs-plus';
281
+ // Or from the singleton:
282
+ Animotion.keyframes('.box', [
283
+ { at: 0, to: { x: 0, opacity: 1 } },
284
+ { at: 0.5, to: { x: 100, rotate: 45 }, ease: 'bounce-out' },
285
+ { at: 1, to: { x: 200, opacity: 0 }, call: () => console.log('done') }
286
+ ], { duration: 2 });
287
+ ```
288
+
289
+ #### Signature
290
+
291
+ ```
292
+ keyframes(target, frames, options?) => Timeline
293
+ ```
294
+
295
+ Each frame can have:
296
+
297
+ | Frame Field | Type | Description |
298
+ |-------------|------|-------------|
299
+ | `at` / `position` | `string \| number` | Timeline position |
300
+ | `to` / `props` | `Record<string, any>` | Target properties |
301
+ | `from` | `Record<string, any>` | From-properties for fromTo |
302
+ | `duration` | `number` | Frame duration |
303
+ | `ease` | `string` | Easing for this frame |
304
+ | `label` | `string` | Add a label at this point |
305
+ | `call` | `() => void` | Function to call |
306
+ | `fromOnly` | `boolean` | Use `from` mode |
307
+ | `target` | target | Override target per frame |
308
+
309
+ ---
310
+
311
+ ### Easing
312
+
313
+ 30+ easing functions exported as named exports and accessible by string name.
314
+
315
+ ```js
316
+ import { Easing } from 'animotionjs-plus';
317
+
318
+ // Direct function
319
+ Easing.easeOutCubic(0.5); // ≈ 0.875
320
+
321
+ // String lookup
322
+ Easing.getEaseFunction('bounce-out')(0.5);
323
+
324
+ // List available easings
325
+ Easing.getAvailableEasings();
326
+ ```
327
+
328
+ #### Named Exports
329
+
330
+ **Quad**: `easeInQuad`, `easeOutQuad`, `easeInOutQuad`
331
+ **Cubic**: `easeInCubic`, `easeOutCubic`, `easeInOutCubic`
332
+ **Quart**: `easeInQuart`, `easeOutQuart`, `easeInOutQuart`
333
+ **Quint**: `easeInQuint`, `easeOutQuint`, `easeInOutQuint`
334
+ **Sine**: `easeInSine`, `easeOutSine`, `easeInOutSine`
335
+ **Expo**: `easeInExpo`, `easeOutExpo`, `easeInOutExpo`
336
+ **Circ**: `easeInCirc`, `easeOutCirc`, `easeInOutCirc`
337
+ **Back**: `easeInBack`, `easeOutBack`, `easeInOutBack`
338
+ **Elastic**: `easeInElastic`, `easeOutElastic`, `easeInOutElastic`
339
+ **Bounce**: `easeInBounce`, `easeOutBounce`, `easeInOutBounce`
340
+ **Other**: `linear`, `steps` (via `getEaseFunction`)
341
+
342
+ #### CSS Keyword Aliases
343
+
344
+ | Keyword | Maps to |
345
+ |---------|---------|
346
+ | `'ease'` | `easeOutCubic` |
347
+ | `'ease-in'` | `easeInQuad` |
348
+ | `'ease-out'` | `easeOutQuad` |
349
+ | `'ease-in-out'` | `easeInOutQuad` |
350
+ | `'none'` | `linear` |
351
+
352
+ #### GSAP-style Aliases
353
+
354
+ Any family can be written in GSAP dot notation or with `powerN` names:
355
+
356
+ | Name | Family |
357
+ |------|--------|
358
+ | `power0` | linear |
359
+ | `power1` | quad |
360
+ | `power2` | cubic |
361
+ | `power3` | quart |
362
+ | `power4` | quint |
363
+
364
+ - Directions: `.in`, `.out`, `.inOut` / `-in-out` — e.g. `'power2.inOut'`, `'power2-in-out'`, `'sine.in'`, `'expo.out'`.
365
+ - Bare family names resolve to their **`.out`** variant (GSAP parity): `'power2'` → `power2.out`, `'sine'` → `sine.out`.
366
+ - Dots and spaces normalize to `-`, case-insensitively: `'Power2 In Out'`, `'power2.inOut'` and `'power2-in-out'` are equivalent.
367
+
368
+ ```js
369
+ Animotion.to('.card', { y: 0, ease: 'power2.out' });
370
+ Animotion.to('.hero', { scale: 1, ease: 'expo.inOut' });
371
+ ```
372
+
373
+ #### Parameterized Eases
374
+
375
+ Eases with configurable parameters use call syntax (GSAP `.config()` parity):
376
+
377
+ ```js
378
+ Animotion.to('.box', { x: 300, ease: 'back-out(1.7)' });
379
+ Animotion.to('.box', { x: 300, ease: 'back.out(2)' }); // dot form works too
380
+ Animotion.to('.box', { x: 300, ease: 'elastic-out(1, 0.3)' }); // amplitude, period
381
+ Animotion.to('.box', { x: 300, ease: 'steps(5)' }); // jump count
382
+ Animotion.to('.box', { x: 300, ease: 'steps(5, start)' }); // direction: start | end | jump-start
383
+ ```
384
+
385
+ | Form | Parameters | Notes |
386
+ |------|-----------|-------|
387
+ | `back-in/out/in-out(n)` | overshoot (default `1.70158`) | Penner overshoot constant |
388
+ | `elastic-in/out/in-out(a, p)` | amplitude (default `1`), period (default `0.3`, `0.45` for inOut) | |
389
+ | `steps(n[, dir])` | count, direction (`end` default; also `start` / `jump-start`) | Lands on `1` at `t=1` |
390
+
391
+ - Registered custom eases are checked first, so `'my-ease(2)'` resolves the registered `my-ease` (params ignored).
392
+ - Unknown parameterized names fall back to the plain ease lookup (unknown → `linear`).
393
+
394
+ #### `getEaseFunction(name)` → `(t) => number`
395
+
396
+ Accepts names like `'linear'`, `'cubic-in'`, `'power2.inOut'`, `'bounce-in-out'`, parameterized forms like `'back-out(1.7)'` / `'steps(5)'`, a `[x1, y1, x2, y2]` cubic-bezier array, or a function (returned as-is).
397
+
398
+ #### `getAvailableEasings()` → `string[]`
399
+
400
+ Returns array of all recognized easing name strings.
401
+
402
+ #### CustomEase (SVG path easing)
403
+
404
+ Create easing functions from SVG cubic-bézier path data (GSAP `CustomEase` parity).
405
+
406
+ ```js
407
+ import { CustomEase, easeFromPath, registerEase } from 'animotionjs-plus';
408
+
409
+ // Register a named custom ease — usable anywhere a normal ease string is accepted
410
+ CustomEase.create('zajno-bounce',
411
+ 'M0,0 C0.05222,-0.59802 0.31828,-1.38625 0.55039,0 0.65208,-0.78892 0.94566,-0.58262 1,1');
412
+
413
+ Animotion.play('.hero', { x: 400, ease: 'zajno-bounce' });
414
+
415
+ // One-off ease function (not registered)
416
+ const ease = easeFromPath('M0,0 C0.5,1 0.5,0 1,1');
417
+ ease(0.5); // → number in 0..1
418
+
419
+ // Manual registry access
420
+ registerEase('my-ease', (t) => t * t);
421
+ unregisterEase('my-ease');
422
+ hasCustomEase('my-ease'); // → boolean
423
+ ```
424
+
425
+ | API | Returns | Description |
426
+ |-----|---------|-------------|
427
+ | `CustomEase.create(id, pathData)` | `(t) => number` | Parse path, register under `id`, return ease fn |
428
+ | `CustomEase.register(id, fn)` | `(t) => number` | Alias of `registerEase` |
429
+ | `CustomEase.getRatio(id)` | `(t) => number` | Look up a registered ease |
430
+ | `easeFromPath(pathData)` | `(t) => number` | Standalone parse — no registration |
431
+ | `registerEase(id, fn)` | `(t) => number` | Register any easing function |
432
+ | `unregisterEase(id)` | `boolean` | Remove a registered ease |
433
+ | `hasCustomEase(id)` | `boolean` | Check registration |
434
+
435
+ Notes:
436
+ - Path coordinates are normalized to `0..1` progress on both axes (works with `0..1` and `0..100` authored paths); x must be monotonic.
437
+ - Custom eases are checked **first** in `Easing.getEaseFunction`, so registered names override built-ins (matched case-insensitively, spaces → `-`).
438
+ - Supports SVG commands: `M L H V C S Q T A Z` (absolute + relative).
439
+ - Convenience: `Animotion.customEase(id, pathData)`.
440
+
441
+ ---
442
+
443
+ ### AnimationCore
444
+
445
+ Main orchestrator class. Manages all declarative animation parsing, registry maps, and lifecycle.
446
+
447
+ ```js
448
+ import { AnimationCore } from 'animotionjs-plus';
449
+ const core = new AnimationCore({ debug: true, attributePrefix: 'am' });
450
+ core.init();
451
+ ```
452
+
453
+ #### Constructor Options
454
+
455
+ | Option | Type | Default | Description |
456
+ |--------|------|---------|-------------|
457
+ | `debug` | `boolean` | `false` | Enable debug logging |
458
+ | `autoInit` | `boolean` | `true` | Auto-run init |
459
+ | `attributePrefix` | `string` | `'am'` | Prefix for data attributes |
460
+ | `root` | `Element \| string \| null` | `null` | Root element for queries |
461
+ | `observeMutations` | `boolean` | `false` | Watch DOM mutations |
462
+ | `legacyAttributes` | `boolean` | `true` | Support `data-anim-*` |
463
+ | `licenseKey` | `string` | `''` | License key |
464
+ | `licenseServerUrl` | `string` | `''` | License validation server |
465
+ | `adminEmail` | `string` | `''` | Admin email |
466
+ | `adminSecret` | `string` | `''` | Admin secret |
467
+
468
+ #### Methods
469
+
470
+ | Method | Description |
471
+ |--------|-------------|
472
+ | `.init()` | Initialize — parse all declarative attributes |
473
+ | `.destroy()` | Kill all animations, clean up |
474
+ | `.refresh()` | Destroy then re-init |
475
+ | `.getStats()` | Get counts of all managed instances |
476
+ | `.registerCleanup(fn)` | Register cleanup function |
477
+ | `.getAttr(element, name)` | Get attribute value (supports legacy) |
478
+ | `.hasAttr(element, name)` | Check attribute presence |
479
+ | `.parseAttrObject(element, name, fallback?)` | Parse JSON attribute |
480
+ | `.parseAttrString(element, name, fallback?)` | Get string attribute |
481
+ | `.parseAttrNumber(element, name, fallback?)` | Parse numeric attribute |
482
+ | `.parseAttrBoolean(element, name, fallback?)` | Parse boolean attribute |
483
+
484
+ ---
485
+
486
+ ### AnimationContext
487
+
488
+ Scoped animation context for use within components (React hooks, component-based setup).
489
+
490
+ ```js
491
+ import { AnimationContext } from 'animotionjs-plus';
492
+ const ctx = new AnimationContext({ scope: myElement });
493
+ const tween = ctx.to('.title', { opacity: 1 }, { duration: 0.5 });
494
+ ctx.revert(); // Clean up all animations
495
+ ```
496
+
497
+ #### Constructor
498
+
499
+ ```
500
+ new AnimationContext(options?)
501
+ ```
502
+
503
+ | Option | Type | Default | Description |
504
+ |--------|------|---------|-------------|
505
+ | `scope` | `Element \| null` | `null` | Scoped query root |
506
+
507
+ #### Methods
508
+
509
+ | Method | Returns | Description |
510
+ |--------|---------|-------------|
511
+ | `.add(instance)` | `instance` | Track an instance for cleanup |
512
+ | `.addCleanup(fn)` | `fn` | Register cleanup callback |
513
+ | `.tween(target, props, options?)` | `Tween` | Create and track a Tween |
514
+ | `.to(target, props, options?)` | `Tween` | Alias for tween |
515
+ | `.from(target, props, options?)` | `Tween` | From-tween |
516
+ | `.fromTo(target, fromProps, toProps, options?)` | `Tween` | FromTo tween |
517
+ | `.set(target, props, options?)` | `Tween` | Instant set (duration 0) |
518
+ | `.timeline(config?)` | `Timeline` | Create tracked Timeline |
519
+ | `.spring(target, props, options?)` | `SpringPhysics` | Create tracked Spring |
520
+ | `.keyframes(target, frames, options?)` | `Timeline` | Create tracked Keyframes |
521
+ | `.motionPath(target, options?)` | `Tween` | Create tracked motion path |
522
+ | `.sequence(scenes, options?)` | `SceneSequence` | Create tracked sequence |
523
+ | `.interactions(options?)` | `Interactions` | Create tracked Interactions |
524
+ | `.initAttributes(options?)` | `AnimationCore` | Init declarative attributes in scope |
525
+ | `.query(selector)` | `Element[]` | Query within scope |
526
+ | `.viewModel(name, schema?)` | `ViewModel` | Create a ViewModel |
527
+ | `.viewModelInstance(vm, data?, id?)` | `ViewModelInstance \| null` | Create VM instance |
528
+ | `.stateMachine(name, config?)` | `StateMachine` | Create a StateMachine |
529
+ | `.stateMachineInstance(sm, config?)` | `StateMachineInstance \| null` | Create SM instance |
530
+ | `.bind(config?)` | `Binding` | Create a data binding |
531
+ | `.revert()` | `void` | Kill all tracked instances |
532
+
533
+ ---
534
+
535
+ ## Scroll & View Features
536
+
537
+ ### ScrollTrigger
538
+
539
+ Triggers and scrubs animations based on scroll position.
540
+
541
+ ```js
542
+ import { ScrollTrigger } from 'animotionjs-plus';
543
+
544
+ const trigger = new ScrollTrigger({
545
+ trigger: '.section',
546
+ start: 'top center',
547
+ end: 'bottom center',
548
+ scrub: true,
549
+ pin: true,
550
+ animation: myTween,
551
+ onEnter: () => console.log('entered'),
552
+ onUpdate: ({ progress }) => console.log(progress)
553
+ });
554
+ ```
555
+
556
+ #### Constructor Options
557
+
558
+ | Option | Type | Default | Description |
559
+ |--------|------|---------|-------------|
560
+ | `trigger` | `Element \| string` | — | The trigger element |
561
+ | `start` | `string \| number` | `'top center'` | Start position expression |
562
+ | `end` | `string \| number` | `'bottom center'` | End position expression |
563
+ | `scrub` | `boolean \| number` | `false` | Link animation to scroll |
564
+ | `pin` | `boolean` | `false` | Pin the trigger element |
565
+ | `pinTarget` | `Element` | trigger | Element to pin |
566
+ | `pinSpacing` | `boolean` | `true` | Add spacer for pin |
567
+ | `pinClass` | `string` | `'am-pinned'` | CSS class when pinned |
568
+ | `animation` | `Tween \| Timeline \| object` | `null` | Animation to control |
569
+ | `reverse` | `boolean` | `false` | Reverse on scroll back |
570
+ | `once` | `boolean` | `false` | Fire only once |
571
+ | `markers` | `boolean` | `false` | Show debug markers |
572
+ | `smooth` | `boolean \| SmoothScrollOptions` | `false` | Enable smooth scroll |
573
+ | `snap` | `boolean` | `false` | Snap to position |
574
+ | `snapTo` | `string` | `'start'` | `'start'`, `'center'`, `'end'` |
575
+ | `duration` | `number` | `null` | Custom scroll distance |
576
+ | `onEnter` | `(trigger) => void` | `null` | When scrolling past start |
577
+ | `onLeave` | `(trigger) => void` | `null` | When scrolling past end |
578
+ | `onEnterBack` | `(trigger) => void` | `null` | When scrolling back past end |
579
+ | `onLeaveBack` | `(trigger) => void` | `null` | When scrolling back past start |
580
+ | `onUpdate` | `(state) => void` | `null` | Every scroll frame |
581
+
582
+ #### Position Expressions
583
+
584
+ Format: `"{element-anchor} {viewport-anchor}"`
585
+
586
+ Anchors: `top`, `center`, `bottom`, `100px`, `50%`, `100vh`, `+=200`, number
587
+
588
+ #### Methods
589
+
590
+ | Method | Description |
591
+ |--------|-------------|
592
+ | `.refresh()` | Recalculate bounds |
593
+ | `.kill()` | Remove event listeners, unpin |
594
+
595
+ #### Properties
596
+
597
+ | Property | Type | Description |
598
+ |----------|------|-------------|
599
+ | `.progress` | `number` | Current 0–1 progress |
600
+ | `.isActive` | `boolean` | Whether within scroll range |
601
+ | `.direction` | `number` | 1 (down) or -1 (up) |
602
+ | `.smoothScroll` | `SmoothScroll \| null` | Attached smooth scroll |
603
+
604
+ ---
605
+
606
+ ### SmoothScroll
607
+
608
+ Smooth scroll engine with configurable easing, snap points, and orientation.
609
+
610
+ ```js
611
+ import { SmoothScroll } from 'animotionjs-plus';
612
+
613
+ const ss = new SmoothScroll({
614
+ lerp: 0.075,
615
+ wheelMultiplier: 1,
616
+ orientation: 'vertical'
617
+ });
618
+
619
+ ss.scrollTo(500, { immediate: false });
620
+ ss.addSnapPoint(1000);
621
+ ```
622
+
623
+ #### Constructor Options
624
+
625
+ | Option | Type | Default | Description |
626
+ |--------|------|---------|-------------|
627
+ | `id` | `string` | `'default'` | Instance identifier |
628
+ | `lerp` | `number` | `0.075` | Interpolation factor |
629
+ | `duration` | `number` | `1` | Animation duration |
630
+ | `easing` | `(t) => number` | cubic ease-out | Custom easing |
631
+ | `wheelMultiplier` | `number` | `1` | Wheel sensitivity |
632
+ | `touchMultiplier` | `number` | `1.5` | Touch sensitivity |
633
+ | `smoothWheel` | `boolean` | `true` | Smooth wheel events |
634
+ | `smoothTouch` | `boolean` | `false` | Smooth touch events |
635
+ | `snapThreshold` | `number` | `100` | Snap activation distance |
636
+ | `snapDuration` | `number` | `500` | Snap animation (ms) |
637
+ | `infinite` | `boolean` | `false` | Infinite scroll |
638
+ | `orientation` | `string` | `'vertical'` | `'vertical'` or `'horizontal'` |
639
+
640
+ #### Methods
641
+
642
+ | Method | Description |
643
+ |--------|-------------|
644
+ | `.addSnapPoint(position)` | Add a snap point |
645
+ | `.removeSnapPoint(position)` | Remove a snap point |
646
+ | `.scrollTo(position, options?)` | Scroll to a position |
647
+ | `.start()` | Resume if stopped |
648
+ | `.stop()` | Stop the engine |
649
+ | `.kill()` | Destroy instance |
650
+
651
+ #### Static Methods
652
+
653
+ | Method | Description |
654
+ |--------|-------------|
655
+ | `.getInstance(id?)` | Get instance by id |
656
+ | `.create(options?)` | Create new instance |
657
+
658
+ ---
659
+
660
+ ### ParallaxEffect
661
+
662
+ Simple scroll parallax effect.
663
+
664
+ ```js
665
+ import { ParallaxEffect } from 'animotionjs-plus';
666
+ const parallax = new ParallaxEffect('.hero', { speed: 0.5, axis: 'y' });
667
+ // Later:
668
+ parallax.destroy();
669
+ ```
670
+
671
+ #### Constructor Options
672
+
673
+ | Option | Type | Default | Description |
674
+ |--------|------|---------|-------------|
675
+ | `speed` | `number` | `0.5` | Parallax speed multiplier |
676
+ | `axis` | `'x' \| 'y'` | `'y'` | Movement axis |
677
+
678
+ #### Methods
679
+
680
+ | Method | Description |
681
+ |--------|-------------|
682
+ | `.destroy()` | Remove scroll listener |
683
+
684
+ ---
685
+
686
+ ## Text Features
687
+
688
+ ### SplitText
689
+
690
+ Splits element text into individual characters, words, or lines for per-unit animation.
691
+
692
+ ```js
693
+ import { SplitText } from 'animotionjs-plus';
694
+
695
+ const split = new SplitText('.heading', { type: 'chars' });
696
+ split.chars.forEach((char, i) => {
697
+ Animotion.to(char, { opacity: 1, y: 0 }, {
698
+ duration: 0.5, delay: i * 0.05
699
+ });
700
+ });
701
+ ```
702
+
703
+ #### Constructor
704
+
705
+ ```
706
+ new SplitText(element, options?)
707
+ ```
708
+
709
+ | Option | Type | Default | Description |
710
+ |--------|------|---------|-------------|
711
+ | `type` | `'chars' \| 'words' \| 'lines'` | `'chars'` | Split mode |
712
+ | `id` | `string` | auto | Identifier |
713
+ | `spanClass` | `string` | `''` | CSS class on each span |
714
+ | `spanAttrs` | `Record<string, string>` | `{}` | Attributes on each span |
715
+
716
+ #### Properties (Readonly)
717
+
718
+ | Property | Type | Description |
719
+ |----------|------|-------------|
720
+ | `.chars` | `HTMLElement[]` | All char spans (regardless of type) |
721
+ | `.words` | `HTMLElement[]` | All word spans |
722
+ | `.lines` | `HTMLElement[]` | All line spans |
723
+ | `.spans` | `HTMLElement[]` | All spans in flat array |
724
+ | `.element` | `Element \| null` | The target element |
725
+ | `.id` | `string` | Instance ID |
726
+ | `.type` | `string` | Split type |
727
+
728
+ #### Methods
729
+
730
+ | Method | Returns | Description |
731
+ |--------|---------|-------------|
732
+ | `.split()` | `void` | Split text (called automatically) |
733
+ | `.getSpans(selector?)` | `HTMLElement[]` | Get spans by named selector |
734
+ | `.get(index)` | `HTMLElement[]` | Get by index, array, or named selector |
735
+ | `.getRange(start, end)` | `HTMLElement[]` | Get span range [start..end] |
736
+ | `.filter(callback)` | `HTMLElement[]` | Filter spans |
737
+ | `.replace(selector, content?)` | `this` | Replace span content |
738
+ | `.fill(content)` | `this` | Fill all spans |
739
+ | `.after(index, content)` | `this` | Insert content after span |
740
+ | `.before(index, content)` | `this` | Insert content before span |
741
+ | `.append(content)` | `this` | Append after last span |
742
+ | `.prepend(content)` | `this` | Prepend before first span |
743
+ | `.revert()` | `void` | Restore original text |
744
+
745
+ #### Named Selectors for `getSpans()`
746
+
747
+ `'all'`, `'chars'`, `'words'`, `'lines'`, `'first'`, `'last'`, `'index:5'`
748
+
749
+ ---
750
+
751
+ ### TextEffects
752
+
753
+ Standalone text animation functions.
754
+
755
+ ```js
756
+ import { TextEffects } from 'animotionjs-plus';
757
+ // Or: Animotion.TextEffects
758
+
759
+ TextEffects.typeText('.output', 'Hello World', { speed: 50, onComplete: () => {} });
760
+ TextEffects.scrambleText('.output', { duration: 2, chars: 'ABC123' });
761
+ TextEffects.counterAnimation('.counter', { from: 0, to: 100, duration: 2 });
762
+ TextEffects.blurEffect('.heading', { duration: 1 });
763
+ TextEffects.waveEffect('.heading', { duration: 2, wave: 15, speed: 1.5 });
764
+ TextEffects.morphText('.heading', 'New Text', { duration: 0.8 });
765
+ ```
766
+
767
+ #### `typeText(element, text, options?)`
768
+
769
+ | Option | Type | Default | Description |
770
+ |--------|------|---------|-------------|
771
+ | `speed` | `number` | `50` | Characters per second |
772
+ | `startDelay` | `number` | `0` | Delay before starting |
773
+ | `viewModel` | `ViewModelInstance` | `null` | VM to sync progress |
774
+ | `vmProperty` | `string` | `null` | VM property for char index |
775
+ | `onComplete` | `() => void` | `null` | Completion callback |
776
+
777
+ #### `scrambleText(element, options?)`
778
+
779
+ | Option | Type | Default | Description |
780
+ |--------|------|---------|-------------|
781
+ | `chars` | `string` | `'01234...'` | Character set for scrambling |
782
+ | `duration` | `number` | `1` | Duration in seconds |
783
+ | `revealDelay` | `number` | `0.05` | Delay per character |
784
+ | `onComplete` | `() => void` | `null` | Completion callback |
785
+
786
+ #### `counterAnimation(element, options?)`
787
+
788
+ | Option | Type | Default | Description |
789
+ |--------|------|---------|-------------|
790
+ | `from` | `number` | `0` | Start number |
791
+ | `to` | `number` | `100` | End number |
792
+ | `duration` | `number` | `1` | Animation duration |
793
+ | `ease` | `(t) => number` | linear | Custom easing |
794
+ | `prefix` | `string` | `''` | Text before number |
795
+ | `suffix` | `string` | `''` | Text after number |
796
+ | `viewModel` | `ViewModelInstance` | `null` | VM to sync |
797
+ | `vmProperty` | `string` | `null` | VM property for value |
798
+ | `onComplete` | `() => void` | `null` | Completion callback |
799
+
800
+ #### `blurEffect(element, options?)`
801
+
802
+ | Option | Type | Default | Description |
803
+ |--------|------|---------|-------------|
804
+ | `duration` | `number` | `1` | Duration |
805
+ | `onComplete` | `() => void` | `null` | Callback |
806
+
807
+ #### `waveEffect(element, options?)`
808
+
809
+ | Option | Type | Default | Description |
810
+ |--------|------|---------|-------------|
811
+ | `duration` | `number` | `1` | Duration |
812
+ | `wave` | `number` | `10` | Wave amplitude (px) |
813
+ | `speed` | `number` | `1` | Wave speed multiplier |
814
+ | `onComplete` | `() => void` | `null` | Callback |
815
+
816
+ #### `morphText(element, text, options?)`
817
+
818
+ | Option | Type | Default | Description |
819
+ |--------|------|---------|-------------|
820
+ | `from` | `string` | current text | Source text |
821
+ | `duration` | `number` | `0.8` | Duration |
822
+ | `ease` | `(t) => number` | linear | Easing function |
823
+ | `onComplete` | `() => void` | `null` | Callback |
824
+
825
+ ---
826
+
827
+ ## Interaction & Physics
828
+
829
+ ### Draggable
830
+
831
+ Makes an element draggable with optional viewModel sync.
832
+
833
+ ```js
834
+ import { Draggable } from 'animotionjs-plus';
835
+ const drag = new Draggable('.handle', {
836
+ lockAxis: 'x',
837
+ bounds: '.container',
838
+ onDrag: ({ x, y }) => console.log(x, y)
839
+ });
840
+ // Later:
841
+ drag.destroy();
842
+ ```
843
+
844
+ #### Constructor Options
845
+
846
+ | Option | Type | Default | Description |
847
+ |--------|------|---------|-------------|
848
+ | `bounds` | `Element \| string \| null` | `null` | Bounding element |
849
+ | `lockAxis` | `'x' \| 'y' \| null` | `null` | Constrain axis |
850
+ | `cursor` | `string` | `'grab'` | Default cursor |
851
+ | `activeCursor` | `string` | `'grabbing'` | Drag cursor |
852
+ | `viewModel` | `ViewModelInstance` | `null` | VM to sync position |
853
+ | `vmX` | `string` | `null` | VM property for X |
854
+ | `vmY` | `string` | `null` | VM property for Y |
855
+ | `onDragStart` | `() => void` | `null` | Drag start callback |
856
+ | `onDrag` | `({ x, y }) => void` | `null` | Drag move callback |
857
+ | `onDragEnd` | `({ x, y }) => void` | `null` | Drag end callback |
858
+
859
+ #### Methods
860
+
861
+ | Method | Description |
862
+ |--------|-------------|
863
+ | `.destroy()` | Remove event listeners |
864
+
865
+ ---
866
+
867
+ ### SpringPhysics
868
+
869
+ Mass-spring-damper physics animation.
870
+
871
+ ```js
872
+ import { SpringPhysics } from 'animotionjs-plus';
873
+ const spring = new SpringPhysics('.box', { x: 200 }, {
874
+ stiffness: 170, damping: 26, mass: 1
875
+ });
876
+ ```
877
+
878
+ #### Constructor
879
+
880
+ ```
881
+ new SpringPhysics(target, props, options?)
882
+ ```
883
+
884
+ | Option | Type | Default | Description |
885
+ |--------|------|---------|-------------|
886
+ | `stiffness` | `number` | `170` | Spring stiffness |
887
+ | `damping` | `number` | `26` | Damping factor |
888
+ | `mass` | `number` | `1` | Mass |
889
+ | `precision` | `number` | `0.01` | Settlement precision |
890
+ | `maxDuration` | `number` | `8` | Max animation seconds |
891
+ | `ease` | `string` | `null` | Optional ease override |
892
+ | `paused` | `boolean` | `false` | Start paused |
893
+ | `onUpdate` | `(spring) => void` | `null` | Per-frame callback |
894
+ | `onComplete` | `(spring) => void` | `null` | Completion callback |
895
+
896
+ #### Methods
897
+
898
+ | Method | Returns | Description |
899
+ |--------|---------|-------------|
900
+ | `.play()` | `this` | Start |
901
+ | `.pause()` | `this` | Pause |
902
+ | `.seek(progress)` | `this` | Jump to 0–1 progress |
903
+ | `.kill()` | `void` | Destroy |
904
+
905
+ ---
906
+
907
+ ### PhysicsEngine
908
+
909
+ Matter.js-backed rigid-body physics with DOM synchronization.
910
+
911
+ ```js
912
+ import { PhysicsEngine } from 'animotionjs-plus';
913
+
914
+ const engine = new PhysicsEngine('#stage', { width: 800, height: 600 });
915
+ const ball = engine.addBody({ x: 100, y: 50, radius: 20, shape: 'circle' });
916
+ engine.setGravity({ y: 1 });
917
+ engine.start();
918
+
919
+ // Let users grab and throw bodies with the mouse/touch
920
+ engine.enableMouseDrag(null, {
921
+ stiffness: 0.4,
922
+ onDragStart: (body) => console.log('grabbed', body.label),
923
+ onDragEnd: (body) => console.log('released', body.label)
924
+ });
925
+ ```
926
+
927
+ #### Constructor
928
+
929
+ ```
930
+ new PhysicsEngine(container, config?)
931
+ ```
932
+
933
+ `container` is the DOM element that receives drag/touch listeners and whose
934
+ bounds (walls) constrain the world. `config`: `{ width, height, wallThickness,
935
+ wallOptions, gravity, autoStart, engine, debug }`.
936
+
937
+ #### Methods
938
+
939
+ | Method | Returns | Description |
940
+ |--------|---------|-------------|
941
+ | `.addBody(options)` | `Matter.Body` | `{ x, y, radius\|width/height, shape: 'circle'\|'rectangle'\|'polygon', type: 'static', label, ... }` |
942
+ | `.setGravity({ x, y })` | `void` | Update engine gravity |
943
+ | `.step(dt?)` | `void` | Advance one frame |
944
+ | `.start()` / `.stop()` | `void` | Start/stop the RAF loop |
945
+ | `.onCollision(fn)` | `void` | `(evt) => void` — `evt = { bodyA, bodyB, phase, pair }` |
946
+ | `.getBodyByLabel(label)` | `Matter.Body \| null` | Lookup |
947
+ | `.enableMouseDrag(target?, options?)` | `MouseConstraint \| null` | Drag bodies with mouse/touch |
948
+ | `.disableMouseDrag()` | `void` | Remove constraint + listeners |
949
+ | `.destroy()` | `void` | Full cleanup (incl. mouse drag) |
950
+
951
+ #### Mouse drag options (`MouseDragOptions`)
952
+
953
+ | Option | Type | Default | Description |
954
+ |--------|------|---------|-------------|
955
+ | `target` | `Element \| string \| null` | physics container | Element that receives pointer listeners |
956
+ | `stiffness` | `number` | `0.2` | Constraint stiffness |
957
+ | `damping` | `number` | `0.1` | Constraint damping |
958
+ | `collisionFilter` | `object` | — | Matter collision filter (only passed through when defined) |
959
+ | `preventDefaultScroll` | `boolean` | `true` | Remove `wheel`/`DOMMouseScroll` listeners on the target so dragging never scrolls the page |
960
+ | `onDragStart` / `onDragEnd` / `onMouseMove` | `(body) => void` | — | Drag lifecycle callbacks |
961
+
962
+ Notes:
963
+ - The `MouseConstraint` is a public property: `engine.mouseConstraint`.
964
+ - Calling `enableMouseDrag()` again replaces the previous constraint.
965
+ - `disableMouseDrag()` fully unbinds Matter's `mousemove`/`mousedown`/`mouseup`/
966
+ `touchmove`/`touchstart`/`touchend` listeners (Matter's own
967
+ `Mouse.clearSourceEvents` does not remove them) and its `beforeUpdate` hook —
968
+ `destroy()` calls this automatically.
969
+
970
+ ---
971
+
972
+ ### Interactions
973
+
974
+ Event-driven interaction system with state machine integration.
975
+
976
+ ```js
977
+ import { Interactions } from 'animotionjs-plus';
978
+
979
+ const interactions = new Interactions();
980
+ interactions.on('.btn', 'click', {
981
+ animation: { scale: 1.2 },
982
+ duration: 0.3,
983
+ autoReverse: true
984
+ });
985
+
986
+ interactions.on('.card', 'hover', {
987
+ animation: { y: -10, boxShadow: '0 10px 20px rgba(0,0,0,0.2)' },
988
+ duration: 0.2
989
+ });
990
+
991
+ interactions.bindStateMachine('.btn', 'click', 'mySM', 'toggle');
992
+ ```
993
+
994
+ #### Event Types
995
+
996
+ `'click'`, `'hover'`, `'focus'`, `'touch'`, `'pointer'`, `'keyboard'`, `'doubletap'`, `'longpress'`, `'swipe'`, `'wheel'`, or any custom DOM event.
997
+
998
+ #### Methods
999
+
1000
+ | Method | Description |
1001
+ |--------|-------------|
1002
+ | `.on(target, eventType, config)` | Register interaction |
1003
+ | `.off(target, eventType)` | Remove interaction |
1004
+ | `.offAll()` | Remove all |
1005
+ | `.bindStateMachine(target, eventType, sm, triggerName?)` | Wire SM to event |
1006
+ | `.getStats()` | Get interaction counts |
1007
+ | `static .initFromDOM()` | Init from `data-anim-*` attributes |
1008
+
1009
+ ---
1010
+
1011
+ ### MotionPath
1012
+
1013
+ Animate an element along an SVG path or point array.
1014
+
1015
+ ```js
1016
+ import { motionPath } from 'animotionjs-plus';
1017
+ // Or from the singleton:
1018
+ Animotion.path('.plane', {
1019
+ path: document.querySelector('#flightPath'),
1020
+ duration: 3,
1021
+ autoRotate: true,
1022
+ ease: 'linear'
1023
+ });
1024
+ ```
1025
+
1026
+ #### Parameters
1027
+
1028
+ ```
1029
+ motionPath(target, options?) => Tween
1030
+ ```
1031
+
1032
+ | Option | Type | Default | Description |
1033
+ |--------|------|---------|-------------|
1034
+ | `path` | `SVGGeometryElement \| {x,y}[]` | `[]` | SVG path or point array |
1035
+ | `points` | `{x,y}[]` | `[]` | Alternative to path |
1036
+ | `from` | `number` | `0` | Start progress (0–1) |
1037
+ | `to` | `number` | `1` | End progress (0–1) |
1038
+ | `autoRotate` | `boolean` | `false` | Rotate along path |
1039
+ | `rotate` | `boolean` | `false` | Alias for autoRotate |
1040
+ | `x` | `string` | `'x'` | Property for X position |
1041
+ | `y` | `string` | `'y'` | Property for Y position |
1042
+ | `rotatePath` | `string` | `'rotate'` | Property for rotation |
1043
+ | `align` | `boolean \| Element \| string` | `undefined` | Map path coordinates into an element's space (`true` = path's owner SVG, selector or element otherwise) |
1044
+ | `alignOrigin` | `[number, number] \| number` | — | Anchor point within the target, `0..1` per axis (defaults to `[0.5, 0.5]` when `align` is set) |
1045
+ | `duration`, `ease`, `delay`, etc. | (TweenOptions) | — | Standard tween options |
1046
+
1047
+ #### Aligning to an element
1048
+
1049
+ ```js
1050
+ motionPath('.cursor', {
1051
+ path: document.querySelector('#trace'),
1052
+ align: '#panel', // path coords become local coords of #panel
1053
+ alignOrigin: [0, 0], // anchor at the target's top-left corner
1054
+ duration: 2
1055
+ });
1056
+ ```
1057
+
1058
+ With `align`, path points are transformed into page space using the align
1059
+ element's bounding box (plus SVG viewBox scaling when aligning to an SVG),
1060
+ and the target's current static position is subtracted each frame — so it
1061
+ works with layout offsets, `transform: translate()` already on the element,
1062
+ and scroll-driven mode. When neither option is given, behavior is unchanged.
1063
+
1064
+ ---
1065
+
1066
+ ### SceneSequence
1067
+
1068
+ Declarative scene-based timeline.
1069
+
1070
+ ```js
1071
+ import { SceneSequence } from 'animotionjs-plus';
1072
+
1073
+ const seq = new SceneSequence([
1074
+ { id: 'intro', enter: { target: '.title', to: { opacity: 1 }, duration: 0.5 } },
1075
+ { id: 'content', enter: { to: { y: 0 }, duration: 0.8 }, call: (seq, scene) => {} }
1076
+ ], { autoplay: true });
1077
+
1078
+ seq.play();
1079
+ ```
1080
+
1081
+ #### Constructor
1082
+
1083
+ ```
1084
+ new SceneSequence(scenes, options?)
1085
+ ```
1086
+
1087
+ Each scene can have:
1088
+
1089
+ | Field | Type | Description |
1090
+ |-------|------|-------------|
1091
+ | `id` / `label` | `string` | Scene identifier / label |
1092
+ | `at` / `position` | `string \| number` | Timeline position |
1093
+ | `enter` | `object \| object[]` | Tween config(s) to execute |
1094
+ | `call` | `(seq, scene) => void` | Callback at this scene |
1095
+ | `duration` | `number` | Default duration |
1096
+ | `ease` | `string` | Default easing |
1097
+
1098
+ #### Methods
1099
+
1100
+ | Method | Returns | Description |
1101
+ |--------|---------|-------------|
1102
+ | `.play()` | `this` | Play the sequence |
1103
+ | `.pause()` | `this` | Pause |
1104
+ | `.restart()` | `this` | Restart |
1105
+ | `.seek(progress)` | `this` | Jump to 0–1 |
1106
+ | `.progress(value?)` | `number \| void` | Get/set progress |
1107
+ | `.kill()` | `void` | Destroy |
1108
+
1109
+ ---
1110
+
1111
+ ## Media Features
1112
+
1113
+ ### VideoAnimation
1114
+
1115
+ Controls video playback with segment scrubbing.
1116
+
1117
+ ```js
1118
+ import { VideoAnimation } from 'animotionjs-plus';
1119
+ const video = new VideoAnimation('.video-container', {
1120
+ src: '/videos/intro.mp4',
1121
+ muted: true,
1122
+ frameRate: 30,
1123
+ segment: [0, 5] // play 0–5 seconds
1124
+ });
1125
+ video.scrubToProgress(0.5);
1126
+ video.playSegment([2, 8], { loop: false });
1127
+ ```
1128
+
1129
+ #### Constructor Options
1130
+
1131
+ | Option | Type | Default | Description |
1132
+ |--------|------|---------|-------------|
1133
+ | `src` | `string` | — | Video source URL |
1134
+ | `autoplay` | `boolean \| 'load'` | `false` | Autoplay on load |
1135
+ | `muted` | `boolean` | `true` | Muted |
1136
+ | `loop` | `boolean` | `false` | Loop |
1137
+ | `controls` | `boolean` | `false` | Show controls |
1138
+ | `objectFit` | `string` | `'cover'` | CSS object-fit |
1139
+ | `frameRate` | `number` | `30` | Frame rate |
1140
+ | `segment` / `frames` | `string \| number[] \| object` | `null` | Default segment |
1141
+ | `sections` | `Record<string, segment>` | `{}` | Named segments |
1142
+ | `video` | `HTMLVideoElement` | `null` | Existing video element |
1143
+ | `viewModel` / `vmProgress` / `vmPlaying` | — | — | ViewModel sync |
1144
+
1145
+ #### Methods
1146
+
1147
+ | Method | Returns | Description |
1148
+ |--------|---------|-------------|
1149
+ | `.play()` | `this` | Play |
1150
+ | `.pause()` | `this` | Pause |
1151
+ | `.scrubToProgress(progress)` | `void` | Set position by 0–1 |
1152
+ | `.seekSegment(segment)` | `this` | Jump to segment start |
1153
+ | `.playSegment(segment, options?)` | `this` | Play a segment |
1154
+ | `.playFrames(startFrame, endFrame, options?)` | `this` | Play frame range |
1155
+ | `.destroy()` | `void` | Clean up |
1156
+
1157
+ ---
1158
+
1159
+ ### AudioAnimation
1160
+
1161
+ Controls audio playback with segment scrubbing.
1162
+
1163
+ ```js
1164
+ import { AudioAnimation } from 'animotionjs-plus';
1165
+ const audio = new AudioAnimation('.audio-el', {
1166
+ src: '/audio/track.mp3',
1167
+ volume: 0.8,
1168
+ segment: [10, 30]
1169
+ });
1170
+ audio.play();
1171
+ audio.scrubToProgress(0.25);
1172
+ ```
1173
+
1174
+ #### Constructor Options
1175
+
1176
+ | Option | Type | Default | Description |
1177
+ |--------|------|---------|-------------|
1178
+ | `src` | `string` | — | Audio source |
1179
+ | `autoplay` | `boolean \| 'load'` | `false` | Autoplay on load |
1180
+ | `muted` | `boolean` | `false` | Muted |
1181
+ | `loop` | `boolean` | `false` | Loop |
1182
+ | `volume` | `number` | `1` | Volume (0–1) |
1183
+ | `preload` | `string` | `'auto'` | Preload attribute |
1184
+ | `segment` | `string \| number[] \| object` | `null` | Default segment |
1185
+ | `audio` | `HTMLAudioElement` | `null` | Existing audio element |
1186
+ | `viewModel` / `vmProgress` / `vmPlaying` | — | — | VM sync |
1187
+
1188
+ #### Methods
1189
+
1190
+ | Method | Returns | Description |
1191
+ |--------|---------|-------------|
1192
+ | `.play()` | `this` | Play |
1193
+ | `.pause()` | `this` | Pause |
1194
+ | `.stop()` | `this` | Stop and seek to 0 |
1195
+ | `.seek(time)` | `this` | Seek to time in seconds |
1196
+ | `.setVolume(volume)` | `this` | Set volume (0–1) |
1197
+ | `.scrubToProgress(progress)` | `this` | Set position by 0–1 |
1198
+ | `.playSegment(segment, options?)` | `this` | Play a segment |
1199
+ | `.destroy()` | `void` | Clean up |
1200
+
1201
+ ---
1202
+
1203
+ ### PNGSequence
1204
+
1205
+ Canvas-based PNG frame sequence player.
1206
+
1207
+ ```js
1208
+ import { PNGSequence } from 'animotionjs-plus';
1209
+ const seq = new PNGSequence({
1210
+ container: '.player',
1211
+ src: '/images/frames/',
1212
+ frameCount: 120,
1213
+ frameRate: 30,
1214
+ prefix: 'frame_',
1215
+ suffix: '.png',
1216
+ digits: 4,
1217
+ loop: true,
1218
+ autoplay: true
1219
+ });
1220
+
1221
+ seq.on((event, data) => {
1222
+ if (event === 'complete') console.log('Done!');
1223
+ });
1224
+ ```
1225
+
1226
+ #### Constructor Options
1227
+
1228
+ | Option | Type | Default | Description |
1229
+ |--------|------|---------|-------------|
1230
+ | `container` | `string \| HTMLElement` | — | Container for canvas |
1231
+ | `src` | `string` | — | Base path for frames |
1232
+ | `frameCount` / `frames` | `number` | — | Number of frames |
1233
+ | `frameRate` | `number` | `30` | Playback frame rate |
1234
+ | `prefix` | `string` | `''` | Filename prefix |
1235
+ | `suffix` | `string` | `'.png'` | Filename suffix |
1236
+ | `digits` | `number` | `4` | Zero-pad digits |
1237
+ | `startFrame` | `number` | `0` | Starting frame index |
1238
+ | `urlPattern` | `string` | `null` | Custom URL pattern (`%d`) |
1239
+ | `loop` | `boolean` | `true` | Loop playback |
1240
+ | `autoplay` | `boolean` | `false` | Autoplay on load |
1241
+ | `crossOrigin` | `string` | `'anonymous'` | CORS setting |
1242
+ | `width` / `height` | `number` | — | Canvas dimensions |
1243
+ | `viewModel` / `vmProgress` / `vmFrame` / `vmPlaying` | — | — | VM sync |
1244
+ | `onComplete` | `(seq) => void` | `null` | Completion callback |
1245
+ | `onFrame` | `(state) => void` | `null` | Per-frame callback |
1246
+
1247
+ #### Methods
1248
+
1249
+ | Method | Returns | Description |
1250
+ |--------|---------|-------------|
1251
+ | `.mount(container, width?, height?)` | `void` | Create canvas in container |
1252
+ | `.load(options?)` | `this` | Load image frames |
1253
+ | `.play()` | `this` | Start playback |
1254
+ | `.pause()` | `this` | Pause |
1255
+ | `.stop()` | `this` | Stop and reset to frame 0 |
1256
+ | `.seek(frameOrProgress)` | `this` | Jump to frame or 0–1 progress |
1257
+ | `.scrubToProgress(progress)` | `this` | Alias for seek |
1258
+ | `.setFrame(frame)` | `this` | Set specific frame |
1259
+ | `.setProgress(progress)` | `this` | Set by 0–1 progress |
1260
+ | `.getProgress()` | `number` | Current 0–1 progress |
1261
+ | `.getCurrentFrame()` | `number` | Current frame index |
1262
+ | `.getTotalFrames()` | `number` | Total frame count |
1263
+ | `.setFrameRate(fps)` | `this` | Change frame rate |
1264
+ | `.setLoop(loop)` | `this` | Toggle loop |
1265
+ | `.resize(width?, height?)` | `this` | Resize canvas |
1266
+ | `.on(listener)` | `this` | Add event listener |
1267
+ | `.off(listener)` | `this` | Remove listener |
1268
+ | `.then(resolve)` | `this` | Promise-like on load |
1269
+ | `.destroy()` | `void` | Clean up |
1270
+ | `static .create(options)` | `PNGSequence` | Factory method |
1271
+
1272
+ #### Events (via `.on()`)
1273
+
1274
+ `'loaded'`, `'play'`, `'pause'`, `'stop'`, `'frame'`, `'loop'`, `'complete'`
1275
+
1276
+ ---
1277
+
1278
+ ## Layouts
1279
+
1280
+ Element positioning engine with multiple layout algorithms.
1281
+
1282
+ ```js
1283
+ import { Layouts } from 'animotionjs-plus';
1284
+
1285
+ const layout = new Layouts('.container', {
1286
+ type: 'circular',
1287
+ radius: 200,
1288
+ startAngle: 0,
1289
+ endAngle: 360,
1290
+ animate: true,
1291
+ duration: 1,
1292
+ stagger: 0.05
1293
+ });
1294
+
1295
+ // Or via singleton:
1296
+ Animotion.layouts('.container', { type: 'spiral', turns: 4 });
1297
+ ```
1298
+
1299
+ #### Constructor Options
1300
+
1301
+ | Option | Type | Default | Description |
1302
+ |--------|------|---------|-------------|
1303
+ | `type` | `LayoutType` | — | Layout algorithm |
1304
+ | `responsive` | `boolean` | `true` | Recalculate on resize |
1305
+ | `centerX` / `centerY` | `number \| string` | `'50%'` | Center point |
1306
+ | `animate` | `boolean` | `false` | Animate position changes |
1307
+ | `duration` | `number` | `1` | Animation duration |
1308
+ | `ease` | `string` | `'ease-out'` | Animation easing |
1309
+ | `stagger` | `number` | `0` | Per-item delay |
1310
+ | `items` / `target` | `string \| Element \| Element[]` | children | Items to arrange |
1311
+ | `viewModel` / `vmItems` | — | — | VM sync |
1312
+
1313
+ #### Methods
1314
+
1315
+ | Method | Returns | Description |
1316
+ |--------|---------|-------------|
1317
+ | `.setOptions(options)` | `this` | Update options |
1318
+ | `.setItems(items?)` | `this` | Set items |
1319
+ | `.circular(options?)` | `this` | Circular layout |
1320
+ | `.orbit(options?)` | `this` | Orbital layout |
1321
+ | `.spiral(options?)` | `this` | Spiral layout |
1322
+ | `.wave(options?)` | `this` | Wave layout |
1323
+ | `.scatter(options?)` | `this` | Scatter layout |
1324
+ | `.radialTree(options?)` | `this` | Radial tree layout |
1325
+ | `.refresh()` | `this` | Reapply current layout |
1326
+ | `.destroy()` | `void` | Clean up and restore |
1327
+
1328
+ ---
1329
+
1330
+ ### Layout Types
1331
+
1332
+ #### Circular
1333
+
1334
+ ```js
1335
+ layout.circular({ radius: 150, startAngle: 0, endAngle: 360, reverse: false, rotateItems: false });
1336
+ ```
1337
+
1338
+ #### Orbit
1339
+
1340
+ ```js
1341
+ layout.orbit({ rings: 3, ringSpacing: 80, startAngle: 0 });
1342
+ ```
1343
+
1344
+ #### Spiral
1345
+
1346
+ ```js
1347
+ layout.spiral({ turns: 4, startAngle: 0 });
1348
+ ```
1349
+
1350
+ #### Wave
1351
+
1352
+ ```js
1353
+ layout.wave({ amplitude: 60, frequency: 1, phase: 0, axis: 'y' });
1354
+ ```
1355
+
1356
+ #### Scatter
1357
+
1358
+ ```js
1359
+ layout.scatter({ spread: 150, rotationRange: 15 });
1360
+ ```
1361
+
1362
+ #### Radial Tree
1363
+
1364
+ ```js
1365
+ layout.radialTree({ levels: 3, angleSpread: 120, levelSpacing: 80 });
1366
+ ```
1367
+
1368
+ ---
1369
+
1370
+ ## Integrations
1371
+
1372
+ ### WebGLSupport
1373
+
1374
+ WebGL shader rendering with full-screen or element-attached canvas.
1375
+
1376
+ ```js
1377
+ import { WebGLSupport } from 'animotionjs-plus';
1378
+
1379
+ // Basic shader
1380
+ const shader = WebGLSupport.createShader('.hero', {
1381
+ fragment: `
1382
+ precision mediump float;
1383
+ uniform float u_time;
1384
+ void main() {
1385
+ gl_FragColor = vec4(0.5 + 0.5 * sin(u_time), 0.0, 0.0, 1.0);
1386
+ }
1387
+ `,
1388
+ uniforms: { u_speed: 1.0 }
1389
+ });
1390
+
1391
+ shader.tweenUniforms({ u_speed: 5.0 }, { duration: 2, ease: 'ease-in-out' });
1392
+
1393
+ // Via singleton:
1394
+ Animotion.shader('.hero', { fragment: '...' });
1395
+ ```
1396
+
1397
+ #### Static Methods
1398
+
1399
+ | Method | Returns | Description |
1400
+ |--------|---------|-------------|
1401
+ | `.isSupported()` | `boolean` | Check WebGL support |
1402
+ | `.createContext(canvas, options?)` | `WebGLRenderingContext \| null` | Create GL context |
1403
+ | `.createShader(targetOrOptions, options?)` | `ShaderController` | Create shader |
1404
+ | `.shader(targetOrOptions, options?)` | `ShaderController` | Alias |
1405
+
1406
+ #### ShaderController
1407
+
1408
+ | Method | Returns | Description |
1409
+ |--------|---------|-------------|
1410
+ | `.setUniform(name, value)` | `this` | Set uniform value |
1411
+ | `.tweenUniforms(uniforms, options?)` | `Tween` | Animate uniforms |
1412
+ | `.scrubToProgress(progress)` | `this` | Set `u_progress` uniform |
1413
+ | `.play()` | `this` | Start animation loop |
1414
+ | `.pause()` | `this` | Pause |
1415
+ | `.render()` | `this` | Render single frame |
1416
+ | `.resize()` | `this` | Handle resize |
1417
+ | `.destroy()` | `void` | Clean up |
1418
+
1419
+ **Default uniforms**: `u_time`, `u_resolution`, `u_mouse`, `u_progress`, `u_texture`, `u_hasTexture`
1420
+
1421
+ #### ShaderOptions
1422
+
1423
+ | Option | Type | Default | Description |
1424
+ |--------|------|---------|-------------|
1425
+ | `target` / `element` / `container` | `Element \| string` | — | Attach target |
1426
+ | `canvas` | `HTMLCanvasElement` | auto | Existing canvas |
1427
+ | `vertex` | `string` | default VS | Vertex shader source |
1428
+ | `fragment` | `string` | default FS | Fragment shader source |
1429
+ | `uniforms` | `Record<string, any>` | `{}` | Custom uniforms |
1430
+ | `texture` / `image` / `video` | `string \| media` | — | Media texture |
1431
+ | `background` | `boolean` | `true` | Cover target as BG |
1432
+ | `autoplay` | `boolean` | `true` | Start animation |
1433
+ | `fit` | `string` | `'cover'` | Canvas fitting |
1434
+ | `pixelRatio` | `number` | `min(dpr, 2)` | Pixel ratio |
1435
+ | `zIndex` | `number` | `-1` | Canvas z-index |
1436
+ | `onRender` | `(shader) => void` | `null` | Per-frame callback |
1437
+
1438
+ ---
1439
+
1440
+ ### ThreeJsSupport
1441
+
1442
+ Three.js integration for tweening 3D objects and animation state machines.
1443
+
1444
+ ```js
1445
+ import { ThreeJsSupport } from 'animotionjs-plus';
1446
+
1447
+ // Tween a Three.js object
1448
+ ThreeJsSupport.tween(mesh.position, { x: 5, y: 3 }, {
1449
+ duration: 2,
1450
+ ease: 'ease-out',
1451
+ renderer,
1452
+ scene,
1453
+ camera
1454
+ });
1455
+
1456
+ // Orbit animation
1457
+ ThreeJsSupport.orbit(mesh, {
1458
+ radius: 5,
1459
+ fromAngle: 0,
1460
+ toAngle: Math.PI * 2,
1461
+ center: { x: 0, y: 0, z: 0 },
1462
+ duration: 4,
1463
+ renderer,
1464
+ scene,
1465
+ camera
1466
+ });
1467
+
1468
+ // GLTF Animation State Machine
1469
+ const machine = ThreeJsSupport.createAnimationStateMachine(gltfModel, {
1470
+ clips: gltfModel.animations,
1471
+ renderer,
1472
+ scene,
1473
+ camera,
1474
+ initialState: 'idle',
1475
+ fade: 0.25
1476
+ });
1477
+ machine.play('walk');
1478
+ ```
1479
+
1480
+ #### Static Methods
1481
+
1482
+ | Method | Returns | Description |
1483
+ |--------|---------|-------------|
1484
+ | `.isLoaded()` | `boolean` | Check `window.THREE` |
1485
+ | `.resolveLibrary(library?)` | `THREE` | Get Three.js lib |
1486
+ | `.tween(target, props, options?)` | `Tween` | Tween 3D object |
1487
+ | `.orbit(object, options?)` | `Tween` | Orbit 3D object |
1488
+ | `.createAnimationStateMachine(gltfOrRoot, options?)` | `Object` | GLTF animation SM |
1489
+ | `.gltfStateMachine(gltfOrRoot, options?)` | `Object` | Alias |
1490
+
1491
+ #### GLTF State Machine Object
1492
+
1493
+ | Method | Description |
1494
+ |--------|-------------|
1495
+ | `.play(name, config?)` | Play animation clip |
1496
+ | `.stop(name?)` | Stop animation |
1497
+ | `.pause(name?)` | Pause animation |
1498
+ | `.update(delta)` | Manual update |
1499
+ | `.start()` | Start render loop |
1500
+ | `.stopLoop()` | Stop render loop |
1501
+ | `.dispose()` | Clean up |
1502
+ | `.has(name)` | Check clip exists |
1503
+ | `.getAction(name)` | Get Action3 instance |
1504
+ | `.getState(name)` | Alias for play |
1505
+
1506
+ ---
1507
+
1508
+ ### LottieSupport
1509
+
1510
+ Lottie animation player wrapper.
1511
+
1512
+ ```js
1513
+ import { LottieSupport } from 'animotionjs-plus';
1514
+
1515
+ const controller = LottieSupport.createController({
1516
+ container: document.querySelector('#lottie-player'),
1517
+ path: '/animations/data.json',
1518
+ renderer: 'svg',
1519
+ autoplay: false,
1520
+ loop: false
1521
+ });
1522
+
1523
+ controller.play();
1524
+ controller.tweenToFrame(60, { duration: 1 });
1525
+ controller.setProgress(0.5);
1526
+
1527
+ // Via singleton:
1528
+ Animotion.lottie({ container: '#player', path: '/data.json' });
1529
+ ```
1530
+
1531
+ #### Static Methods
1532
+
1533
+ | Method | Returns | Description |
1534
+ |--------|---------|-------------|
1535
+ | `.isLoaded()` | `boolean` | Check `window.lottie` |
1536
+ | `.load(options?, library?)` | lottie instance | Load animation |
1537
+ | `.createController(targetOrOptions, options?, library?)` | `LottieController` | Create controller |
1538
+
1539
+ #### LottieController
1540
+
1541
+ | Method | Returns | Description |
1542
+ |--------|---------|-------------|
1543
+ | `.play()` | `this` | Play |
1544
+ | `.pause()` | `this` | Pause |
1545
+ | `.stop()` | `this` | Stop |
1546
+ | `.destroy()` | `void` | Destroy |
1547
+ | `.setSpeed(speed)` | `this` | Set playback speed |
1548
+ | `.setDirection(direction)` | `this` | 1 (forward) / -1 (reverse) |
1549
+ | `.playSegments(segments, forceFlag?)` | `this` | Play segments |
1550
+ | `.goToAndPlay(frame, isFrame?)` | `this` | Go to frame and play |
1551
+ | `.goToAndStop(frame, isFrame?)` | `this` | Go to frame and stop |
1552
+ | `.setFrame(frame)` | `this` | Set current frame |
1553
+ | `.setProgress(progress)` | `this` | Set by 0–1 progress |
1554
+ | `.tweenToFrame(frame, options?)` | `Tween` | Animate to frame |
1555
+ | `.tweenToProgress(progress, options?)` | `Tween` | Animate to progress |
1556
+ | `.on(eventName, handler)` | unsubscribe fn | Listen to events |
1557
+
1558
+ ---
1559
+
1560
+ ### DotLottieSupport
1561
+
1562
+ dotLottie animation player wrapper.
1563
+
1564
+ ```js
1565
+ import { DotLottieSupport } from 'animotionjs-plus';
1566
+
1567
+ const controller = DotLottieSupport.createController({
1568
+ canvas: document.querySelector('#dotlottie-canvas'),
1569
+ src: '/animations/animation.lottie',
1570
+ autoplay: false
1571
+ });
1572
+
1573
+ controller.play();
1574
+ controller.tweenToFrame(30, { duration: 0.5 });
1575
+
1576
+ // Via singleton:
1577
+ Animotion.dotLottie({ canvas: '#player', src: '/anim.lottie' });
1578
+ ```
1579
+
1580
+ #### Static Methods
1581
+
1582
+ | Method | Returns | Description |
1583
+ |--------|---------|-------------|
1584
+ | `.isLoaded()` | `boolean` | Check `window.DotLottie` |
1585
+ | `.createController(targetOrOptions, options?, library?)` | `DotLottieController` | Create controller |
1586
+
1587
+ #### DotLottieController
1588
+
1589
+ | Method | Returns | Description |
1590
+ |--------|---------|-------------|
1591
+ | `.play()` | `this` | Play |
1592
+ | `.pause()` | `this` | Pause |
1593
+ | `.stop()` | `this` | Stop |
1594
+ | `.destroy()` | `void` | Destroy |
1595
+ | `.setLoop(loop)` | `this` | Toggle loop |
1596
+ | `.setMode(mode)` | `this` | Set playback mode |
1597
+ | `.setSpeed(speed)` | `this` | Set speed |
1598
+ | `.setSegment(startFrame, endFrame)` | `this` | Set segment |
1599
+ | `.setFrame(frame)` | `this` | Set frame |
1600
+ | `.setProgress(progress)` | `this` | Set by 0–1 |
1601
+ | `.tweenToFrame(frame, options?)` | `Tween` | Animate to frame |
1602
+ | `.on(eventName, handler)` | unsubscribe fn | Listen to events |
1603
+
1604
+ ---
1605
+
1606
+ ## Data & State
1607
+
1608
+ ### ViewModel
1609
+
1610
+ Reactive observable data store with type coercion and nested paths.
1611
+
1612
+ ```js
1613
+ import { ViewModel } from 'animotionjs-plus';
1614
+
1615
+ // Define a ViewModel
1616
+ const vm = new ViewModel('app', {
1617
+ count: { type: 'number', default: 0 },
1618
+ name: { type: 'string', default: 'World' },
1619
+ active: { type: 'boolean', default: false },
1620
+ color: { type: 'color', default: '#ff0000' },
1621
+ items: { type: 'object', default: [] }
1622
+ });
1623
+
1624
+ // Create an instance
1625
+ const instance = vm.create({ count: 10 }, 'my-instance');
1626
+ instance.on((path, newVal, oldVal, instanceId) => {
1627
+ console.log(`${path}: ${oldVal} → ${newVal}`);
1628
+ });
1629
+ instance.set('count', 20);
1630
+ instance.set({ name: 'Animotion', active: true });
1631
+ instance.trigger('submit');
1632
+
1633
+ // Via singleton:
1634
+ Animotion.defineViewModel('app', { count: 'number' });
1635
+ Animotion.createViewModelInstance('app', { count: 5 }, 'inst-1');
1636
+ ```
1637
+
1638
+ #### Constructor
1639
+
1640
+ ```
1641
+ new ViewModel(name, schema?)
1642
+ ```
1643
+
1644
+ Schema values can be a type string (`'number'`, `'string'`, `'boolean'`, `'color'`, `'enum'`, `'object'`, `'trigger'`) or a config object `{ type, default, values, description }`.
1645
+
1646
+ #### Methods
1647
+
1648
+ | Method | Returns | Description |
1649
+ |--------|---------|-------------|
1650
+ | `.create(initialValues?, id?)` | `ViewModelInstance` | Create instance |
1651
+ | `.getInstance(id)` | `ViewModelInstance \| null` | Get instance by ID |
1652
+ | `static .get(name)` | `ViewModel \| null` | Get VM definition |
1653
+ | `static .getInstance(id)` | `ViewModelInstance \| null` | Get any instance |
1654
+ | `static .getAll()` | `ViewModel[]` | All VMs |
1655
+
1656
+ #### ViewModelInstance
1657
+
1658
+ | Method | Returns | Description |
1659
+ |--------|---------|-------------|
1660
+ | `.on(listener)` | `this` | Subscribe to changes |
1661
+ | `.off(listener)` | `this` | Unsubscribe |
1662
+ | `.get(path?)` | `any` | Get value by dot-path |
1663
+ | `.set(path, value)` | `this` | Set value |
1664
+ | `.set(obj)` | `this` | Set multiple values |
1665
+ | `.trigger(name)` | `this` | Fire a trigger prop |
1666
+ | `.toJSON()` | `object` | Serialize |
1667
+ | `.destroy()` | `void` | Clean up |
1668
+
1669
+ **Properties**: `id`, `viewModel`, `data` (observable proxy, read directly for reactive access)
1670
+
1671
+ #### Registry Exports
1672
+
1673
+ | Export | Type | Description |
1674
+ |--------|------|-------------|
1675
+ | `vmRegistry` | `Map<string, ViewModel>` | All ViewModel definitions, keyed by name |
1676
+ | `instanceRegistry` | `Map<string, ViewModelInstance>` | All ViewModel instances, keyed by ID |
1677
+
1678
+ ```js
1679
+ import { vmRegistry, instanceRegistry } from 'animotionjs-plus';
1680
+ vmRegistry.get('app'); // ViewModel definition
1681
+ instanceRegistry.get('inst-1'); // ViewModelInstance
1682
+ ```
1683
+
1684
+ ---
1685
+
1686
+ ### StateMachine
1687
+
1688
+ Declarative state machine with transitions, animations, and ViewModel binding.
1689
+
1690
+ ```js
1691
+ import { StateMachine } from 'animotionjs-plus';
1692
+
1693
+ const sm = new StateMachine('menu', {
1694
+ initial: 'closed',
1695
+ states: {
1696
+ closed: {
1697
+ animation: { opacity: 0, scale: 0.8 },
1698
+ transitions: [
1699
+ { target: 'open', when: 'toggle' },
1700
+ { target: 'open', condition: { isOpen: true } }
1701
+ ]
1702
+ },
1703
+ open: {
1704
+ animation: { opacity: 1, scale: 1 },
1705
+ transitions: [
1706
+ { target: 'closed', when: 'toggle' }
1707
+ ],
1708
+ onEnter: (instance) => console.log('opened')
1709
+ }
1710
+ }
1711
+ });
1712
+
1713
+ const instance = sm.createInstance({
1714
+ id: 'menu-instance',
1715
+ element: document.querySelector('.menu'),
1716
+ initial: 'closed'
1717
+ });
1718
+
1719
+ instance.send('toggle');
1720
+ instance.transitionTo('open', { duration: 0.5, ease: 'back-out' });
1721
+
1722
+ // Via singleton:
1723
+ Animotion.createStateMachine('menu', { initial: 'closed', states: {...} });
1724
+ ```
1725
+
1726
+ #### Constructor
1727
+
1728
+ ```
1729
+ new StateMachine(name, config?)
1730
+ ```
1731
+
1732
+ | Option | Type | Default | Description |
1733
+ |--------|------|---------|-------------|
1734
+ | `initial` | `string` | `'idle'` | Initial state |
1735
+ | `states` | `Record<string, StateDef>` | `{}` | State definitions |
1736
+ | `layers` | `StateMachineConfig[]` | `[]` | Sub-layers |
1737
+ | `debug` | `boolean` | `false` | Debug logging |
1738
+
1739
+ #### StateDef
1740
+
1741
+ | Field | Type | Description |
1742
+ |-------|------|-------------|
1743
+ | `to` / `animation` | `Record<string, any>` | CSS/style properties for this state |
1744
+ | `from` | `Record<string, any>` | From-properties |
1745
+ | `transitions` | `StateTransition[]` | Transition definitions |
1746
+ | `onEnter` | `(instance) => void` | Enter callback |
1747
+ | `onExit` | `(instance) => void` | Exit callback |
1748
+ | `onUpdate` | `(instance) => void` | Update callback |
1749
+ | `speed` | `number` | Animation speed |
1750
+ | `loop` | `boolean` | Loop animation |
1751
+
1752
+ #### StateTransition
1753
+
1754
+ | Field | Type | Description |
1755
+ |-------|------|-------------|
1756
+ | `target` | `string` | Target state name |
1757
+ | `when` / `condition` / `on` | `string \| object` | Trigger condition |
1758
+ | `duration` | `number` | Transition duration |
1759
+ | `ease` | `string` | Transition easing |
1760
+ | `always` | `boolean` | Allow re-entering current state |
1761
+ | `actions` | `object` | Side effects (set, trigger, call, lottie, audio, video, png, svg, emoji) |
1762
+
1763
+ #### Methods
1764
+
1765
+ | Method | Returns | Description |
1766
+ |--------|---------|-------------|
1767
+ | `.createInstance(config?)` | `StateMachineInstance` | Create runtime instance |
1768
+ | `static .get(name)` | `StateMachine \| null` | Get definition |
1769
+ | `static .getInstance(id)` | `StateMachineInstance \| null` | Get instance |
1770
+ | `static .create(name, config)` | `StateMachine` | Create + register |
1771
+
1772
+ #### StateMachineInstance
1773
+
1774
+ | Method | Returns | Description |
1775
+ |--------|---------|-------------|
1776
+ | `.bindToViewModel(vm)` | `void` | Bind to VM for reactive transitions |
1777
+ | `.bindElement(element)` | `void` | Bind to DOM element |
1778
+ | `.transitionTo(targetState, config?)` | `void` | Transition to state |
1779
+ | `.send(event)` | `this` | Send event name |
1780
+ | `.trigger(name)` | `this` | Trigger VM trigger |
1781
+ | `.setState(name)` | `this` | Instant state change |
1782
+ | `.getCurrentState()` | `string` | Current state |
1783
+ | `.getPreviousState()` | `string \| null` | Previous state |
1784
+ | `.play()` | `this` | Resume |
1785
+ | `.pause()` | `this` | Pause |
1786
+ | `.reset()` | `this` | Reset to initial |
1787
+ | `.on(listener)` | `this` | Subscribe |
1788
+ | `.off(listener)` | `this` | Unsubscribe |
1789
+ | `.destroy()` | `void` | Clean up |
1790
+
1791
+ **Properties**: `id`, `sm`, `element`, `currentState`, `previousState`, `isPlaying`
1792
+
1793
+ #### Registry Exports
1794
+
1795
+ | Export | Type | Description |
1796
+ |--------|------|-------------|
1797
+ | `stateMachineRegistry` | `Map<string, StateMachine>` | All StateMachine definitions, keyed by name |
1798
+ | `stateMachineInstances` | `Map<string, StateMachineInstance>` | All StateMachine instances, keyed by ID |
1799
+
1800
+ ```js
1801
+ import { stateMachineRegistry, stateMachineInstances } from 'animotionjs-plus';
1802
+ stateMachineRegistry.get('menu'); // StateMachine definition
1803
+ stateMachineInstances.get('menu-instance'); // StateMachineInstance
1804
+ ```
1805
+
1806
+ ---
1807
+
1808
+ ### Binding
1809
+
1810
+ Two-way data binding between ViewModel and DOM elements.
1811
+
1812
+ ```js
1813
+ import { Binding } from 'animotionjs-plus';
1814
+
1815
+ const binding = new Binding({
1816
+ source: vmInstance,
1817
+ sourcePath: 'count',
1818
+ target: document.querySelector('.counter'),
1819
+ targetPath: 'textContent',
1820
+ direction: 'source-to-target' // or 'bidirectional' | 'target-to-source'
1821
+ });
1822
+ binding.connect();
1823
+
1824
+ // Parse binding strings
1825
+ Binding.parseBindingString('vm.myInst.count -> .counter.textContent');
1826
+ // → { source: 'vm.myInst.count', target: '.counter.textContent', direction: 'source-to-target' }
1827
+
1828
+ // Via singleton:
1829
+ Animotion.createBinding({ source: vmInstance, sourcePath: 'count', target: '.out', targetPath: 'textContent' });
1830
+ ```
1831
+
1832
+ #### Constructor Options
1833
+
1834
+ | Option | Type | Default | Description |
1835
+ |--------|------|---------|-------------|
1836
+ | `id` | `string` | auto | Binding identifier |
1837
+ | `source` | `ViewModelInstance \| ViewModel` | `null` | Data source |
1838
+ | `sourcePath` | `string` | `''` | Source dot-path |
1839
+ | `sourceId` | `string` | `null` | VM instance ID |
1840
+ | `target` | `Element \| string` | `null` | DOM target |
1841
+ | `targetPath` | `string` | `''` | Target path |
1842
+ | `direction` | `string` | `'source-to-target'` | Binding direction |
1843
+ | `bindOnce` | `boolean` | `false` | Apply once only |
1844
+ | `converter` | `(value) => any` | `null` | Value transformer |
1845
+
1846
+ #### Target Path Formats
1847
+
1848
+ | Format | Example | Effect |
1849
+ |--------|---------|--------|
1850
+ | `textContent` | — | Sets element text |
1851
+ | `innerText` | — | Sets inner text |
1852
+ | `innerHTML` | — | Sets inner HTML |
1853
+ | `style.prop` | `style.opacity` | Sets CSS property |
1854
+ | `attr.name` | `attr.data-active` | Sets DOM attribute |
1855
+ | `x`, `y`, `z` | — | Sets transform |
1856
+ | `opacity` | — | Sets opacity |
1857
+ | custom path | `object.prop` | Sets nested property |
1858
+
1859
+ #### Methods
1860
+
1861
+ | Method | Description |
1862
+ |--------|-------------|
1863
+ | `.connect()` | Activate binding |
1864
+ | `.disconnect()` | Deactivate |
1865
+ | `.destroy()` | Clean up |
1866
+ | `static .create(config)` | Create + connect |
1867
+ | `static .parseBindingString(str)` | Parse `source -> target` |
1868
+ | `static .getBindingsForElement(el)` | Get element bindings |
1869
+ | `static .getBindingsForVM(vmId)` | Get VM bindings |
1870
+ | `static .getAll()` | All bindings |
1871
+
1872
+ #### Binding String Syntax
1873
+
1874
+ ```
1875
+ vm.{instanceId}.{property} -> {targetSelector}.{targetPath}
1876
+ vm.{instanceId}.{property} <- {targetSelector}.{targetPath}
1877
+ vm.{instanceId}.{property} <=> {targetSelector}.{targetPath}
1878
+ ```
1879
+
1880
+ Arrows: `->`, `→`, `=>`, `<-`, `←`, `↔`, `<=>`
1881
+
1882
+ #### Registry Exports
1883
+
1884
+ | Export | Type | Description |
1885
+ |--------|------|-------------|
1886
+ | `bindings` | `Map<string, Binding>` | All Binding instances, keyed by ID |
1887
+ | `elementBindings` | `WeakMap<Element, Binding[]>` | Bindings indexed by target Element |
1888
+ | `vmBindings` | `Map<string, Binding[]>` | Bindings indexed by ViewModel instance ID |
1889
+
1890
+ ```js
1891
+ import { bindings, elementBindings, vmBindings } from 'animotionjs-plus';
1892
+ bindings.get('binding-1'); // Binding instance
1893
+ elementBindings.get(element); // Bindings for element
1894
+ vmBindings.get('vm-instance-id'); // Bindings for VM
1895
+ ```
1896
+
1897
+ ---
1898
+
1899
+ ### ConditionEvaluator
1900
+
1901
+ Expression compiler for state machine transition conditions.
1902
+
1903
+ ```js
1904
+ import { ConditionEvaluator } from 'animotionjs-plus';
1905
+
1906
+ const eval = new ConditionEvaluator();
1907
+ eval.compile('>= 5')({ result: 7 }); // true
1908
+ eval.evaluate('== "active"', 'active'); // true
1909
+ eval.evaluate('!== null', null); // false
1910
+ eval.evaluateConditions({ '>= 10': 'high', '>= 5': 'medium' }, (cond) => 7);
1911
+ // → 'medium'
1912
+ ```
1913
+
1914
+ #### Methods
1915
+
1916
+ | Method | Returns | Description |
1917
+ |--------|---------|-------------|
1918
+ | `.compile(expression)` | `(ctx) => boolean` | Compile expression |
1919
+ | `.evaluate(condition, value)` | `boolean` | Evaluate condition against value |
1920
+ | `.evaluateConditions(conditions, getValue)` | `string \| null` | Return matched target |
1921
+ | `.clear()` | `void` | Clear compiled cache |
1922
+
1923
+ **Supported operators**: `==`, `===`, `!=`, `!==`, `>=`, `<=`, `>`, `<`
1924
+
1925
+ ---
1926
+
1927
+ ## License Manager
1928
+
1929
+ ### LicenseManager
1930
+
1931
+ Server-side license validation with admin login, session refresh, and localStorage persistence.
1932
+
1933
+ ```js
1934
+ import { LicenseManager } from 'animotionjs-plus';
1935
+ // Or via:
1936
+ Animotion.init({ licenseKey: '...' });
1937
+
1938
+ // Singleton access:
1939
+ import { getLicenseManager } from './core/LicenseManager';
1940
+ ```
1941
+
1942
+ #### Methods
1943
+
1944
+ | Method | Returns | Description |
1945
+ |--------|---------|-------------|
1946
+ | `.init()` | `Promise<boolean>` | Start license validation |
1947
+ | `.refreshSession()` | `Promise<boolean>` | Refresh stored session |
1948
+ | `.isValid()` | `boolean` | License valid? |
1949
+ | `.getToken()` | `string \| null` | Session token |
1950
+ | `.getTier()` | `string` | `'pro'` or `'none'` |
1951
+ | `.getEmail()` | `string \| null` | User email |
1952
+ | `.onExpiry(callback)` | `void` | Register expiry callback |
1953
+ | `.destroy()` | `void` | Clean up |
1954
+
1955
+ **Default server URL**: `https://skills.animotion.click/api`
1956
+
1957
+ ---
1958
+
1959
+ ## Framework Integrations
1960
+
1961
+ ### React Hooks
1962
+
1963
+ Import from `animotionjs-plus/react`:
1964
+
1965
+ ```jsx
1966
+ import {
1967
+ useAnimotion,
1968
+ useAnimotionContext,
1969
+ useAnimotionAttributes,
1970
+ useViewModel,
1971
+ useStateMachine,
1972
+ useBinding,
1973
+ animotionAttrs
1974
+ } from 'animotionjs-plus/react';
1975
+ ```
1976
+
1977
+ #### `useAnimotion(setup, deps?)`
1978
+
1979
+ Creates a scoped AnimationContext that auto-cleans on unmount.
1980
+
1981
+ ```jsx
1982
+ const scopeRef = useAnimotion((ctx, scope) => {
1983
+ ctx.to('.title', { opacity: 1, y: 0 }, { duration: 0.8 });
1984
+ }, []);
1985
+ return <div ref={scopeRef}>...</div>;
1986
+ ```
1987
+
1988
+ #### `useAnimotionContext(scopeRef, setup, deps?)`
1989
+
1990
+ Attaches a context to an existing ref.
1991
+
1992
+ ```jsx
1993
+ const ref = useRef(null);
1994
+ useAnimotionContext(ref, (ctx, scope) => {
1995
+ ctx.from('.box', { opacity: 0 });
1996
+ }, []);
1997
+ return <div ref={ref}>...</div>;
1998
+ ```
1999
+
2000
+ #### `useAnimotionAttributes(options?, deps?)`
2001
+
2002
+ Processes declarative `data-anim-*` attributes within a scope.
2003
+
2004
+ ```jsx
2005
+ const scopeRef = useAnimotionAttributes({ attributePrefix: 'am' }, []);
2006
+ return (
2007
+ <div ref={scopeRef}>
2008
+ <div am-to={{ x: 100 }} am-duration="1">Animate me</div>
2009
+ </div>
2010
+ );
2011
+ ```
2012
+
2013
+ #### `useViewModel(nameOrSchema, initialValues?, options?)`
2014
+
2015
+ Reactive ViewModel hook that triggers re-renders on data changes.
2016
+
2017
+ ```jsx
2018
+ const { instance, data, set, trigger } = useViewModel('app', { count: 0 });
2019
+ // data.count is reactive
2020
+ return <div>{data.count}</div>;
2021
+ ```
2022
+
2023
+ #### `useStateMachine(nameOrConfig, viewModelInstance?, options?)`
2024
+
2025
+ ```jsx
2026
+ const { instance, state, send, transitionTo } = useStateMachine('menu', {
2027
+ initial: 'closed',
2028
+ states: {
2029
+ closed: { transitions: [{ target: 'open', when: 'toggle' }] },
2030
+ open: { transitions: [{ target: 'closed', when: 'toggle' }] }
2031
+ }
2032
+ });
2033
+ return <button onClick={() => send('toggle')}>{state}</button>;
2034
+ ```
2035
+
2036
+ #### `useBinding(config, deps?)`
2037
+
2038
+ ```jsx
2039
+ useBinding({ source: vmInstance, sourcePath: 'count', target: '.out', targetPath: 'textContent' }, [vmInstance]);
2040
+ ```
2041
+
2042
+ ---
2043
+
2044
+ ### Next.js
2045
+
2046
+ Import from `animotionjs-plus/next` (identical API to React hooks, with `'use client'` directive).
2047
+
2048
+ ```jsx
2049
+ 'use client';
2050
+ import { useAnimotion } from 'animotionjs-plus/next';
2051
+ ```
2052
+
2053
+ ---
2054
+
2055
+ ### HTML Attributes (data-anim-*)
2056
+
2057
+ Declarative animation API via HTML attributes. Powered by `AnimationCore.init()` and `auto-init.js` (for UMD).
2058
+
2059
+ ```html
2060
+ <script src="dist/animotion.min.js" data-anim-init></script>
2061
+
2062
+ <!-- Basic tween -->
2063
+ <div am-to='{"x":200,"opacity":0.5}' am-duration="1" am-ease="bounce-out">
2064
+ Animate me on load
2065
+ </div>
2066
+
2067
+ <!-- From tween -->
2068
+ <div am-from='{"opacity":0}'>
2069
+
2070
+ <!-- FromTo -->
2071
+ <div am-from='{"opacity":0}' am-to='{"opacity":1}' am-duration="1.5">
2072
+
2073
+ <!-- Set (instant) -->
2074
+ <div am-set='{"backgroundColor":"red"}'>
2075
+
2076
+ <!-- Timeline -->
2077
+ <div am-timeline="myTimeline">
2078
+ <div am-to='{"x":100}'></div>
2079
+ <div am-to='{"x":200}' am-position="+=0.5"></div>
2080
+ </div>
2081
+
2082
+ <!-- Event-triggered -->
2083
+ <button am-on="click" am-to='{"scale":1.2}' am-duration="0.3" am-yoyo="true">Click me</button>
2084
+
2085
+ <!-- Scroll-triggered -->
2086
+ <div am-scroll am-to='{"opacity":1}' am-start="top bottom" am-end="top center" am-scrub="true">
2087
+ Fade in on scroll
2088
+ </div>
2089
+
2090
+ <!-- Pin on scroll -->
2091
+ <div am-pin am-duration="300">Pinned section</div>
2092
+
2093
+ <!-- Split text -->
2094
+ <div am-split="chars" am-split-class="split-char">
2095
+ Each character becomes a span
2096
+ </div>
2097
+
2098
+ <!-- Draggable -->
2099
+ <div am-draggable='{"lockAxis":"x"}'>Drag me</div>
2100
+
2101
+ <!-- Spring physics -->
2102
+ <div am-spring='{"stiffness":300}' am-to='{"x":200}' am-on="click">Spring on click</div>
2103
+
2104
+ <!-- Motion path -->
2105
+ <div am-motion-path='{"pathSelector":"#myPath"}' am-duration="3">
2106
+
2107
+ <!-- Parallax -->
2108
+ <div am-parallax="0.3">
2109
+
2110
+ <!-- Keyframes -->
2111
+ <div am-keyframes='[{"at":0,"to":{"x":0}},{"at":0.5,"to":{"x":100}},{"at":1,"to":{"x":200}}]'>
2112
+
2113
+ <!-- Video -->
2114
+ <div am-video="/videos/intro.mp4" am-video-muted="true"></div>
2115
+
2116
+ <!-- Audio -->
2117
+ <div am-audio="/audio/track.mp3" am-audio-volume="0.8"></div>
2118
+
2119
+ <!-- WebGL Shader -->
2120
+ <div am-shader='{"fragment":"..."}'></div>
2121
+
2122
+ <!-- Lottie -->
2123
+ <div am-lottie="/animations/data.json"></div>
2124
+
2125
+ <!-- Layouts -->
2126
+ <div am-layout='{"type":"circular","radius":200}'>
2127
+ <div>Item 1</div>
2128
+ <div>Item 2</div>
2129
+ </div>
2130
+
2131
+ <!-- ViewModel -->
2132
+ <div am-view-model="app" am-vm-props='{"count":"number","name":"string"}' am-vm-data='{"count":0}'></div>
2133
+
2134
+ <!-- State Machine -->
2135
+ <div am-state-machine="menu" am-sm-states='{"closed":{"transitions":[{"target":"open","when":"toggle"}]},"open":{"transitions":[{"target":"closed","when":"toggle"}]}}' am-sm-initial="closed"></div>
2136
+
2137
+ <!-- Binding -->
2138
+ <div am-bind="vm.appInst.count -> .counter.textContent"></div>
2139
+ ```
2140
+
2141
+ #### Attribute Prefix
2142
+
2143
+ Default prefix is `am` (produces `am-to`, `am-from`, etc.). Configure via `AnimationCore` options or `Animotion.init({ attributePrefix: 'data-anim' })`.
2144
+
2145
+ #### Legacy Attributes
2146
+
2147
+ `data-anim`, `data-anim-scroll-trigger`, `data-anim-split-text` work when `legacyAttributes: true`.
2148
+
2149
+ #### Attribute Reference
2150
+
2151
+ | Attribute | Description |
2152
+ |-----------|-------------|
2153
+ | `am` | Mark as animation root |
2154
+ | `am-to` | Target properties (JSON) |
2155
+ | `am-from` | From properties (JSON) |
2156
+ | `am-set` | Instant set properties |
2157
+ | `am-props` | Alias for `am-to` |
2158
+ | `am-duration` | Duration (seconds) |
2159
+ | `am-ease` | Easing name |
2160
+ | `am-delay` | Delay (seconds) |
2161
+ | `am-repeat` | Repeat count |
2162
+ | `am-yoyo` | Reverse on repeat |
2163
+ | `am-stagger` | Stagger delay (seconds per target) |
2164
+ | `am-stagger-from` | Stagger order (`start`, `center`, `edges`, `end`, `random`) |
2165
+ | `am-stagger-amount` | Total stagger span (seconds, distributed across targets) |
2166
+ | `am-stagger-grid` | Grid for `center`/`edges` ordering, e.g. `3, 4` (rows, cols) |
2167
+ | `am-on` | Event trigger (click, hover, load, inview, etc.) |
2168
+ | `am-once` | Fire only once |
2169
+ | `am-scroll` | Scroll trigger config |
2170
+ | `am-pin` | Pin on scroll |
2171
+ | `am-scrub` | Scrub with scroll |
2172
+ | `am-start` | Scroll start position |
2173
+ | `am-end` | Scroll end position |
2174
+ | `am-timeline` | Timeline ID |
2175
+ | `am-position` | Item position in timeline |
2176
+ | `am-label` | Timeline label |
2177
+ | `am-variants` | Named variant map (JSON), declarative equivalent of `variants()` |
2178
+ | `am-variants-initial` | Variant applied at init (default: first key in map) |
2179
+ | `am-variant` | Variant applied on `am-on` event (string, or event→variant JSON); also switchable via `am-action="variant:<name>"` |
2180
+ | `am-split` | Split text type |
2181
+ | `am-draggable` | Draggable config |
2182
+ | `am-spring` | Spring config |
2183
+ | `am-motion-path` / `am-path` | Motion path config |
2184
+ | `am-keyframes` | Keyframes array |
2185
+ | `am-sequence` | Scene sequence config |
2186
+ | `am-mouse` | Mouse parallax config |
2187
+ | `am-parallax` | Parallax speed |
2188
+ | `am-video` | Video source |
2189
+ | `am-audio` / `am-sound` | Audio source |
2190
+ | `am-shader` / `am-webgl` | Shader config |
2191
+ | `am-lottie` | Lottie path |
2192
+ | `am-dotlottie` | dotLottie source |
2193
+ | `am-layout` | Layout config |
2194
+ | `am-layout-type` | Layout type |
2195
+ | `am-png-sequence` | PNG sequence config |
2196
+ | `am-view-model` | ViewModel name |
2197
+ | `am-state-machine` | StateMachine name |
2198
+ | `am-bind` | Binding declaration |
2199
+ | `am-sm-send` | Send event to SM |
2200
+ | `am-sm-set-state` | Set SM state |
2201
+ | `am-vm-set` | Set VM property |
2202
+ | `am-vm-trigger` | Trigger VM prop |
2203
+ | `am-bind-now` | Apply binding immediately |
2204
+
2205
+ ---
2206
+
2207
+ ### animotionAttrs
2208
+
2209
+ Utility to generate HTML attribute objects from a config (useful in JSX).
2210
+
2211
+ ```js
2212
+ import { animotionAttrs } from 'animotionjs-plus';
2213
+ // Or from /attrs:
2214
+ import { animotionAttrs } from 'animotionjs-plus/attrs';
2215
+
2216
+ const attrs = animotionAttrs({
2217
+ to: { x: 100, opacity: 0.5 },
2218
+ duration: 1,
2219
+ ease: 'bounce-out',
2220
+ on: 'click'
2221
+ }, 'am');
2222
+ // → { 'am': '', 'am-to': '{"x":100,"opacity":0.5}', 'am-duration': '1', 'am-ease': 'bounce-out', 'am-on': 'click' }
2223
+
2224
+ // In JSX:
2225
+ <div {...attrs}>Animate</div>
2226
+ ```
2227
+
2228
+ #### Signature
2229
+
2230
+ ```
2231
+ animotionAttrs(config, prefix?) => Record<string, string>
2232
+ ```
2233
+
2234
+ Maps camelCase config keys to kebab-case `{prefix}-{key}` attributes. Has built-in aliases for multi-word attrs (e.g., `viewModel` → `view-model`, `vmData` → `vm-data`).
2235
+
2236
+ ---
2237
+
2238
+ ## Motion Design Principles
2239
+
2240
+ Ready-made recipes for the classic motion-design lessons (the ones every motion-design tutorial covers). Each recipe is a thin wrapper over the core engine: tween recipes return a `Tween`, `parallax` returns a controller.
2241
+
2242
+ ```js
2243
+ import { Principles } from 'animotionjs-plus';
2244
+ // or: Animotion.Principles.easing(...)
2245
+
2246
+ Principles.offsetAndDelay('.card', { each: 0.08, ease: 'power2.out' });
2247
+ ```
2248
+
2249
+ | Recipe | Lesson | Returns |
2250
+ |--------|--------|---------|
2251
+ | `easing(target, opts)` | Basics of Easing | `Tween` |
2252
+ | `offsetAndDelay(target, opts)` | Offset and Delay (staggered entrance) | `Tween` |
2253
+ | `fadeIn(target, opts)` / `fadeOut(target, opts)` | Fade in Fade out | `Tween` |
2254
+ | `transformMorph(target, opts)` | Transformation / Morph | `Tween` |
2255
+ | `maskReveal(target, opts)` | Masking | `Tween` (`.inner` when used) |
2256
+ | `dimension(target, opts)` | Floating Dimensionality (3D depth) | `Tween` |
2257
+ | `parallax(target, opts)` | Parallax (scroll & pointer) | controller |
2258
+ | `zoom(target, opts)` | Zoom / FLIP continuity | `Tween` |
2259
+
2260
+ All tween recipes accept the usual `TweenOptions` (`duration`, `delay`, `ease`, `repeat`, `paused`, ...) plus stagger shorthands `each` / `amount` / `grid` / `axis`.
2261
+
2262
+ #### `easing(target, opts)`
2263
+
2264
+ Animate props with a chosen ease. `type` accepts tutorial terms (`'linear'`, `'ease'`, `'ease-in'`, `'ease-out'`, `'cubic'`); an explicit `ease` wins.
2265
+
2266
+ ```js
2267
+ Principles.easing('.ball', { to: { x: 400 }, type: 'cubic', duration: 1.2 });
2268
+ Principles.easing('.ball', { from: { x: 0 }, to: { x: 400 }, ease: 'power2.inOut' });
2269
+ ```
2270
+
2271
+ #### `offsetAndDelay(target, opts)`
2272
+
2273
+ Staggered entrance — default `opacity 0→1` and `y 40→0`, with stagger shorthands:
2274
+
2275
+ ```js
2276
+ Principles.offsetAndDelay('.card', { each: 0.1 });
2277
+ Principles.offsetAndDelay('.tile', { amount: 0.6, grid: [3, 4], stagger: { from: 'center' } });
2278
+ ```
2279
+
2280
+ #### `fadeIn(target, opts)` / `fadeOut(target, opts)`
2281
+
2282
+ ```js
2283
+ Principles.fadeIn('.hero', { y: 24, duration: 0.8 });
2284
+ Principles.fadeOut('.banner', { y: -20, duration: 0.4 });
2285
+ ```
2286
+
2287
+ `fadeIn` uses an explicit from-state (`opacity 0`, optional `y`/`scale`); `fadeOut` animates from the current opacity to `0`.
2288
+
2289
+ #### `transformMorph(target, opts)`
2290
+
2291
+ Shape morphing — style props (default: square → circle) or SVG path-to-path:
2292
+
2293
+ ```js
2294
+ Principles.transformMorph('.photo'); // borderRadius 0 → 50%
2295
+ Principles.transformMorph('.card', { to: { borderRadius: 24, scale: 1.05 } });
2296
+ Principles.transformMorph(pathEl, { from: 'M0,0 L10,0', d: 'M0,0 L20,0' });
2297
+ ```
2298
+
2299
+ Path mode requires a `from` string or an existing `d` attribute; both paths must share the same command structure.
2300
+
2301
+ #### `maskReveal(target, opts)`
2302
+
2303
+ Clip-path reveal; optionally the inner content drifts against the reveal (exposed as `tween.inner`):
2304
+
2305
+ ```js
2306
+ const reveal = Principles.maskReveal('.mask', { inner: '.mask img' });
2307
+ reveal.seek(0.5); // or let it autoplay
2308
+ ```
2309
+
2310
+ Defaults: `clipFrom: 'inset(0 100% 0 0)'` → `clipTo: 'inset(0 0% 0 0)'`, inner `x: -32 → 0`.
2311
+
2312
+ #### `dimension(target, opts)`
2313
+
2314
+ 3D depth entrance (perspective + rotateX + translateZ):
2315
+
2316
+ ```js
2317
+ Principles.dimension('.card', { depth: 200, each: 0.12 });
2318
+ Principles.dimension('.panel', { rotateX: 20, from: { opacity: 0, y: 120 } });
2319
+ ```
2320
+
2321
+ #### `parallax(target, opts)`
2322
+
2323
+ Scroll mode (default) creates one `ParallaxEffect` per element; `interactive: true` follows the pointer. Returns `{ mode, elements, effects?, destroy() }`:
2324
+
2325
+ ```js
2326
+ const layers = Principles.parallax('.layer', { speed: (el, i) => 0.2 + i * 0.25 });
2327
+ // ... later
2328
+ layers.destroy();
2329
+
2330
+ Principles.parallax('.scene > *', { interactive: true, strength: 0.1 });
2331
+ ```
2332
+
2333
+ #### `zoom(target, opts)`
2334
+
2335
+ Zoom transitions; `fromElement` measures a FLIP-style start state from another element:
2336
+
2337
+ ```js
2338
+ Principles.zoom('.lightbox', { fromElement: '.thumb', duration: 0.6 });
2339
+ Principles.zoom('.modal', { out: true, scale: 0.9 }); // zoom-out
2340
+ Principles.zoom('.card', { origin: 'top left' });
2341
+ ```
2342
+
2343
+ ---
2344
+
2345
+ ## Utilities
2346
+
2347
+ ### DomUtils
2348
+
2349
+ ```js
2350
+ import { DomUtils } from 'animotionjs-plus';
2351
+
2352
+ DomUtils.getElement('.selector', fallback);
2353
+ DomUtils.getElements('.selector', []);
2354
+ DomUtils.getElementByIdOrSelector('#id-or-selector');
2355
+ DomUtils.placeElementInContainer(element, container);
2356
+ DomUtils.hasClass(el, 'class');
2357
+ DomUtils.addClass(el, 'class');
2358
+ DomUtils.removeClass(el, 'class');
2359
+ DomUtils.toggleClass(el, 'class');
2360
+ DomUtils.setData(el, 'key', 'value');
2361
+ DomUtils.getData(el, 'key', fallback);
2362
+ ```
2363
+
2364
+ ### MathUtils
2365
+
2366
+ ```js
2367
+ import { MathUtils } from 'animotionjs-plus';
2368
+
2369
+ MathUtils.clamp(value, min, max);
2370
+ MathUtils.lerp(a, b, t);
2371
+ MathUtils.map(value, inMin, inMax, outMin, outMax);
2372
+ MathUtils.random(min, max);
2373
+ MathUtils.randomInt(min, max);
2374
+ MathUtils.distance(x1, y1, x2, y2);
2375
+ MathUtils.angle(x1, y1, x2, y2);
2376
+ MathUtils.round(value, decimals?);
2377
+ ```
2378
+
2379
+ ### ParserUtils
2380
+
2381
+ ```js
2382
+ import { ParserUtils } from 'animotionjs-plus';
2383
+
2384
+ ParserUtils.parseJSON('{"key":"value"}');
2385
+ ParserUtils.parseNumber('42', 0);
2386
+ ParserUtils.parseBoolean('true', false);
2387
+ ParserUtils.parseCSS('color: red; font-size: 16px');
2388
+ ```
2389
+
2390
+ ### EnvironmentUtils
2391
+
2392
+ ```js
2393
+ import { EnvironmentUtils } from 'animotionjs-plus';
2394
+
2395
+ EnvironmentUtils.isBrowser(); // boolean
2396
+ EnvironmentUtils.getWindow(); // Window | null
2397
+ EnvironmentUtils.getDocument(); // Document | null
2398
+ EnvironmentUtils.isElement(value); // boolean
2399
+ EnvironmentUtils.isNodeList(value); // boolean
2400
+ ```
2401
+
2402
+ ### Logger
2403
+
2404
+ ```js
2405
+ import { Logger } from 'animotionjs-plus';
2406
+
2407
+ Logger.setLevel('debug'); // 'debug' | 'info' | 'warn' | 'error'
2408
+ Logger.debug('msg');
2409
+ Logger.info('msg');
2410
+ Logger.warn('msg');
2411
+ Logger.error('msg');
2412
+ ```
2413
+
2414
+ ---
2415
+
2416
+ ## CSS Styles
2417
+
2418
+ Import: `import 'animotionjs-plus/styles.css'`
2419
+
2420
+ ### Built-in Keyframe Animations
2421
+
2422
+ ```css
2423
+ @keyframes fadeIn { ... }
2424
+ @keyframes slideUp { ... }
2425
+ @keyframes slideDown { ... }
2426
+ @keyframes slideLeft { ... }
2427
+ @keyframes slideRight { ... }
2428
+ @keyframes scale { ... }
2429
+ @keyframes rotate { ... }
2430
+ ```
2431
+
2432
+ ### Utility Classes
2433
+
2434
+ ```css
2435
+ .is-visible { opacity: 1 !important; }
2436
+ .is-hidden { opacity: 0 !important; pointer-events: none; }
2437
+ .is-animating { pointer-events: none; }
2438
+
2439
+ .animate-fade-in { animation: fadeIn 0.6s ease-out forwards; }
2440
+ .animate-slide-up { animation: slideUp 0.6s ease-out forwards; }
2441
+ .animate-slide-down { animation: slideDown 0.6s ease-out forwards; }
2442
+ .animate-slide-left { animation: slideLeft 0.6s ease-out forwards; }
2443
+ .animate-slide-right { animation: slideRight 0.6s ease-out forwards; }
2444
+ .animate-scale { animation: scale 0.6s ease-out forwards; }
2445
+ .animate-rotate { animation: rotate 0.6s ease-out forwards; }
2446
+ ```
2447
+
2448
+ ### Stagger Delays
2449
+
2450
+ ```css
2451
+ [data-stagger-delay="0"] { animation-delay: 0s; }
2452
+ [data-stagger-delay="1"] { animation-delay: 0.1s; }
2453
+ [data-stagger-delay="2"] { animation-delay: 0.2s; }
2454
+ [data-stagger-delay="3"] { animation-delay: 0.3s; }
2455
+ [data-stagger-delay="4"] { animation-delay: 0.4s; }
2456
+ [data-stagger-delay="5"] { animation-delay: 0.5s; }
2457
+ ```