animejs 3.2.1 → 4.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.
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2019 Julian Garnier
3
+ Copyright (c) 2025 Julian Garnier
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
package/README.md CHANGED
@@ -1,109 +1,288 @@
1
- <h1 align="center">
2
- <a href="https://animejs.com"><img src="/documentation/assets/img/animejs-v3-header-animation.gif" width="250"/></a>
3
- <br>
4
- anime.js
5
- </h1>
6
-
7
- <h4 align="center">JavaScript animation engine | <a href="https://animejs.com" target="_blank">animejs.com</a></h4>
1
+ # Anime.js
8
2
 
9
3
  <p align="center">
10
- <a href="https://www.npmjs.com/package/animejs" rel="nofollow"><img src="https://camo.githubusercontent.com/011820ee25bf1d3ddaf635d869903b98eccaeae7/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f616e696d656a732e7376673f7374796c653d666c61742d737175617265" alt="npm version" data-canonical-src="https://img.shields.io/npm/v/animejs.svg?style=flat-square" style="max-width:100%;"></a>
11
- <a href="https://www.npmjs.com/package/animejs" rel="nofollow"><img src="https://camo.githubusercontent.com/3e9b69d51aee25fad784a3097676696096621d47/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f646d2f616e696d656a732e7376673f7374796c653d666c61742d737175617265" alt="npm downloads" data-canonical-src="https://img.shields.io/npm/dm/animejs.svg?style=flat-square" style="max-width:100%;"></a>
4
+ <picture align="center">
5
+ <source media="(prefers-color-scheme: dark)" srcset="./assets/images/animejs-v4-logo-animation-dark.gif">
6
+ <img align="center" alt="Anime.js V4 logo animation" src="./assets/images/animejs-v4-logo-animation.gif" width="560">
7
+ </picture>
12
8
  </p>
13
9
 
14
- <blockquote align="center">
15
- <em>Anime.js</em> (<code>/ˈæn.ə.meɪ/</code>) is a lightweight JavaScript animation library with a simple, yet powerful API.<br>
10
+ <p align="center">
11
+ <strong>
12
+ <em>Anime.js</em> is a fast, multipurpose and lightweight JavaScript animation library with a simple, yet powerful API.<br>
16
13
  It works with CSS properties, SVG, DOM attributes and JavaScript Objects.
17
- </blockquote>
14
+ </strong>
15
+ </p>
18
16
 
19
17
  <p align="center">
20
- <a href="#getting-started">Getting started</a>&nbsp;|&nbsp;<a href="#documentation">Documentation</a>&nbsp;|&nbsp;<a href="#demos-and-examples">Demos and examples</a>&nbsp;|&nbsp;<a href="#browser-support">Browser support</a>
18
+ <img alt="NPM Downloads" src="https://img.shields.io/npm/dm/animejs?style=flat-square&logo=npm">
19
+ <img alt="jsDelivr hits (npm)" src="https://img.shields.io/jsdelivr/npm/hm/animejs?style=flat-square&logo=jsdeliver">
20
+ <img alt="GitHub Sponsors" src="https://img.shields.io/github/sponsors/juliangarnier?style=flat-square&logo=github">
21
21
  </p>
22
22
 
23
- ## Getting started
23
+ ## Usage
24
24
 
25
- ### Download
25
+ Anime.js V4 works by importing ES modules like so:
26
26
 
27
- Via npm
27
+ <table>
28
+ <tr>
29
+ <td>
28
30
 
