select-animation 1.0.0 β 1.1.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/index.js +11 -1
- package/package.json +1 -1
- package/readme.md +268 -0
package/index.js
CHANGED
|
@@ -705,4 +705,14 @@
|
|
|
705
705
|
|
|
706
706
|
// Additional helper functions can be added as needed...
|
|
707
707
|
|
|
708
|
-
|
|
708
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
709
|
+
module.exports = {
|
|
710
|
+
animate: global.animate
|
|
711
|
+
};
|
|
712
|
+
} else {
|
|
713
|
+
global.SelectAnimation = {
|
|
714
|
+
animate: global.animate
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
})(typeof window !== 'undefined' ? window : global);
|
package/package.json
CHANGED
package/readme.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
|
|
2
|
+
# π Select-Animation
|
|
3
|
+
|
|
4
|
+
## **HighβPerformance JavaScript Engine for Organic & Fluid Motion**
|
|
5
|
+
|
|
6
|
+
**Select-Animation** is a lightweight yet powerful JavaScript animation engine built in pure JavaScript, with zero dependencies. Designed for developers who require **full control over timing, easing, looping, and DOM interactions**, it emphasizes **performance, mathematical precision, and flexibility**.
|
|
7
|
+
|
|
8
|
+
This library is ideal for:
|
|
9
|
+
|
|
10
|
+
- Web UI animations
|
|
11
|
+
- SVG animations
|
|
12
|
+
- Interactive interfaces
|
|
13
|
+
- Advanced motion systems
|
|
14
|
+
|
|
15
|
+
It leverages `requestAnimationFrame` for smooth, high-performance rendering.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# β¨ Features
|
|
20
|
+
|
|
21
|
+
- β‘ **High Performance** β Utilizes `requestAnimationFrame` to ensure smooth animations
|
|
22
|
+
- π§ **Advanced Looping System** β Supports multiple cycle modes like repeat, ping-pong, and reverse
|
|
23
|
+
- π **Event-Controlled Pause/Resume** β Pause or resume animations via DOM events
|
|
24
|
+
- π¨ **Color & Transform Animation Support** β Animate CSS properties like color and transforms
|
|
25
|
+
- π **Rich Easing Library** β Includes various easing functions for natural motion
|
|
26
|
+
- π§© **SVG Compatibility** β Supports animation of SVG elements
|
|
27
|
+
- π§Ή **Automatic Memory Cleanup** β Prevents memory leaks
|
|
28
|
+
- πͺΆ **Pure JavaScript, Zero Dependencies**
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
# π¦ Installation
|
|
33
|
+
|
|
34
|
+
### Using npm:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install select-animation
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Usage in the browser:
|
|
41
|
+
|
|
42
|
+
Include the script directly:
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<script src="https://cdn.jsdelivr.net/npm/select-animation/index.js"></script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
or via CDN if available.
|
|
49
|
+
|
|
50
|
+
### Usage with ES Modules:
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
import "select-animation";
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
# π Basic Example
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
const element = document.querySelector(".box");
|
|
62
|
+
|
|
63
|
+
animate({
|
|
64
|
+
property: ["left", "opacity"], // Properties to animate
|
|
65
|
+
from: 0, // Starting values
|
|
66
|
+
to: 300, // Ending values
|
|
67
|
+
duration: 1000, // Duration in milliseconds
|
|
68
|
+
typeAnimation: "bounceout" // Easing type
|
|
69
|
+
})(element);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
# π§ Core Concepts
|
|
75
|
+
|
|
76
|
+
## Animation Configuration
|
|
77
|
+
|
|
78
|
+
Animations are defined using a configuration object:
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
{
|
|
82
|
+
from: 0,
|
|
83
|
+
to: 200,
|
|
84
|
+
duration: 1000,
|
|
85
|
+
property: ["left"],
|
|
86
|
+
typeAnimation: "cubicout"
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Properties Description
|
|
91
|
+
|
|
92
|
+
| Property | Description |
|
|
93
|
+
|-------------------|-----------------------------------------------------------|
|
|
94
|
+
| `from` | Starting value of the property |
|
|
95
|
+
| `to` | Final value of the property |
|
|
96
|
+
| `duration` | Duration of the animation in milliseconds |
|
|
97
|
+
| `property` | CSS property to animate |
|
|
98
|
+
| `typeAnimation` | Easing function for the animation |
|
|
99
|
+
| `timeline` | Delay offset for multiple elements or properties |
|
|
100
|
+
| `startafter` | Delay before the animation begins |
|
|
101
|
+
| `callback` | Custom function called on each frame |
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
# π Loop System
|
|
106
|
+
|
|
107
|
+
Supports advanced loop modes:
|
|
108
|
+
|
|
109
|
+
| Mode | Description |
|
|
110
|
+
|------------------|----------------------------------------------------------|
|
|
111
|
+
| `repeat` | Repeats indefinitely |
|
|
112
|
+
| `return` | Plays forward then backward |
|
|
113
|
+
| `returnRepeat` | Infinite ping-ponging |
|
|
114
|
+
| `repeatReturn` | Repeats then reverses direction |
|
|
115
|
+
|
|
116
|
+
Example:
|
|
117
|
+
|
|
118
|
+
```javascript
|
|
119
|
+
{
|
|
120
|
+
boucle: true,
|
|
121
|
+
boucleType: "returnRepeat"
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
# βΈ Pause / Resume with Events
|
|
128
|
+
|
|
129
|
+
Enable pausing or resuming animations via DOM events:
|
|
130
|
+
|
|
131
|
+
```javascript
|
|
132
|
+
{
|
|
133
|
+
pause: [".button", "e:click|false"]
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Meaning:**
|
|
138
|
+
|
|
139
|
+
- Pause the animation when `.button` is clicked.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
# π¨ Animating Colors
|
|
144
|
+
|
|
145
|
+
Supports color transitions for:
|
|
146
|
+
|
|
147
|
+
- `color`
|
|
148
|
+
- `backgroundColor`
|
|
149
|
+
- `borderColor`
|
|
150
|
+
|
|
151
|
+
Example:
|
|
152
|
+
|
|
153
|
+
```javascript
|
|
154
|
+
{
|
|
155
|
+
property: [{ backgroundColor: ["rgbR", "rgbG", "rgbB"] }],
|
|
156
|
+
from: { backgroundColor: [0, 0, 0] },
|
|
157
|
+
to: { backgroundColor: [255, 0, 0] },
|
|
158
|
+
duration: 1000
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
This allows smooth color transitions using RGB components.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
# π Transform Animations
|
|
167
|
+
|
|
168
|
+
Supports animating CSS transform properties:
|
|
169
|
+
|
|
170
|
+
- `translateX`, `translateY`, `translateZ`
|
|
171
|
+
- `rotateX`, `rotateY`, `rotateZ`
|
|
172
|
+
- `scale`
|
|
173
|
+
- `skewX`, `skewY`
|
|
174
|
+
|
|
175
|
+
Example:
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
{
|
|
179
|
+
property: [{ transform: ["translateX"] }],
|
|
180
|
+
from: 0,
|
|
181
|
+
to: 300,
|
|
182
|
+
duration: 800
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
# π Easing Functions
|
|
189
|
+
|
|
190
|
+
Includes a comprehensive set of easing algorithms, such as:
|
|
191
|
+
|
|
192
|
+
- **Quad**, **Cubic**, **Quart**, **Quint**
|
|
193
|
+
- **Sine**, **Expo**, **Circ**
|
|
194
|
+
- **Elastic**, **Back**, **Bounce**
|
|
195
|
+
|
|
196
|
+
Each easing supports:
|
|
197
|
+
|
|
198
|
+
- `in`
|
|
199
|
+
- `out`
|
|
200
|
+
- `inout`
|
|
201
|
+
- `outin`
|
|
202
|
+
|
|
203
|
+
Example:
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
typeAnimation: "bounceout"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
# π§© Special Animation Types
|
|
212
|
+
|
|
213
|
+
| Type | Description |
|
|
214
|
+
|------------------|------------------------------------------------|
|
|
215
|
+
| `linear` | Constant speed |
|
|
216
|
+
| `vibration` | Oscillation effect |
|
|
217
|
+
| `cubicbezier` | Custom cubic bezier curve |
|
|
218
|
+
|
|
219
|
+
Example:
|
|
220
|
+
|
|
221
|
+
```javascript
|
|
222
|
+
typeAnimation: "vibration"
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
# π Try It Online
|
|
228
|
+
|
|
229
|
+
Experiment with **Select-Animation** and explore various examples in your browser:
|
|
230
|
+
|
|
231
|
+
[π¬ Try Select-Animation Examples Online](https://selectjs.vercel.app/)
|
|
232
|
+
|
|
233
|
+
This interactive playground allows you to tweak properties, easing types, and sequences in real-time.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
# β Internal Architecture
|
|
238
|
+
|
|
239
|
+
The engine includes:
|
|
240
|
+
|
|
241
|
+
- **RequestAnimationFrame Polyfill** β ensures cross-browser support
|
|
242
|
+
- **Mathematical Easing Functions** β for smooth motion
|
|
243
|
+
- **Color & Transform State Caching** β for performance
|
|
244
|
+
- **Deep Object Copy Utility** β for safe data handling
|
|
245
|
+
- **Automatic Frame Cancellation** β to optimize resource use
|
|
246
|
+
|
|
247
|
+
Ensuring **performance efficiency and memory safety**.
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
# π€ Contributing
|
|
252
|
+
|
|
253
|
+
Contributions are welcome!
|
|
254
|
+
|
|
255
|
+
1. Fork the repository
|
|
256
|
+
2. Create a feature branch
|
|
257
|
+
3. Commit your changes
|
|
258
|
+
4. Submit a pull request
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
# π License
|
|
263
|
+
|
|
264
|
+
MIT License
|
|
265
|
+
|
|
266
|
+
Β© Housseyn Cheriet
|
|
267
|
+
|
|
268
|
+
---
|