If we consider a scenario where there is a function as illustrated below. The intention is to execute this.sidebarVisible = false;
only after all the animations related to the code mentioned in sidebarClose()
are completed. Any suggestions on how this can be achieved?
ts:
sidebarOpen() {
const toggleButton = this.toggleButton;
const html = document.getElementsByTagName('html')[0];
setTimeout(function () {
toggleButton.classList.add('toggled');
}, 500);
html.classList.add('nav-open');
this.sidebarVisible = true;
};
sidebarClose() {
const html = document.getElementsByTagName('html')[0];
this.toggleButton.classList.remove('toggled');
html.classList.remove('nav-open');
this.sidebarVisible = false; // I want to execute this line of code after all the animations associated with the code shown above in sidebarClode() will be done. I mean three lines of code above this comment.
};
sidebarToggle() {
if (this.sidebarVisible === false) {
this.sidebarOpen();
} else {
this.sidebarClose();
}
};
html:
<button style="right: 1vw;" class="navbar-toggler navbar-burger" type="button" data-toggle="collapse" data-target="#navbarToggler"
aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation"
(click)="sidebarToggle()" (transitionend)="this.printText()" >