【发布时间】:2017-09-09 22:48:14
【问题描述】:
我正在尝试使用 Angular 4.1.2 使用伪 :enter、:leave 状态更改表达式(使用 3D CSS 表达式)为路由器转换设置动画。
阅读angular.io 文档,其中描述了void => * 和* => void 用于:enter 和:leave 伪转换。
在尝试从this post 转换slide in out 之后,我最终可以通过在我的组件css 文件中设置:host {postion:relative} 来让它工作(应该让作者知道)。
这行得通:
trigger('routerAnimation', [
transition(':enter', [
style({ right: '-400%' }),
animate('.2s ease-in-out', style({ right: 0 }))
]),
transition(':leave', [
animate('.2s ease-in-out', style({ right: '-400%' }))
])
]);
这没有:
trigger('routerAnimation', [
transition(':enter', [
style({ transform: 'translateZ(-400px)' }),
animate('.2s ease-in-out', style({ transform: 'translateZ(0)' }))
]),
transition(':leave', [
style({ transform: 'translateZ(0)' }),
animate('.2s ease-in-out', style({ transform: 'translateZ(-400px)' }))
])
]);
我真的很困惑为什么会发生这种情况,我还尝试将我的 :host 定位从 relative 设置为 absolute 以确保我没有犯 CSS 错误。
任何帮助都会是超级超级棒:)
【问题讨论】:
标签: html css angular angular-animations