0
我有一个新的Angular 4.3动画的问题。我认为我按照https://medium.com/@gerard.sans/angular-supercharge-your-router-transitions-using-new-animation-features-v4-3-3eb341ede6c8定义了一切正常,但是在补丁更改期间,此刻我没有任何动画。下面我展示我的动画文件:Angular 4.3新的路由器动画不起作用
我的动画:
import {trigger, stagger, animate, style, group, query, transition} from '@angular/animations';
export const routerTransition = trigger('routerTransition', [
transition('* <=> *', [
/* order */
/* 1 */ query(':enter, :leave', style({ position: 'fixed', width:'100%' })
, { optional: true }),
/* 2 */ group([ // block executes in parallel
query(':enter', [
style({ transform: 'translateX(100%)' }),
animate('0.5s ease-in-out', style({ transform: 'translateX(0%)' }))
], { optional: true }),
query(':leave', [
style({ transform: 'translateX(0%)' }),
animate('0.5s ease-in-out', style({ transform: 'translateX(-100%)' }))
], { optional: true }),
])
])
]);
如果我改变了动画到另一个我看到不同的动作,但我从来没有取得良好的结果(全宽页面动画等)。我也得到这个错误,如果我删除{可选:真正}从动画代码:
core.es5.js:1020 ERROR Error: Unable to process animations due to the following failed trigger transitions
@routerTransition has failed due to:
- `query(":enter")` returned zero elements. (Use `query(":enter", { optional: true })` if you wish to allow this.)
- `query(":leave")` returned zero elements. (Use `query(":leave", { optional: true })` if you wish to allow this.)
编辑:
我无法找到一个解决方案,所以我回老版本在各子控制器的动画:
animations: [slideInOutAnimation],
host: { '[@slideInOutAnimation]': '' }
如果有人发现了一个解决方案的请求发布信息,我们怎样才能使它更容易,只在一个地方,而不是每个控制器创建动画。