<div class="container">
<div class="square"></div>
<div class="circle"></div>
<button class="animButton">Click to animate</button>
</div>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
width: 100%;
height: 100vh;
}
.square {
width: 100px;
height: 100px;
background-color: blue;
}
.circle {
border-radius: 9999px;
width: 100px;
height: 100px;
background-color: red;
}
const animButton = document.querySelector(".animButton")
animButton.addEventListener("click", animateOnClick)
function animateOnClick(){
gsap.to(".square", { duration: 1, x: 200})
gsap.to(".circle", { duration: 1, x: 200, delay: 1})
}
This Pen doesn't use any external CSS resources.