Ste*_*tes 23 typescript angular2-animation angular
我试图触发绑定到布尔属性的转换,但这似乎没有触发.
这是我的动画触发器的缩减版本
trigger(
'trueFalseAnimation', [
transition('* => true', [
style({backgroundColor: '#00f7ad'}),
animate('2500ms', style({backgroundColor: '#fff'}))
]),
transition('* => false', [
style({backgroundColor: '#ff0000'}),
animate('2500ms', style({backgroundColor: '#fff'}))
])
]
)
Run Code Online (Sandbox Code Playgroud)
HTML:
<div [@trueFalseAnimation]="model.someProperty">Content here</div>
Run Code Online (Sandbox Code Playgroud)
去测试:
ngOnInit() {
setTimeout(() => {
this.model.someProperty = true;
setTimeOut(() => {
this.model.someProperty = false;
}, 5000);
}, 1000)
}
Run Code Online (Sandbox Code Playgroud)
someProperty更改时,触发器永远不会发生.
作为一个快速测试我更改了触发器以使用字符串,它的工作原理
trigger(
'trueFalseAnimation', [
transition('* => Success', [
style({backgroundColor: '#00f7ad'}),
animate('2500ms', style({backgroundColor: '#fff'}))
]),
transition('* => Failed', [
style({backgroundColor: '#ff0000'}),
animate('2500ms', style({backgroundColor: '#fff'}))
])
]
)
Run Code Online (Sandbox Code Playgroud)
去测试:
ngOnInit() {
setTimeout(() => {
this.model.someProperty = "Success";
setTimeOut(() => {
this.model.someProperty = "Failed";
}, 5000);
}, 1000)
}
Run Code Online (Sandbox Code Playgroud)
第二个例子很好用
我的问题是
小智 26
trigger('isVisibleChanged', [
state('true' , style({ opacity: 1, transform: 'scale(1.0)' })),
state('false', style({ opacity: 0, transform: 'scale(0.0)' })),
transition('1 => 0', animate('300ms')),
transition('0 => 1', animate('900ms'))
])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9314 次 |
| 最近记录: |