[英]How to add animation to NGX-Bootstrap Dropdown
I have created a dropdown using ngx bootstrap.我使用 ngx bootstrap 创建了一个下拉列表。 In the dropdown I want to add a custom animation.
在下拉列表中,我想添加一个自定义动画。 I have created a animation using angular's animation library and added it in the dropdown.
我使用 angular 的动画库创建了一个动画并将其添加到下拉列表中。 But it is not working.
但它不起作用。
Question - how I can add the custom animation in the bootstrap dropdown?问题 -如何在引导程序下拉列表中添加自定义动画?
This is what i have done -这就是我所做的 -
Component HTML -组件 HTML -
<div class="btn-group" dropdown>
<button id="button-basic" dropdownToggle type="button" class="btn btn-primary dropdown-toggle" aria-
controls="dropdown-basic">
Button dropdown <span class="caret"></span>
</button>
<ul id="dropdown-basic" *dropdownMenu class="dropdown-menu" role="menu" aria-labelledby="button-basic"
[@dropdownAnimation]>
<li role="menuitem"><a class="dropdown-item" href="#">Action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</div>
Component ts -组件 ts -
animations: [
trigger("dropdownAnimation", [
transition(":enter", [
style({
transform: "translate(0, -40px)",
opacity: 0,
visibility: "hidden",
}),
animate(
"400ms ease-in-out",
style({ transform: "translate(0, 0)", opacity: 1, visibility: "visible" })
),
]),
transition(":leave", [
style({ transform: "translate(0, 0)", opacity: 1, visibility: "visible" }),
animate(
"400ms ease-in-out",
style({
transform: "translate(0, -40px)",
opacity: 0,
visibility: "hidden",
})
),
]),
])
]
Add BsDropdownModule
to app.module.ts
将
BsDropdownModule
添加到app.module.ts
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
@NgModule({
imports: [BsDropdownModule.forRoot(),...]
})
export class AppModule(){}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.