@vdragon/vui-animate 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +169 -2
- package/dist/vui-animate.css +583 -0
- package/dist/vui-animate.js +446 -0
- package/dist/vui-animate.min.css +3 -0
- package/dist/vui-animate.min.css.map +1 -0
- package/dist/vui-animate.min.js +3 -0
- package/dist/vui-animate.min.js.map +7 -0
- package/index.css +7 -0
- package/lib/cjs/index.d.ts +92 -0
- package/lib/cjs/index.js +431 -0
- package/lib/cjs/index.js.map +7 -0
- package/lib/esm/index.d.ts +92 -0
- package/lib/esm/index.d.ts.map +1 -0
- package/lib/esm/index.js +411 -0
- package/lib/esm/index.js.map +7 -0
- package/package.json +80 -5
- package/src/index.ts +560 -0
- package/vui-animate.css +603 -0
package/README.md
CHANGED
|
@@ -1,3 +1,170 @@
|
|
|
1
|
-
#
|
|
1
|
+
# vUI Animate (`@vdragon/vui-animate`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A lightweight CSS & JavaScript animation plugin for **[`@vdragon/vui`](https://www.npmjs.com/package/@vdragon/vui)**. It inherits vUI design tokens (`--primary`, `--card`, `--border`, `.dark`), provides a `VAnimate` component extending `VComponent`, and auto-registers with `vComponents` for declarative `data-v-animate` and dynamic runtime animations.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @vdragon/vui @vdragon/vui-animate
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
> **Peer dependency**: `@vdragon/vui` (`^0.0.3`).
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### 1. CSS Import (Tailwind v4 / Bundlers)
|
|
20
|
+
|
|
21
|
+
```css
|
|
22
|
+
@import '@vdragon/vui/dist/styles.css';
|
|
23
|
+
@import '@vdragon/vui-animate/styles.css';
|
|
24
|
+
|
|
25
|
+
/* Or minified: @import '@vdragon/vui-animate/styles.min.css'; */
|
|
26
|
+
/* Or bundle entry (includes @vdragon/vui/dist/styles.css): @import '@vdragon/vui-animate/bundle'; */
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 2. JavaScript / TypeScript (ESM / CJS)
|
|
30
|
+
|
|
31
|
+
Importing `@vdragon/vui-animate` automatically registers `VAnimate` with `vComponents` from `@vdragon/vui/core`:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import '@vdragon/vui';
|
|
35
|
+
import { VAnimate } from '@vdragon/vui-animate';
|
|
36
|
+
|
|
37
|
+
// Play or replay an animation dynamically (returns a Promise resolved on animationend)
|
|
38
|
+
await VAnimate.play('#hero-card', 'fade-up', {
|
|
39
|
+
duration: '450ms',
|
|
40
|
+
easing: 'spring',
|
|
41
|
+
cleanup: true,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Dynamically attach a VAnimate component with a trigger
|
|
45
|
+
VAnimate.add('#submit-btn', 'pop', { trigger: 'click' });
|
|
46
|
+
|
|
47
|
+
// Stagger animate a list or container's children
|
|
48
|
+
await VAnimate.stagger('#card-list > .card', 'blur-in', { step: 70 });
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 3. Plain HTML (`<script>` & `<link>`)
|
|
52
|
+
|
|
53
|
+
Load `@vdragon/vui` first, then `vui-animate`:
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<link rel="stylesheet" href="./node_modules/@vdragon/vui/dist/styles.min.css" />
|
|
57
|
+
<link rel="stylesheet" href="./node_modules/@vdragon/vui-animate/dist/vui-animate.min.css" />
|
|
58
|
+
|
|
59
|
+
<script src="./node_modules/@vdragon/vui/dist/vui.min.js"></script>
|
|
60
|
+
<script src="./node_modules/@vdragon/vui-animate/dist/vui-animate.min.js"></script>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Declarative HTML API (`data-v-animate`)
|
|
66
|
+
|
|
67
|
+
Because `VAnimate` extends `VComponent` and registers with `vComponents`, elements with `data-v-animate` initialize automatically on page load, `vComponents.init()`, `vComponents.observe()`, and SPA navigation (`livewire:navigate` / `enhancedload`):
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<!-- Animate on mount -->
|
|
71
|
+
<div class="card" data-v-animate="fade-up" data-v-animate-duration="450ms">...</div>
|
|
72
|
+
|
|
73
|
+
<!-- Animate when scrolled into viewport -->
|
|
74
|
+
<div class="card" data-v-animate="blur-in" data-v-animate-trigger="visible" data-v-animate-once="true">...</div>
|
|
75
|
+
|
|
76
|
+
<!-- Replay on click with spring easing -->
|
|
77
|
+
<button class="btn" data-v-animate="pop" data-v-animate-trigger="click" data-v-animate-easing="spring">
|
|
78
|
+
Click me
|
|
79
|
+
</button>
|
|
80
|
+
|
|
81
|
+
<!-- Trigger animation on another target element -->
|
|
82
|
+
<button class="btn" data-v-animate="shake" data-v-animate-trigger="click" data-v-animate-target="#email-input" data-v-animate-cleanup="true">
|
|
83
|
+
Validate
|
|
84
|
+
</button>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
| Attribute | Default | Description |
|
|
88
|
+
|-----------|---------|-------------|
|
|
89
|
+
| `data-v-animate` | `""` | Animation name (`fade-up` or `v-anim-fade-up`) |
|
|
90
|
+
| `data-v-animate-trigger` | `"mount"` | `"mount"` \| `"visible"` \| `"click"` \| `"hover"` \| `"manual"` |
|
|
91
|
+
| `data-v-animate-target` | host element | CSS selector for a different target element to animate |
|
|
92
|
+
| `data-v-animate-duration` | `360ms` | Overrides `--v-anim-duration` |
|
|
93
|
+
| `data-v-animate-delay` | `0ms` | Overrides `--v-anim-delay` |
|
|
94
|
+
| `data-v-animate-easing` | `"smooth"` | `"smooth"` \| `"spring"` \| `"snappy"` or custom CSS timing function |
|
|
95
|
+
| `data-v-animate-distance` | `16px` | Overrides `--v-anim-distance` |
|
|
96
|
+
| `data-v-animate-scale` | `0.94` | Overrides `--v-anim-scale` |
|
|
97
|
+
| `data-v-animate-blur` | `10px` | Overrides `--v-anim-blur` |
|
|
98
|
+
| `data-v-animate-iterations` | `1` | Overrides `--v-anim-iterations` (e.g. `infinite`) |
|
|
99
|
+
| `data-v-animate-once` | `true` | For `visible` trigger: animate only once |
|
|
100
|
+
| `data-v-animate-threshold` | `0.15` | For `visible` trigger: `IntersectionObserver` threshold |
|
|
101
|
+
| `data-v-animate-cleanup` | `false` | Remove the animation class automatically on `animationend` |
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## `VAnimate` JavaScript API
|
|
106
|
+
|
|
107
|
+
### Static Methods
|
|
108
|
+
- `VAnimate.play(elementOrSelector, animation, options?)` — Dynamically play/replay an animation (`Promise<HTMLElement | null>`).
|
|
109
|
+
- `VAnimate.add(elementOrSelector, animation, options?)` — Dynamically attach/configure `VAnimate` on an element (`VAnimate | null`).
|
|
110
|
+
- `VAnimate.stagger(elementsOrSelector, animation, { step, startDelay, ...options })` — Stagger-animate a collection or container's children.
|
|
111
|
+
- `VAnimate.getInstance(element)` / `VAnimate.getOrCreateInstance(element, config?)` / `VAnimate.createInstances(root?)` / `VAnimate.init()`.
|
|
112
|
+
|
|
113
|
+
### Instance Methods & Events (inherited from `VComponent`)
|
|
114
|
+
- `play(animation?, options?)`, `replay(animation?, options?)`, `pause()`, `resume()`, `stop()`, `setAnimation(animation)`, `dispose()`.
|
|
115
|
+
- `on('start' | 'end', callback)` / `off(eventType, id)` and DOM `CustomEvent`s: `v.animate.start` (cancellable via `payload.cancel = true`) and `v.animate.end`.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Package Exports
|
|
120
|
+
|
|
121
|
+
| Entry | Target | Description |
|
|
122
|
+
|-------|--------|-------------|
|
|
123
|
+
| `@vdragon/vui-animate` | `lib/esm/index.js` / `lib/cjs/index.js` | JS/TS component (`VAnimate`, `vAnimatePlugin`) + types |
|
|
124
|
+
| `@vdragon/vui-animate/styles.css` | `dist/vui-animate.css` | Standard compiled CSS |
|
|
125
|
+
| `@vdragon/vui-animate/styles.min.css` | `dist/vui-animate.min.css` | Minified CSS with source map |
|
|
126
|
+
| `@vdragon/vui-animate/bundle` | `index.css` | Imports `@vdragon/vui/dist/styles.css` + `vui-animate.css` |
|
|
127
|
+
| `@vdragon/vui-animate/dist/*` | `dist/*` | Browser CSS & IIFE JS bundles (`vui-animate(.min).js`, `vui-animate(.min).css`) |
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Animation Classes
|
|
132
|
+
|
|
133
|
+
| Category | Classes |
|
|
134
|
+
|----------|---------|
|
|
135
|
+
| **Entrance** | `.v-anim-fade-in`, `.v-anim-fade-up`, `.v-anim-fade-down`, `.v-anim-fade-left`, `.v-anim-fade-right`, `.v-anim-zoom-in`, `.v-anim-blur-in`, `.v-anim-pop`, `.v-anim-slide-up`, `.v-anim-slide-down`, `.v-anim-slide-left`, `.v-anim-slide-right` |
|
|
136
|
+
| **Exit** | `.v-anim-fade-out`, `.v-anim-zoom-out`, `.v-anim-blur-out` |
|
|
137
|
+
| **Micro-interactions** | `.v-anim-hover-lift`, `.v-anim-hover-scale`, `.v-anim-hover-glow`, `.v-anim-press` |
|
|
138
|
+
| **Trending Surface** | `.v-anim-shimmer`, `.v-anim-gradient-flow`, `.v-anim-border-beam` |
|
|
139
|
+
| **Attention & Ambient** | `.v-anim-shake`, `.v-anim-wiggle`, `.v-anim-pulse-ring`, `.v-anim-float` |
|
|
140
|
+
| **Modifiers** | `.v-anim-fast`, `.v-anim-normal`, `.v-anim-slow`, `.v-anim-slower`, `.v-anim-delay-100`, `.v-anim-delay-200`, `.v-anim-delay-300`, `.v-anim-delay-500`, `.v-anim-ease-smooth`, `.v-anim-ease-spring`, `.v-anim-ease-snappy`, `.v-anim-loop`, `.v-anim-paused`, `.v-anim-stagger` |
|
|
141
|
+
| **vUI Integration** | `.v-anim-modal` (on `.modal-content`), `.v-anim-drawer-end`, `.v-anim-drawer-start`, `.v-anim-dropdown` |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Customization (CSS Variables)
|
|
146
|
+
|
|
147
|
+
```css
|
|
148
|
+
.my-element {
|
|
149
|
+
--v-anim-duration: 450ms;
|
|
150
|
+
--v-anim-delay: 120ms;
|
|
151
|
+
--v-anim-distance: 24px;
|
|
152
|
+
--v-anim-scale: 0.92;
|
|
153
|
+
--v-anim-blur: 10px;
|
|
154
|
+
--v-anim-stagger-step: 70ms;
|
|
155
|
+
--v-anim-easing: var(--v-anim-ease-smooth);
|
|
156
|
+
--v-anim-accent: var(--primary);
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Accessibility
|
|
163
|
+
|
|
164
|
+
All animations automatically respect the user's `prefers-reduced-motion: reduce` system preference.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
MIT © `@vdragon100`
|