I'm trying to build a simple navbar but I'm having some issues with the way the animation looks and I was wondering if you could give me a hand
I have a Codepen of the issue here: https://codepen.io/anon/pen/oqYwgP
HTML
<nav>
<div class="menu-icon">
menu button
</div>
<div class="menu">
<ul>
<li><a href="#">menu1</a></li>
<li><a href="#">menu2</a></li>
<li><a href="#">menu3</a></li>
</ul>
</div>
</nav>
CSS
nav ul {
list-style: none;
overflow: hidden;
color: #fff;
padding-right: 40px;
text-align:center;
height:0px;
width:60px;
background:gray;
transition: 1s all;
}
.menu-icon {
width:140px;
border:1px solid gray;
}
.change-menu-icon{
background:gray;
transition: all 1s;
}
.change-menu{
height: 180px;
}
JS
$(document).ready(function() {
$(".menu-icon").on("click", function() {
$("nav ul").toggleClass("change-menu");
$(".menu-icon").toggleClass("change-menu-icon");
});
});
I would like to when I press the menu button for the background color to change and then for the menu to resize, and when I toggle the button again for animation to be reverse, for the resize to happen first and then the menu button background color change.
setTimeOut()or promises.