在 Angular2 应用程序中,我正在尝试制作动画
这是组件的html:
<div [@playBox]="state" id="toPlay" class="playBox rounded-box">
</div>
这是动画:
animations:[
trigger('playBox',[
state('closed',style({
width: '5%',
backgroundColor:'red',
transform:'translateX(0)'
})),
state('wided',style({
width: '100%',
border: '3px solid red',
backgroundColor:'transparent'
})),transition('closed => wided',animate(4000))])
]
我将在页面加载时触发此动画:
export class AppComponent implements OnInit{
state="closed";
public ngOnInit(): any
{
if(this.state=="closed"){
this.state="wided";
}
}