コンポーネント内のSVGをAngularでアニメーション化したいのですが、アニメーションのステップを指定するのが難しいと感じています。Angular 4、遷移とクエリでSVGをアニメーション化する
私は、次の手順アニメーション化する:円は不透明度0
2でオフスクリーン始まり)
1)円は、トップから画面に移動し、それが行くように、より不透明になり、不透明度が1に終了します
3)右に円を移動し、
オフスクリーン終わる私もそれがオフスクリーンを開始するために得ることはできませんが、私はまた、アニメーションがトリガされたときに制御することはできませんように見えます。ページが読み込まれてから1秒後にトリガーしたいと思います。
HTML:
<svg width="100" height="100">
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
</svg>
TS:
import { Component, OnInit, HostBinding } from '@angular/core';
import { style, animate, animation, animateChild, useAnimation, group, sequence, transition, state, trigger, query, stagger } from '@angular/animations';
@Component({
selector: 'app-svg-viewer',
templateUrl: './svg-viewer.component.html',
styleUrls: ['./svg-viewer.component.css'],
animations: [
trigger('myAwesomeAnimation', [
transition(':enter', group([
query('circle', stagger('0ms', [
animate('200ms 250ms ease-in', style({ opacity: 0, transform: 'translateY(-400%)' }))
])),
])),
])
],
})
export class SvgViewerComponent implements OnInit {
@HostBinding('@myAwesomeAnimation')
public animateProfile = true;
constructor() { }
ngOnInit() {
}
}
私のdevの環境はapp.module.tsに以下の追加でビルド、標準角度-CLIです:
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
app.module.ts内の@NgModule内:
BrowserModule,
BrowserAnimationsModule,
https://blog.thoughtram.io/angular/2017/07/26/a-web-animations-deep-dive-with-angular.html – JGFMK
私はそれを試してみましたが、私は変更しようとしました私のsvgを含めるように恥ずかしがり屋 - それは動作していないようです – Davtho1983
あなたがそれをリンクすることができるように塊をフォークしないと仮定しないでください... – JGFMK