에 대해 이야기 :
<div style="position: relative;">
<router-outlet></router-outlet>
</div>
상대와 경로-구성 요소는 디스플레이를 가지고 각도 버전 4.3.x. router
documentation을 읽고, 경로 사이에 애니메이션을 추가하는 방법을 설명합니다. 여기에 게으른 사람들을위한 이력서 (나 자신 포함)가 있습니다.
당신은 @angular/core
(그리고 @angular/animations
)에서 애니메이션 라이브러리를 가져올 :
이
import {
AnimationEntryMetadata,
animate,
state,
style,
trigger
} from '@angular/core';
export const fadeInAnimation: AnimationEntryMetadata = trigger('fadeInAnimation', [
transition(':enter', [
style({
opacity: 0,
transform: 'translateY(20px)'
}),
animate(
'.3s',
style({
opacity: 1,
transform: 'translateY(0)'
})
)
])
]);
그런 다음 구성 요소에 구성 요소의 레이아웃 CSS 속성을 지정하기 위해 HostBinding
장식을 사용 (당신이 사용을 필요로하지 않습니다 fixed
또는 absolute
위치) :
import { Component, OnInit, HostBinding } from '@angular/core';
import { fadeInAnimation } from './../animations/fadein';
@Component({
animations: [fadeInAnimation],
selector: 'app-posts',
templateUrl: './posts.component.html'
})
export class DemandsComponent implements OnInit {
@HostBinding('@fadeInAnimation') fadeInAnimation = true;
@HostBinding('style.display') display = 'block';
@HostBinding('style.position') position = 'relative';
// Rest of the code
}
각 라우팅 구성 요소에 이러한 추가는 번거로울 수 있습니다. 문서가 제안하고 나는 다음을 인용한다.
간단한 구성으로 경로 애니메이션을 적용하는 것은 실제 데모에서는 효과가 있지만 실제 경로에서는 경로를 기반으로하는 것이 좋습니다.
마티아스 Niemelä에서이 문서 https://www.yearofmoo.com/2017/06/new-wave-of-animation-features.html#routable-animations
당신에게 이것에 대한 해결책을 찾을 수 있었 도울 수 있는가? –
다른 화면이 나타날 때 위치 절대/고정이 필요합니다.반면에 당신은 서로를 같은 코디로 덮어야합니다. 내 경우에는 배치를 깨지 않고 절대적으로 배치 된 경로를 허용하기 위해 내 웹 응용 프로그램의 CSS를 다시 작성합니다. –
오늘, 나는 또한 이것으로 고투하고있다. 우리가'position : fixed' 또는'position : absolute'를 추가해야만한다는 사실은 정말 바보 같고 전혀 똑똑하지 않습니다. Angular 팀이 그보다 낫기를 정말로 바랍니다. 다른 방법이 있어야합니다. 내 의견은 전혀 도움이되지 못합니다. 죄송합니다. 내가하기 전에 아무도 그것을하지 않으면 뭔가를 찾아 여기에 게시하려고합니다. – lkartono