我有一个动画,它在 stackblizt ( https://stackblitz.com/edit/burger?file=app%2Fburger%2Fburger.component.ts ) 以及在本地运行良好ng serve --aot
,但它似乎直接跳到生产构建的最终状态 ( ng build --prod
) http://burger.fxck.cz/
你能停止代码中可能导致它的东西吗?
import {
trigger,
state,
style,
animate,
transition
} from '@angular/animations';
export const EASING = 'cubic-bezier(0.5, 0.5, 0.76, 0.76)';
export function burgerLineAnimation(name: string, translateY = '15px', rotateFinal = '45deg', rotateOver = '65deg') {
return trigger(name, [
// opened state, in center, rotated, expanded
state('true', style({
transform: `translateY(${translateY}) translateX(17.5px) rotate(${rotateFinal})`,
width: '40px'
})),
transition('false => true', [
// move to center
animate(`100ms ${EASING}`, style({
transform: `translateY(${translateY})`
})),
// expand from dot to line
animate(`100ms ${EASING}`, style({
width: '40px',
transform: `translateY(${translateY}) translateX(17.5px)`
})),
// rotate over
animate(`80ms ${EASING}`, style({
transform: `translateY(${translateY}) translateX(17.5px) rotate(${rotateOver})`
})),
// rotate final
animate(`150ms ${EASING}`, style({
transform: `translateY(${translateY}) translateX(17.5px) rotate(${rotateFinal})`
}))
]),
transition('true => false', [
// level and shrink
animate(`100ms ${EASING}`, style({
transform: `translateY(${translateY}) translateX(0) rotate(0deg)`,
width: '5px'
})),
// move to proper position
animate(`100ms ${EASING}`, style({
transform: 'translateY(0)'
}))
])
]);
}
在组件装饰器中这样使用
animations: [
burgerLineAnimation('firstLine'),
burgerLineAnimation('thirdLine', '-15px', '-45deg', '-60deg')
]