I have two box. I want to fadeoutLeft my first box when user click on button.
But I have one more condition. I want to show box2 when box1 is 75% fadeout or In other words I want a callback function which tell box1 fadeout 75% done.
Is this possible ?
Currently I am doing like this
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Template</title>
<style>
@keyframes fadeOutLeft {
from {
opacity: 1;
}
to {
opacity: 0;
transform: translate3d(-10%, 0, 0);
}
}
.box {
width: 200px;
height: 200px;
}
.box1 {
background-color: #aff;
}
.box2 {
background-color: #eac;
opacity: 0;
}
.fadeOutLeft {
animation-name: fadeOutLeft;
animation-duration: 10000ms;
}
</style>
</head>
<body>
<div class="box box1"></div>
<div class="box box2"></div>
<button id="abc">Start Animation</button>
<script>
document.getElementById("abc").addEventListener("click", function () {
document.querySelector(".box1").classList.add("fadeOutLeft");
});
</script>
</body>
</html>
here is my code https://codesandbox.io/s/cranky-resonance-5ddzt?file=/index.html:0-1077
using CSS I am not able to get when callback function when it done 75%