anime.js

3.1.0 · active · verified Sun Apr 19

anime.js (pronounced /'æn.ə.meɪ/) is a lightweight, general-purpose JavaScript animation library designed to work across a wide range of web technologies. It provides a simple yet powerful API for animating CSS properties, SVG, DOM attributes, and JavaScript Objects. The library is currently in its v4 major release, with the latest stable version being 4.3.6. It is actively maintained with frequent bug fixes and feature additions, as evidenced by recent patch releases. Key differentiators include its focus on performance, an ESM-first API for better tree-shaking, robust timeline capabilities, and a comprehensive set of easing functions. It's often chosen for its ease of use compared to more complex alternatives, making it suitable for both simple UI effects and more intricate motion design tasks.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart animates multiple DOM elements, demonstrating translation, rotation, background color, scaling, staggered delays, looping, and alternating direction, using the v4 API.

import { animate } from 'animejs';

const targets = document.querySelectorAll('.my-element');

if (targets.length > 0) {
  animate(targets, {
    translateX: 250,
    rotate: '1turn',
    backgroundColor: '#FF0000',
    scale: [1, 1.2, 1],
    duration: 800,
    delay: (el, i) => 100 * i,
    easing: 'easeOutQuad',
    loop: true,
    direction: 'alternate'
  });
} else {
  console.warn('No elements found with class .my-element. Please add some div elements to the HTML.');
}

// Example for HTML structure:
// <div class="my-element"></div>
// <div class="my-element"></div>
// <div class="my-element"></div>

view raw JSON →