Finally I created a JS file called index.js, although the name chosen is not relevant to get it to work. In this file I added my animation code for my test I created this simple animation:
document.addEventListener("DOMContentLoaded", () => {
// pull out the animate function from the global `anime`
const { animate } = anime;
// selector first, options second:
animate('.anime-box', {
translateX: 250,
duration: 2000,
alternate: true,
ease: 'inOutQuad',
loop: true
});
});
Finally I tested this and my animation worked!
Your Setup
First follow the steps in my demo example on how to import the correct JS file for Anime.js
Create your Divs
Add your CSS styles and then for the animations replace your animation.js file with the following:
document.addEventListener("DOMContentLoaded", () => {
// pull out the animate function from the global `anime`
const { animate } = anime;
// selector first, options second:
animate('.square', {
translateX: '23rem',
rotate: 90,
loop: true,
duration: 4000,
easing: 'inOutExpo',
});
animate(['.blue', '.green'], {
translateX: '13rem',
rotate: 90,
borderRadius: '8px',
duration: 2000,
loop: true
});
});
Your animations should now run, I setup some of my own styles just to test and got this result: