Skip to content

Commit 5a9ca31

Browse files
committed
📝 Update README with full AnimText usage, attributes table, and examples
1 parent fadb1dc commit 5a9ca31

File tree

1 file changed

+57
-38
lines changed

1 file changed

+57
-38
lines changed

README.md

Lines changed: 57 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
![No Dependencies](https://img.shields.io/badge/Dependencies-None-lightgrey?style=for-the-badge)
66
[![Built for](https://img.shields.io/badge/Built%20for-cssanimation-blueviolet?style=for-the-badge)](https://github.com/yesiamrocks/cssanimation)
77
[![npm](https://img.shields.io/npm/v/animtext?style=for-the-badge)](https://www.npmjs.com/package/animtext)
8-
[![jsDelivr](https://img.shields.io/jsdelivr/npm/hm/animtext?style=for-the-badge)](https://cdn.jsdelivr.net/npm/animtext@latest/dist/)
8+
[![jsDelivr](https://img.shields.io/jsdelivr/npm/hm/animtext?style=for-the-badge)](https://www.jsdelivr.com/package/npm/animtext)
99
[![unpkg](https://img.shields.io/badge/CDN-unpkg-blue?style=for-the-badge)](https://unpkg.com/browse/animtext/)
1010
[![View Demo](https://img.shields.io/badge/🎬%20Live-Demo-green?style=for-the-badge)](https://yesiamrocks.github.io/animtext/)
1111

@@ -44,43 +44,85 @@ animtext.init({ dev: true });
4444
<script src="https://cdn.jsdelivr.net/npm/animtext@latest/dist/animtext.min.js"></script>
4545
```
4646

47-
animtext requires @hellouxpavel/cssanimation to function. It provides the actual animation classes (like ca\_\_fx-fadeIn) used in the HTML examples.
47+
## Animation Classes Powered by {css}animation
48+
49+
**AnimText** is designed to work hand-in-hand with the animation classes from **[{css}animation](https://github.com/yesiamrocks/cssanimation)**. These CSS classes are required to make the **AnimText** actually animate elements, so be sure to include them in your project.
50+
51+
Install the animation library:
4852

4953
```bash
5054
npm install @hellouxpavel/cssanimation
5155
```
5256

57+
Then import it in your JavaScript:
58+
59+
```js
60+
import "@hellouxpavel/cssanimation";
61+
```
62+
63+
Or include it via CDN:
64+
65+
```html
66+
<link
67+
rel="stylesheet"
68+
href="https://cdn.jsdelivr.net/npm/@hellouxpavel/cssanimation@latest/dist/cssanimation.min.css" />
69+
```
70+
71+
Without the cssanimation classes, **AnimText** can still spilt the text, but no animation will play.
72+
5373
## Getting Started
5474

5575
```html
5676
<h1 class="cssanimation" data-at-sequence="ca__fx-fadeIn">Hello AnimText!</h1>
5777
```
5878

5979
This will animate the letters of the heading using your chosen animation class.
80+
`class="cssanimation"` – Required. This enables animation support from the **[{css}animation](https://github.com/yesiamrocks/cssanimation)** library.
81+
82+
## Supported Attributes
83+
84+
| Attribute | Description |
85+
| ----------------------- | -------------------------------------------------------------------------------- |
86+
| `data-at-sequence` | Animates letter-by-letter, in order. |
87+
| `data-at-random` | Animates letter-by-letter, in a randomized order. |
88+
| `data-at-reverse` | Animates letter-by-letter, in reverse order (last letter first). |
89+
| `data-at-word` | Animates word-by-word. |
90+
| `data-at-line` | Animates line-by-line. |
91+
| `data-at-delay` | Accepts one or more delay values (e.g., `100 300 500`) in milliseconds per unit. |
92+
| `data-at-base-duration` | Optional base animation duration per unit (in ms) |
93+
| `data-at-separator` | Use `dot` to split on periods `( . )`. Default: line breaks (`<br>` or `\n`) |
6094

61-
## Letter Animation Usage
95+
**Example**
6296

63-
Every animated text block needs the `.cssanimation` class along with a `data-at-*` attribute to define how it animates.
97+
```html
98+
<h2
99+
class="cssanimation"
100+
data-at-word="ca__fx-fadeIn ca__fx-fadeInLeft ca__fx-slinkyDrop ca__fx-jiggleTransform"
101+
data-at-delay="200 300 400"
102+
data-at-duration="1000">
103+
Animate each word smoothly
104+
</h2>
105+
```
64106

65-
### 1. Letter-by-Letter Animation
107+
## 1. Letter Animation Usage
66108

67109
Animate text one letter at a time with different sequencing styles:
68110

69-
**Sequential (in order):** `data-at-sequence`
111+
**Sequential (in order):** `data-at-sequence`
70112

71113
```html
72114
<h1 class="cssanimation" data-at-sequence="ca__fx-fadeIn">Letters Animate</h1>
73115
```
74116

75-
**Randomized order** `data-at-random`
117+
**Randomized order** `data-at-random`
76118

77119
```html
78120
<p class="cssanimation" data-at-random="ca__fx-bounceInTop">
79121
Randomized entry!
80122
</p>
81123
```
82124

83-
**Reverse (last letter first)** `data-at-reverse`
125+
**Reverse (last letter first)** `data-at-reverse`
84126

85127
```html
86128
<h3 class="cssanimation" data-at-reverse="ca__fx-moveFromTop">
@@ -90,15 +132,15 @@ Animate text one letter at a time with different sequencing styles:
90132

91133
---
92134

93-
### 2. Word-by-Word Animation `data-at-word`
135+
## 2. Word-by-Word Animation `data-at-word`
94136

95137
```html
96138
<h2 class="cssanimation" data-at-word="ca__fx-fadeIn">
97139
Each word animates uniquely
98140
</h2>
99141
```
100142

101-
### 3. Line-by-line Animation `data-at-line`
143+
## 3. Line-by-line Animation `data-at-line`
102144

103145
```html
104146
<p class="cssanimation" data-at-line="ca__fx-fadeIn">
@@ -118,7 +160,9 @@ Split lines by periods `"."` or by `<br>` / `\n`. Use `data-at-separator="dot"`
118160

119161
You don't need to add `data-at-separator` for `<br>` or newlines, this is the **default behavior**.
120162

121-
**🔥You can assign different animation classes and delays to each word and line! Space-separate your class names and delay values.**
163+
## Multiple Animation Classes
164+
165+
🔥You can assign different animation classes and delays to each **word and line**! Space-separate your class names and delay values.
122166

123167
```html
124168
<h2
@@ -140,7 +184,7 @@ You don't need to add `data-at-separator` for `<br>` or newlines, this is the **
140184

141185
[Check out this Text & Letter Animations Preview Tool to easily generate the animation code for your text.](https://yesiamrocks.github.io/cssanimation/text-animation.html)
142186

143-
## `data-at-delay` in Detail
187+
## `data-at-delay`
144188

145189
The `data-at-delay` attribute specifies the delay before each animated unit (letter, word, or line) begins its animation. The values are in milliseconds (ms).
146190

@@ -162,7 +206,7 @@ The `data-at-delay` attribute specifies the delay before each animated unit (let
162206

163207
This allows you to create rhythmic or staggered entry effects easily, like `data-at-delay="50 100 100"` as in your example. The first unit gets 50ms delay, and all subsequent units get 100ms delay.
164208

165-
## `data-at-base-duration` in Detail
209+
## `data-at-base-duration`
166210

167211
The `data-at-base-duration` attribute provides a simple way to set a global default animation duration for all units (letters, words, or lines) in milliseconds (ms).
168212

@@ -185,31 +229,6 @@ This value is used to explicitly set the duration for all units, overriding any
185229

186230
This means `data-at-base-duration` gives you a convenient way to set a project-wide or component-wide default duration without needing to edit CSS.
187231

188-
## Supported Attributes for Text Animations Plugin
189-
190-
| Attribute | Description |
191-
| ----------------------- | -------------------------------------------------------------------------------- |
192-
| `data-at-sequence` | Animates letter-by-letter, in order. |
193-
| `data-at-random` | Animates letter-by-letter, in a randomized order. |
194-
| `data-at-reverse` | Animates letter-by-letter, in reverse order (last letter first). |
195-
| `data-at-word` | Animates word-by-word. |
196-
| `data-at-line` | Animates line-by-line. |
197-
| `data-at-delay` | Accepts one or more delay values (e.g., `100 300 500`) in milliseconds per unit. |
198-
| `data-at-base-duration` | Optional base animation duration per unit (in ms) |
199-
| `data-at-separator` | Use `dot` to split on periods `( . )`. Default: line breaks (`<br>` or `\n`) |
200-
201-
**Example: Full Setup**
202-
203-
```html
204-
<h2
205-
class="cssanimation"
206-
data-at-word="ca__fx-fadeIn ca__fx-fadeInLeft ca__fx-slinkyDrop ca__fx-jiggleTransform"
207-
data-at-delay="200 300 400"
208-
data-at-duration="1000">
209-
Animate each word smoothly
210-
</h2>
211-
```
212-
213232
## Developer Tips
214233

215234
- The `.cssanimation` **class is always required** for baseline styling and to activate text animations.

0 commit comments

Comments
 (0)