hey everyone I am building a hamburger menu and when I toggle the menu I want to add/remove a certain css property a existing class. Here's my code
burger.component.html
<div class="top-nav--hamburger--container" (click)="handleHamburger()">
<div class="hamburger-bar--top"></div>
<div class="hamburger-bar--bot"></div>
</div>
And my css looks like this
.hamburger-bar--top
width: 30px
height: 5px
background: red
border-radius: 100px
transition: transform 50ms ease-out
// transform: rotate(45deg) translateY(5px) translateX(5px)
.hamburger-bar--bot
margin-top: 8px
width: 30px
height: 5px
background: red
border-radius: 100px
transition: transform 50ms ease-out
// transform: rotate(-45deg) translateY(-5px) translateX(4px)
I want to add those transform properties to the existing class on click and remove them if already applied.
burger.component.ts
showStyle: boolean = false;
constructor() { }
handleHamburger(){
this.showStyle = !this.showStyle;
...Add the properties to the class
...Can not figure this part out
}
So on click I would like to add the transform properties on the class. I am not sure how to do this. Any help or idea would be great. Thanks