Anime JS library for delay: https://animejs.com/documentation/#endDelay
Delay effect
https://animation-js-2.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 for Grid</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: '90%',
backgroundColor: 'rgb(197, 197, 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>
Comments