29
- ```bash
30
- $ npm install animejs --save
31
+ ```javascript
32
+ import {
33
+ animate,
34
+ stagger,
35
+ } from 'animejs';
36
+
37
+ animate('.square', {
38
+ x: 320,
39
+ rotate: { from: -180 },
40
+ duration: 1250,
41
+ delay: stagger(65, { from: 'center' }),
42
+ ease: 'inOutQuint',
43
+ loop: true,
44
+ alternate: true
45
+ });
31
46
  ```
32
47
 
33
- or manual [download](https://github.com/juliangarnier/anime/archive/master.zip).
48
+ </td>
49
+ <td>
50
+ <img align="center" alt="Anime.js code example" src="./assets/images/usage-example-result.gif">
51
+ </td>
52
+ </tr>
53
+ </table>
34
54
 
35
- ### Usage
55
+ ## V4 Documentation
36
56
 
37
- #### ES6 modules
57
+ The full documentation is available [here](https://animejs.com/documentation).
38
58
 
39
- ```javascript
40
- import anime from 'animejs/lib/anime.es.js';
59
+ ## NPM development scripts
60
+
61
+ First, run `npm i` to install all the necessary packages.
62
+ Then, execute the following scripts with `npm run <script>`.
63
+
64
+ | script | action |
65
+ | ------ | ------ |
66
+ | `dev` | Watch any changes in `src/` and compiles the esm version to `lib/anime.esm.js` |
67
+ | `dev-types` | Same as `dev`, but also run TypeScript and generate the `types/index.d.ts` file |
68
+ | `build` | Generate types definition and compiles ESM / UMD / IIFE versions to `lib/` |
69
+ | `test-browser` | Start a local server and start all browser related tests |
70
+ | `test-node` | Start all Node related tests |
71
+ | `open-examples` | Start a local server to browse the examples locally |
72
+
73
+ ## Our sponsors
74
+
75
+ Anime.js is 100% free and is only made possible with the help of our sponsors.
76
+
77
+ ## Platinum sponsors
78
+
79
+ <table>
80
+ <tr>
81
+ <td>
82
+ <a target="_blank" href="https://huly.io?ref=animejs">
83
+ <picture>
84
+ <source media="(prefers-color-scheme: dark)" srcset="./assets/sponsors/huly-logomark.svg">
85
+ <img align="center" src="./assets/sponsors/huly-logomark-dark.svg" width="128">
86
+ </picture>
87
+ </a>
88
+ </td>
89
+ <td>
90
+ <a target="_blank" href="https://clutch.io?ref=animejs">
91
+ <picture>
92
+ <source media="(prefers-color-scheme: dark)" srcset="./assets/sponsors/clutch-logomark.svg">
93
+ <img align="center" src="./assets/sponsors/clutch-logomark-dark.svg" width="128">
94
+ </picture>
95
+ </a>
96
+ </td>
97
+ <td>
98
+ <a target="_blank" href="https://github.com/sponsors/juliangarnier">
99
+ <picture>
100
+ <source media="(prefers-color-scheme: dark)" srcset="./assets/sponsors/placeholder.svg">
101
+ <img align="center" src="./assets/sponsors/placeholder-dark.svg" width="128">
102
+ </picture>
103
+ </a>
104
+ </td>
105
+ </tr>
106
+ <tr>
107
+ <td align="center">
108
+ <a target="_blank" href="https://huly.io?ref=animejs">Huly</a>
109
+ </td>
110
+ <td align="center">
111
+ <a target="_blank" href="https://clutch.io?ref=animejs">Clutch</a>
112
+ </td>
113
+ <td align="center">
114
+ <a target="_blank" href="https://github.com/sponsors/juliangarnier">Your logo here</a>
115
+ </td>
116
+ </tr>
117
+ </table>
118
+
119
+ ## V4 API breaking changes overview
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
+ });
41
163
  ```
42
164
 
43
- #### CommonJS
165
+ ### Promises
44
166
 
45
- ```javascript
46
- const anime = require('animejs');
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(() => {});
47
173
  ```
48
174
 
49
- #### File include
175
+ ### Timers
50
176
 
51
- Link `anime.min.js` in your HTML :
177
+ ```diff
178
+ - import anime from 'animejs';
179
+ + import { createTimer } from 'animejs';
52
180
 
53
- ```html
54
- <script src="anime.min.js"></script>
181
+ - anime({
182
+ + createTimer({
183
+ - duration: Infinity,
184
+ - update: () => {},
185
+ + onUpdate: () => {},
186
+ });
55
187
  ```
