animejs 4.0.0 → 4.0.2
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 +13 -177
- package/lib/anime.cjs +2 -2
- package/lib/anime.esm.js +149 -112
- package/lib/anime.esm.min.js +2 -2
- package/lib/anime.iife.js +2 -2
- package/lib/anime.iife.min.js +2 -2
- package/lib/anime.min.cjs +2 -2
- package/lib/anime.umd.js +2 -2
- package/lib/anime.umd.min.js +2 -2
- package/package.json +1 -1
- package/types/index.d.ts +47 -43
- package/types/index.js +80 -94
package/README.md
CHANGED
|
@@ -56,6 +56,10 @@ animate('.square', {
|
|
|
56
56
|
|
|
57
57
|
The full documentation is available [here](https://animejs.com/documentation).
|
|
58
58
|
|
|
59
|
+
## V3 Migration guide
|
|
60
|
+
|
|
61
|
+
You can find the v3 to v4 migration guide [here](https://github.com/juliangarnier/anime/wiki/Migrating-from-v3-to-v4).
|
|
62
|
+
|
|
59
63
|
## NPM development scripts
|
|
60
64
|
|
|
61
65
|
First, run `npm i` to install all the necessary packages.
|
|
@@ -73,13 +77,14 @@ Then, execute the following scripts with `npm run <script>`.
|
|
|
73
77
|
## Our sponsors
|
|
74
78
|
|
|
75
79
|
Anime.js is 100% free and is only made possible with the help of our sponsors.
|
|
80
|
+
Help the project become sustainable by sponsoring us on <a target="_blank" href="https://github.com/sponsors/juliangarnier">GitHub Sponsors</a>.
|
|
76
81
|
|
|
77
|
-
|
|
82
|
+
### Platinum sponsors
|
|
78
83
|
|
|
79
84
|
<table>
|
|
80
85
|
<tr>
|
|
81
86
|
<td>
|
|
82
|
-
<a target="_blank" href="https://huly.io
|
|
87
|
+
<a target="_blank" href="https://huly.io/?ref=animejs">
|
|
83
88
|
<picture>
|
|
84
89
|
<source media="(prefers-color-scheme: dark)" srcset="./assets/sponsors/huly-logomark.svg">
|
|
85
90
|
<img align="center" src="./assets/sponsors/huly-logomark-dark.svg" width="128">
|
|
@@ -87,10 +92,10 @@ Anime.js is 100% free and is only made possible with the help of our sponsors.
|
|
|
87
92
|
</a>
|
|
88
93
|
</td>
|
|
89
94
|
<td>
|
|
90
|
-
<a target="_blank" href="https://
|
|
95
|
+
<a target="_blank" href="https://ice.io/?ref=animejs">
|
|
91
96
|
<picture>
|
|
92
|
-
<source media="(prefers-color-scheme: dark)" srcset="./assets/sponsors/
|
|
93
|
-
<img align="center" src="./assets/sponsors/
|
|
97
|
+
<source media="(prefers-color-scheme: dark)" srcset="./assets/sponsors/ice-open-network-logomark.svg">
|
|
98
|
+
<img align="center" src="./assets/sponsors/ice-open-network-logomark-dark.svg" width="128">
|
|
94
99
|
</picture>
|
|
95
100
|
</a>
|
|
96
101
|
</td>
|
|
@@ -105,10 +110,10 @@ Anime.js is 100% free and is only made possible with the help of our sponsors.
|
|
|
105
110
|
</tr>
|
|
106
111
|
<tr>
|
|
107
112
|
<td align="center">
|
|
108
|
-
<a target="_blank" href="https://huly.io
|
|
113
|
+
<a target="_blank" href="https://huly.io/?ref=animejs">Huly</a>
|
|
109
114
|
</td>
|
|
110
115
|
<td align="center">
|
|
111
|
-
<a target="_blank" href="https://
|
|
116
|
+
<a target="_blank" href="https://ice.io/?ref=animejs">Ice Open Network</a>
|
|
112
117
|
</td>
|
|
113
118
|
<td align="center">
|
|
114
119
|
<a target="_blank" href="https://github.com/sponsors/juliangarnier">Your logo here</a>
|
|
@@ -116,173 +121,4 @@ Anime.js is 100% free and is only made possible with the help of our sponsors.
|
|
|
116
121
|
</tr>
|
|
117
122
|
</table>
|
|
118
123
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
### Animations
|
|
122
|
-
|
|
123
|
-
```diff
|
|
124
|
-
- import anime from 'animejs';
|
|
125
|
-
+ import { animate, createSpring, utils } from 'animejs';
|
|
126
|
-
|
|
127
|
-
- anime({
|
|
128
|
-
- targets: 'div',
|
|
129
|
-
+ animate('div', {
|
|
130
|
-
translateX: 100,
|
|
131
|
-
rotate: {
|
|
132
|
-
- value: 360,
|
|
133
|
-
+ to: 360,
|
|
134
|
-
- easing: 'spring(.7, 80, 10, .5)',
|
|
135
|
-
+ ease: createSpring({ mass: .7, damping: 80, stiffness: 10, velocity: .5}),
|
|
136
|
-
},
|
|
137
|
-
- easing: 'easeinOutExpo',
|
|
138
|
-
+ ease: 'inOutExpo',
|
|
139
|
-
- easing: () => t => Math.cos(t),
|
|
140
|
-
+ ease: t => Math.cos(t),
|
|
141
|
-
- direction: 'reverse',
|
|
142
|
-
+ reversed: true,
|
|
143
|
-
- direction: 'alternate',
|
|
144
|
-
+ alternate: true,
|
|
145
|
-
- loop: 1,
|
|
146
|
-
+ loop: 0,
|
|
147
|
-
- round: 100,
|
|
148
|
-
+ modifier: utils.round(2),
|
|
149
|
-
- begin: () => {},
|
|
150
|
-
+ onBegin: () => {},
|
|
151
|
-
- update: () => {},
|
|
152
|
-
+ onUpdate: () => {},
|
|
153
|
-
- change: () => {},
|
|
154
|
-
+ onRender: () => {},
|
|
155
|
-
- changeBegin: () => {},
|
|
156
|
-
- changeComplete: () => {},
|
|
157
|
-
- loopBegin: () => {},
|
|
158
|
-
- loopComplete: () => {},
|
|
159
|
-
+ onLoop: () => {},
|
|
160
|
-
- complete: () => {},
|
|
161
|
-
+ onComplete: () => {},
|
|
162
|
-
});
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### Promises
|
|
166
|
-
|
|
167
|
-
```diff
|
|
168
|
-
- import anime from 'animejs';
|
|
169
|
-
+ import { animate, utils } from 'animejs';
|
|
170
|
-
|
|
171
|
-
- anime({ targets: target, prop: x }).finished.then(() => {});
|
|
172
|
-
+ animate(target, { prop: x }).then(() => {});
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
### Timers
|
|
176
|
-
|
|
177
|
-
```diff
|
|
178
|
-
- import anime from 'animejs';
|
|
179
|
-
+ import { createTimer } from 'animejs';
|
|
180
|
-
|
|
181
|
-
- anime({
|
|
182
|
-
+ createTimer({
|
|
183
|
-
- duration: Infinity,
|
|
184
|
-
- update: () => {},
|
|
185
|
-
+ onUpdate: () => {},
|
|
186
|
-
});
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
### Timelines
|
|
190
|
-
|
|
191
|
-
```diff
|
|
192
|
-
- import anime from 'animejs';
|
|
193
|
-
+ import { createTimeline, stagger } from 'animejs';
|
|
194
|
-
|
|
195
|
-
- anime.timeline({
|
|
196
|
-
+ createTimeline({
|
|
197
|
-
- duration: 500,
|
|
198
|
-
- easing: 'easeInOutQuad',
|
|
199
|
-
+ defaults: {
|
|
200
|
-
+ duration: 500,
|
|
201
|
-
+ ease: 'inOutQuad',
|
|
202
|
-
+ }
|
|
203
|
-
- loop: 2,
|
|
204
|
-
+ loop: 1,
|
|
205
|
-
- }).add({
|
|
206
|
-
- targets: 'div',
|
|
207
|
-
+ }).add('div', {
|
|
208
|
-
rotate: 90,
|
|
209
|
-
})
|
|
210
|
-
- .add('.target:nth-child(1)', { opacity: 0, onComplete }, 0)
|
|
211
|
-
- .add('.target:nth-child(2)', { opacity: 0, onComplete }, 100)
|
|
212
|
-
- .add('.target:nth-child(3)', { opacity: 0, onComplete }, 200)
|
|
213
|
-
- .add('.target:nth-child(4)', { opacity: 0, onComplete }, 300)
|
|
214
|
-
+ .add('.target', { opacity: 0, onComplete }, stagger(100))
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### Stagger
|
|
218
|
-
|
|
219
|
-
```diff
|
|
220
|
-
- import anime from 'animejs';
|
|
221
|
-
+ import { animate, stagger } from 'animejs';
|
|
222
|
-
|
|
223
|
-
- anime({
|
|
224
|
-
- targets: 'div',
|
|
225
|
-
+ animate('div', {
|
|
226
|
-
- translateX: anime.stagger(100),
|
|
227
|
-
+ translateX: stagger(100),
|
|
228
|
-
- delay: anime.stagger(100, { direction: 'reversed' }),
|
|
229
|
-
+ translateX: stagger(100, { reversed: true }),
|
|
230
|
-
});
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
### SVG
|
|
234
|
-
|
|
235
|
-
```diff
|
|
236
|
-
- import anime from 'animejs';
|
|
237
|
-
+ import { animate, svg } from 'animejs';
|
|
238
|
-
|
|
239
|
-
- const path = anime.path('path');
|
|
240
|
-
+ const { x, y, angle } = svg.createMotionPath('path');
|
|
241
|
-
|
|
242
|
-
- anime({
|
|
243
|
-
- targets: '#shape1',
|
|
244
|
-
+ animate('#shape1', {
|
|
245
|
-
- points: '70 41 118.574 59.369 111.145 132.631 60.855 84.631 20.426 60.369',
|
|
246
|
-
+ points: svg.morphTo('#shape2'),
|
|
247
|
-
- strokeDashoffset: [anime.setDashoffset, 0],
|
|
248
|
-
+ strokeDashoffset: svg.drawLine(),
|
|
249
|
-
- translateX: path('x'),
|
|
250
|
-
- translateY: path('y'),
|
|
251
|
-
- rotate: path('angle'),
|
|
252
|
-
+ translateX: x,
|
|
253
|
-
+ translateY: y,
|
|
254
|
-
+ rotate: angle,
|
|
255
|
-
});
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
### Utils
|
|
259
|
-
|
|
260
|
-
```diff
|
|
261
|
-
- import anime from 'animejs';
|
|
262
|
-
+ import { utils } from 'animejs';
|
|
263
|
-
|
|
264
|
-
- const value = anime.get('#target1', 'translateX');
|
|
265
|
-
+ const value = utils.get('#target1', 'translateX');
|
|
266
|
-
|
|
267
|
-
- anime.set('#target1', { translateX: 100 });
|
|
268
|
-
+ utils.set('#target1', { translateX: 100 });
|
|
269
|
-
|
|
270
|
-
- anime.remove('#target1');
|
|
271
|
-
+ utils.remove('#target1');
|
|
272
|
-
|
|
273
|
-
- const rounded = anime.round(value);
|
|
274
|
-
+ const rounded = utils.round(value, 0);
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
### Engine
|
|
278
|
-
|
|
279
|
-
```diff
|
|
280
|
-
- import anime from 'animejs';
|
|
281
|
-
+ import { engine } from 'animejs';
|
|
282
|
-
|
|
283
|
-
- anime.suspendWhenDocumentHidden = false;
|
|
284
|
-
+ engine.pauseWhenHidden = false;
|
|
285
|
-
|
|
286
|
-
- anime.speed = .5;
|
|
287
|
-
+ engine.playbackRate = .5;
|
|
288
|
-
```
|
|
124
|
+
© [Julian Garnier](http://juliangarnier.com) | [MIT License](LICENSE.md)
|