5

ルート遷移をしたいのですが、単純なスライドアウト/スライドインのアニメーションではありません。左のようなアニメーションを探しています ( https://cdn.dribbble.com/users/495792/screenshots/3847874/allshots3.gif )

コンテンツ全体を再描画するルートをアニメーション化する方法を知っています。しかし、ルートを変更して、1 つまたは複数のコンポーネントを別のコンポーネントに移行する効果 (左側のこの拡大 / ズーム効果) をどのように達成できますか。

いくつかのサンプルコードを探すためのアドバイスや指示をいただければ幸いです。

4

1 に答える 1

1

Routable Animations を読む必要があります。Matias Niemelä (@angular/animations の責任者) によるこのブログ投稿をチェックしてください。

アニメーション機能の新しい波

TL;DR:

<!-- app.html -->
<div [@routeAnimation]="prepRouteState(routerOutlet)">
    <!-- make sure to keep the ="outlet" part -->
  <router-outlet #routerOutlet="outlet"></router-outlet>
<div>


// app.ts
@Component({
  animations: [
    trigger('routeAnimation', [
      // no need to animate anything on load
      transition(':enter', []),
      // but anytime a route changes let's animate!
      transition('homePage => supportPage', [
        // ... some awesome animation here
      ]),
      // and when we go back home
      transition('supportPage => homePage', [
        // ... some awesome animation here
      ])
    ])
  ] 
})
class AppComponent {
  prepRouteState(outlet: any) {
    return outlet.activatedRouteData['animation'] || 'firstPage'; 
  }
}

<!-- app-routing.module.ts -->
const ROUTES = [
  { path: '',
    component: HomePageComponent,
    data: {
      animation: 'homePage'
    }
  },
  { path: 'support',
    component: SupportPageComponent,
    data: {
      animation: 'supportPage'
    }
  }
]
于 2018-03-23T00:47:18.607 に答える