https://github.com/juliangarnier/anime
JavaScript animation engine
https://github.com/juliangarnier/anime
animation anime canvas css javascript javascript-library svg
Last synced: 5 days ago
JSON representation
JavaScript animation engine
- Host: GitHub
- URL: https://github.com/juliangarnier/anime
- Owner: juliangarnier
- License: mit
- Created: 2016-03-13T21:37:45.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-11-10T08:45:21.000Z (5 months ago)
- Last Synced: 2025-04-01T11:02:04.885Z (11 days ago)
- Topics: animation, anime, canvas, css, javascript, javascript-library, svg
- Language: JavaScript
- Homepage: https://animejs.com
- Size: 47 MB
- Stars: 51,132
- Watchers: 756
- Forks: 3,713
- Open Issues: 235
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
- awesome-frontend - anime.js - JavaScript animation engine.  (Repository / Animation)
- awesome-frontend-lib - anime.js
- my-awesome-starred - juliangarnier/anime - JavaScript animation engine (JavaScript)
- awesome-repositories - juliangarnier/anime - JavaScript animation engine (JavaScript)
- awesome-starred - anime - JavaScript animation engine (JavaScript)
- awesome-github-star - anime
- awesome-list - anime
- awesome-starts - juliangarnier/anime - JavaScript animation engine (JavaScript)
- awesome - juliangarnier/anime - JavaScript animation engine (JavaScript)
- awesome-list - anime
- StarryDivineSky - juliangarnier/anime
- awesome-web-animation - Anime.js - JavaScript animation engine. (Common)
- awesome-star-libs - juliangarnier / anime
- awesome-frontend-libraries - animejs
- stars - juliangarnier/anime - JavaScript animation engine \[*MIT License*\] (⭐️53181) (JavaScript)
- stars - juliangarnier/anime - JavaScript animation engine \[*MIT License*\] (⭐️50345) (JavaScript)
- awesome - juliangarnier/anime - JavaScript animation engine (JavaScript)
- awesome - juliangarnier/anime - JavaScript animation engine (JavaScript)
README
# Anime.js
![]()
Anime.js is a fast, multipurpose and lightweight JavaScript animation library with a simple, yet powerful API.
It works with CSS properties, SVG, DOM attributes and JavaScript Objects.
![]()
![]()
![]()
## Usage
Anime.js V4 works by importing ES modules like so:
```javascript
import {
animate,
stagger,
} from 'animejs';animate('.square', {
x: 320,
rotate: { from: -180 },
duration: 1250,
delay: stagger(65, { from: 'center' }),
ease: 'inOutQuint',
loop: true,
alternate: true
});
```
![]()
## V4 Documentation
The full documentation is available [here](https://animejs.com/documentation).
## Our sponsors
Anime.js is 100% free and is only made possible with the help of our sponsors.
Help the project become sustainable by sponsoring us on GitHub Sponsors.## Platinum sponsors
![]()
![]()
![]()
Huly
Ice Open Network
Your logo here
## NPM development scripts
First, run `npm i` to install all the necessary packages.
Then, execute the following scripts with `npm run `.| script | action |
| ------ | ------ |
| `dev` | Watch any changes in `src/` and compiles the esm version to `lib/anime.esm.js` |
| `dev-types` | Same as `dev`, but also run TypeScript and generate the `types/index.d.ts` file |
| `build` | Generate types definition and compiles ESM / UMD / IIFE versions to `lib/` |
| `test-browser` | Start a local server and start all browser related tests |
| `test-node` | Start all Node related tests |
| `open-examples` | Start a local server to browse the examples locally |## V4 API breaking changes overview
### Animations
```diff
- import anime from 'animejs';
+ import { animate, createSpring, utils } from 'animejs';- anime({
- targets: 'div',
+ animate('div', {
translateX: 100,
rotate: {
- value: 360,
+ to: 360,
- easing: 'spring(.7, 80, 10, .5)',
+ ease: createSpring({ mass: .7, damping: 80, stiffness: 10, velocity: .5}),
},
- easing: 'easeinOutExpo',
+ ease: 'inOutExpo',
- easing: () => t => Math.cos(t),
+ ease: t => Math.cos(t),
- direction: 'reverse',
+ reversed: true,
- direction: 'alternate',
+ alternate: true,
- loop: 1,
+ loop: 0,
- round: 100,
+ modifier: utils.round(2),
- begin: () => {},
+ onBegin: () => {},
- update: () => {},
+ onUpdate: () => {},
- change: () => {},
+ onRender: () => {},
- changeBegin: () => {},
- changeComplete: () => {},
- loopBegin: () => {},
- loopComplete: () => {},
+ onLoop: () => {},
- complete: () => {},
+ onComplete: () => {},
});
```### Promises
```diff
- import anime from 'animejs';
+ import { animate, utils } from 'animejs';- anime({ targets: target, prop: x }).finished.then(() => {});
+ animate(target, { prop: x }).then(() => {});
```### Timers
```diff
- import anime from 'animejs';
+ import { createTimer } from 'animejs';- anime({
+ createTimer({
- duration: Infinity,
- update: () => {},
+ onUpdate: () => {},
});
```### Timelines
```diff
- import anime from 'animejs';
+ import { createTimeline, stagger } from 'animejs';- anime.timeline({
+ createTimeline({
- duration: 500,
- easing: 'easeInOutQuad',
+ defaults: {
+ duration: 500,
+ ease: 'inOutQuad',
+ }
- loop: 2,
+ loop: 1,
- }).add({
- targets: 'div',
+ }).add('div', {
rotate: 90,
})
- .add('.target:nth-child(1)', { opacity: 0, onComplete }, 0)
- .add('.target:nth-child(2)', { opacity: 0, onComplete }, 100)
- .add('.target:nth-child(3)', { opacity: 0, onComplete }, 200)
- .add('.target:nth-child(4)', { opacity: 0, onComplete }, 300)
+ .add('.target', { opacity: 0, onComplete }, stagger(100))
```### Stagger
```diff
- import anime from 'animejs';
+ import { animate, stagger } from 'animejs';- anime({
- targets: 'div',
+ animate('div', {
- translateX: anime.stagger(100),
+ translateX: stagger(100),
- delay: anime.stagger(100, { direction: 'reversed' }),
+ translateX: stagger(100, { reversed: true }),
});
```### SVG
```diff
- import anime from 'animejs';
+ import { animate, svg } from 'animejs';- const path = anime.path('path');
+ const { x, y, angle } = svg.createMotionPath('path');- anime({
- targets: '#shape1',
+ animate('#shape1', {
- points: '70 41 118.574 59.369 111.145 132.631 60.855 84.631 20.426 60.369',
+ points: svg.morphTo('#shape2'),
- strokeDashoffset: [anime.setDashoffset, 0],
+ strokeDashoffset: svg.drawLine(),
- translateX: path('x'),
- translateY: path('y'),
- rotate: path('angle'),
+ translateX: x,
+ translateY: y,
+ rotate: angle,
});
```### Utils
```diff
- import anime from 'animejs';
+ import { utils } from 'animejs';- const value = anime.get('#target1', 'translateX');
+ const value = utils.get('#target1', 'translateX');- anime.set('#target1', { translateX: 100 });
+ utils.set('#target1', { translateX: 100 });- anime.remove('#target1');
+ utils.remove('#target1');- const rounded = anime.round(value);
+ const rounded = utils.round(value, 0);
```### Engine
```diff
- import anime from 'animejs';
+ import { engine } from 'animejs';- anime.suspendWhenDocumentHidden = false;
+ engine.pauseWhenHidden = false;- anime.speed = .5;
+ engine.playbackRate = .5;
```