【发布时间】:2019-02-25 04:57:27
【问题描述】:
假设我有一个如下所示的函数。我想在与上面sidebarClode() 中显示的代码相关的所有动画都完成之后执行this.sidebarVisible = false;。有什么想法我该怎么做?
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()" >
【问题讨论】:
标签: html css angular typescript bootstrap-4