top of page
  • Writer's pictureSon Luu

Anime js 3 - Delay

Updated: Mar 3, 2021

https://animation-animejs-3.glitch.me/




<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

<link rel="stylesheet" href="style.css">

</head>

<body>


<h1>deSign</h1>

<section>

<div></div>

<div></div>

<div></div>

<div></div>

<div></div>

<div></div>

<div></div>

<div></div>

<div></div>


</section>


<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha512-z4OUqw38qNLpn1libAN9BsoDx6nbNFio5lA6CuTp9NlK83b89hgyCVq+N5FdBJptINztxn1Z3SaKSKUS5UP60Q==" crossorigin="anonymous"></script>



<script>

let tl = anime.timeline({

easing: 'easeOutExpo',

duration: 750

})


tl.add ({

targets: 'section div',

width: '100%',

backgroundColor: 'rgb(235, 181, 156)',

delay: anime.stagger(100)

})


tl.add ({

targets: 'section div',

width: '90%',

backgroundColor: 'rgb(249, 232, 219)',

// delay: anime.stagger(100)

})


tl.add ({

targets: 'h1',

width: '20%',

opacity: 1,

duration: 4000,

// backgroundColor: 'rgb(235, 235, 255)',

// delay: anime.stagger(100)

})


// let grids = document.querySelectorAll('div');


// let num = 0;


// const delay = time => new Promise(resolve => setTimeout(resolve, time));


// grids.forEach(grid => {

// delay(0).then(() => {

// setTimeout(() => {

// grid.style.backgroundColor = 'lightblue';

// }, num += 100);

// });

// delay(500).then(() => {

// setTimeout(() => {

// grid.style.backgroundColor = 'rgb(228, 242, 255)';

// grid.style.width = '90%'

// }, num += 100);

// })

// })


</script>

</body>

</html>


bottom of page