我写了 plunk 来说明我的问题:LINK
我需要为父组件制作动画,同时我想在子组件中制作一些动画。似乎角度正在阻止子组件上的动画,然后在父动画结束后简单地跳转状态而没有任何过渡。
有没有办法让动画并行工作,或者至少在不使用回调的情况下进行链接?
@Component({
selector: 'outer',
template: `
<div [@state]="state" (mouseenter)="state='wide'" (mouseleave)="state='narrow'" style="background-color: red;">
<inner [stateInner]="state"></inner>
</div>`,
animations:[
trigger('state', [
state('narrow', style({
width: '100px'
})),
state('wide', style({
width: '400px'
})),
transition('* => *', animate('500ms'))
])
]
})
export class Outer {
public state: string = 'narrow';
constructor() {
}
}
@Component({
selector: 'inner',
template: `
<div [@stateInner]="stateInner">
<h2>Hello</h2>
</div>`,
animations:[
trigger('stateInner', [
state('narrow', style({
height: '100px'
})),
state('wide', style({
height: '400px'
})),
transition('* => *', animate('500ms'))
])
]
})
export class Inner {
@Input() stateInner: string = 'narrow';
constructor() {
}
}