Tap on the flower to reveal the menu. I have successfully implemented the animation for "process" fading in after the menu opens. However, I am struggling to reverse the animation when collapsing the menu. I want "process" to fade out before the menu closes again. Can anyone provide assistance with this?
function toggleClass() {
var spin = document.getElementById("nav");
spin.classList.toggle('in');
spin.classList.toggle('out');
}
const delay = ms => new Promise(res => setTimeout(res, ms));
const fadeInAnimation = async () => {
var element1 = document.getElementById("text1");
var element2 = document.getElementById("text2");
var element3 = document.getElementById("text3");
await delay(300);
element1.classList.toggle("show");
element2.classList.toggle("show");
element3.classList.toggle("show");
}
document.querySelector('#nav').addEventListener('click', fadeInAnimation);
:root{
--seconds: 5s;
--fast: 2s;
}
nav{
position: fixed;
display: flex;
justify-content: space-between;
align-items: center;
z-index: 10px;
padding-top: 20px;
width: 100%;
}
nav img{
width: 50px;
}
/* INN OUT */
#nav{
height: auto;
display: flex;
align-items: center;
justify-content: flex-start;
border-radius: 50px;
padding: 10px;
background-color: white;
margin-right: 20px;
/*drop shadow*/
-webkit-box-shadow: 0px 10px 30px 0px rgba(0,0,0,0.10);
-moz-box-shadow: 0px 10px 30px 0px rgba(0,0,0,0.10);
box-shadow: 0px 10px 30px 0px rgba(0,0,0,0.10);
}
.in {
width: 50px;
}
.out {
width: 400px;
}
.transition{
-webkit-transition: all 0.2s ease-in-out;
-moz-transition:all 0.2s ease-in-out;
-o-transition:all 0.2s ease-in-out;
transition::all 0.2s ease-in-out;
}
#navtext{
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-around;
}
.style{
display: flex;
background-color: white;
justify-content: center;
align-items: center;
padding: 10px 15px 10px 15px;
border-radius: 40px;
color: lightgrey;
transition: 0.1s;
}
#text{
display: none;
}
.noshow{
display: none;
}
.show{
display: flex;
}
.show:hover{
color: black;
background-color: lightgrey
}
<nav>
<div id="nav" class="in transition">
<img id="spin" src="https://i.dlpng.com/static/png/762080_preview_preview.png" class="rotating spin" onclick="toggleClass()">
<div id="navtext">
<a id="text1" class="noshow style">Process</a>
<a id="text2" class="noshow style">Process</a>
<a id="text3" class="noshow style">Process</a>
</div>
</div>
</nav>