Yuv*_*als 17 angular angular-animations
我正在尝试使用Angular2动画系统,用于伪元素:before
.根据动画流程,我需要定义动画状态:
animations: [
trigger('heroState', [
state('inactive', style({
backgroundColor: '#eee',
transform: 'scale(1)'
})),
state('active', style({
backgroundColor: '#cfd8dc',
transform: 'scale(1.1)'
})),
transition('inactive => active', animate('100ms ease-in')),
transition('active => inactive', animate('100ms ease-out'))
])]
Run Code Online (Sandbox Code Playgroud)
然后将其附加到DOM元素,如下所示:
<ul>
<li *ngFor="let hero of heroes"
[@heroState]="hero.state"
(click)="hero.toggleState()">
{{hero.name}}
</li>
Run Code Online (Sandbox Code Playgroud)
但是,我想将其附加到伪before
元素.我怎样才能做到这一点?
请尝试一下,这将是您想要的。
<style>
h1::before {
content: url(animation.html);
}
</style>
Run Code Online (Sandbox Code Playgroud)
动画.html 文件
<ul>
<li *ngFor="let hero of heroes"
[@heroState]="hero.state"
(click)="hero.toggleState()">
{{hero.name}}
</li>
Run Code Online (Sandbox Code Playgroud)
希望这对你有用。
归档时间: |
|
查看次数: |
764 次 |
最近记录: |