I have been trying to implement an animated hamburger animation on the navbar using ng-bootstrap and Angular, but so far I have had no success. While the Navbar does collapse as expected, it lacks the animation and transformation into an 'x'. I would appreciate any help or guidance from anyone who has experience with this.
HTML
<button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#navbarGrey"
aria-controls="navbarGrey" aria-label="Toggle navigation"
(click)="isCollapsed = !isCollapsed" [attr.aria-expanded]="!isCollapsed">
<span class="icon-bar top-bar"></span>
<span class="icon-bar middle-bar"></span>
<span class="icon-bar bottom-bar"></span>
<span class="sr-only">Toggle navigation</span>
</button>
scss
// Custom Navbar styling
.navbar-toggler {
border: none;
background: transparent !important;
}
.navbar-toggler:focus {
outline: none;
background: transparent !important;
}
.navbar-toggler .icon-bar {
background-color: #fff;
transform: rotate(0deg) translate(0px, 0px);
transition: ease all .2s;
display: block;
width: 22px;
height: 2px;
border-radius: 1px;
}
.navbar-toggler .icon-bar + .icon-bar {
margin-top: 5px;
}
//Animation section <== experiencing issues here
.navbar-toggler .top-bar {
transform: rotate(45deg);
transform-origin: 10% 10%;
}
.navbar-toggler .middle-bar {
opacity: 0;
}
.navbar-toggler .bottom-bar {
transform: rotate(-45deg);
transform-origin: 10% 90%;
}
.navbar-toggler.collapsed .top-bar {
transform: rotate(0);
}
.navbar-toggler.collapsed .middle-bar {
opacity: 1;
}
.navbar-toggler.collapsed .bottom-bar {
transform: rotate(0);
}
EDIT
I have also provided a StackBlitz link for further reference and collaboration.