56
188
 
57
- ### Hello world
189
+ ### Timelines
58
190
 
59
- ```javascript
60
- anime({
61
- targets: 'div',
62
- translateX: 250,
63
- rotate: '1turn',
64
- backgroundColor: '#FFF',
65
- duration: 800
66
- });
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
+ });
67
256
  ```
68
257
 
69
- ## [Documentation](https://animejs.com/documentation/)
70
-
71
- * [Targets](https://animejs.com/documentation/#cssSelector)
72
- * [Properties](https://animejs.com/documentation/#cssProperties)
73
- * [Property parameters](https://animejs.com/documentation/#duration)
74
- * [Animation parameters](https://animejs.com/documentation/#direction)
75
- * [Values](https://animejs.com/documentation/#unitlessValue)
76
- * [Keyframes](https://animejs.com/documentation/#animationKeyframes)
77
- * [Staggering](https://animejs.com/documentation/#staggeringBasics)
78
- * [Timeline](https://animejs.com/documentation/#timelineBasics)
79
- * [Controls](https://animejs.com/documentation/#playPause)
80
- * [Callbacks and promises](https://animejs.com/documentation/#update)
81
- * [SVG Animations](https://animejs.com/documentation/#motionPath)
82
- * [Easing functions](https://animejs.com/documentation/#linearEasing)
83
- * [Helpers](https://animejs.com/documentation/#remove)
84
-
85
- ## [Demos and examples](http://codepen.io/collection/b392d3a52d6abf5b8d9fda4e4cab61ab/)
86
-
87
- * [CodePen demos and examples](http://codepen.io/collection/b392d3a52d6abf5b8d9fda4e4cab61ab/)
88
- * [juliangarnier.com](http://juliangarnier.com)
89
- * [animejs.com](https://animejs.com)
90
- * [Moving letters](http://tobiasahlin.com/moving-letters/) by [@tobiasahlin](https://twitter.com/tobiasahlin)
91
- * [Gradient topography animation](https://tympanus.net/Development/GradientTopographyAnimation/) by [@crnacura](https://twitter.com/crnacura)
92
- * [Organic shape animations](https://tympanus.net/Development/OrganicShapeAnimations/) by [@crnacura](https://twitter.com/crnacura)
93
- * [Pieces slider](https://tympanus.net/Tutorials/PiecesSlider/) by [@lmgonzalves](https://twitter.com/lmgonzalves)
94
- * [Staggering animations](https://codepen.io/juliangarnier/pen/4fe31bbe8579a256e828cd4d48c86182?editors=0100)
95
- * [Easings animations](https://codepen.io/juliangarnier/pen/444ed909fd5de38e3a77cc6e95fc1884)
96
- * [Sphere animation](https://codepen.io/juliangarnier/pen/b3bb8ca599ad0f9d00dd044e56cbdea5?editors=0010)
97
- * [Layered animations](https://codepen.io/juliangarnier/pen/6ca836535cbea42157d1b8d56d00be84?editors=0010)
98
- * [anime.js logo animation](https://codepen.io/juliangarnier/pen/d43e8ec355c30871cbe775193255d6f6?editors=0010)
99
-
100
-
101
- ## Browser support
102
-
103
- | Chrome | Safari | IE / Edge | Firefox | Opera |
104
- | --- | --- | --- | --- | --- |
105
- | 24+ | 8+ | 11+ | 32+ | 15+ |
106
-
107
- ## <a href="https://animejs.com"><img src="/documentation/assets/img/animejs-v3-logo-animation.gif" width="150" alt="anime-js-v3-logo"/></a>
108
-
109
- [Website](https://animejs.com/) | [Documentation](https://animejs.com/documentation/) | [Demos and examples](http://codepen.io/collection/b392d3a52d6abf5b8d9fda4e4cab61ab/) | [MIT License](LICENSE.md) | © 2019 [Julian Garnier](http://juliangarnier.com).
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
+ ```