Angular 5 parent and child animations not working at the same time

我的梦境 提交于 2019-12-22 09:58:12

问题


I'm trying to create side menu with additional animation for inner arrow element:

https://stackblitz.com/edit/angular5-menu-animation

In this realization animations are working in the next order:

  1. Menu is opening
  2. Arrow is rotating

But I want to start this 2 animations at the same time. It works good in Angular 4.4.x but not working in 5.2.x.

Need some help with this issue.


回答1:


You can check my working fork here.

You have to add the group function so that the steps are executed in parallel instead of in sequence as sequence is taken by default.

 import { group } from '@angular/animations';

 transition('in <=> out', [
    group([
      query('@buttonInOut', [
        animateChild()
      ]),
      animate('300ms ease-out')
    ])
  ])

If you check the docs on sequence, it is said that;

sequence Specifies a list of animation steps that are run one by one. (sequence is used by default when an array is passed as animation data into transition.)

The sequence function can either be used within a group or a transition and it will only continue to the next instruction once each of the inner animation steps have completed.

To perform animation styling in parallel with other animation steps then have a look at the group animation function.



来源:https://stackoverflow.com/questions/50156300/angular-5-parent-and-child-animations-not-working-at-the-same-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!