Ich habe eine Angular2 App, und ich versuche, eine Animation zu meinem Routing hinzuzufügen, so dass es gleitet, wenn ich Seiten wechseln. Die Eingabeanimation funktioniert einwandfrei, die aktivierende Animation wird jedoch nicht aktiviert. Die vorherige Seite verschwindet einfach, nachdem die neue Seite geladen wurde. Kennt jemand die Ursache dieses Problems? plunkerAngular2 - Verlassen Animation nicht anwenden
Nach der anuglar2 docs, denke ich, meine Übergänge sind korrekt.
// transition(':enter', [ ... ]); // void => *
// transition(':leave', [ ... ]); // * => void
Animationsdatei
export function routerTransition() {
return trigger('routerTransition', [
transition('void => *', [
style({ transform: 'translateX(100%)' }),
animate(1000)
]),
transition('* => void', [
style({ transform: 'translateX(-100%)' }),
animate(1000)
])
])
}
child_1.component.ts
import { Component } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Rx';
import { routerTransition } from '../../directives/router.animation';
@Component({
selector: 'about',
template: require('./about.component.html'),
styles: [require('./about.component.css')],
animations: [routerTransition()],
host: { '[@routerTransition]': '' }
})
child_2.component.ts
import { Component } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Rx';
import { routerTransition } from '../../directives/router.animation';
@Component({
selector: 'home-info',
template: require('./home.component.html'),
styles: [require('./home.component.css')],
animations: [routerTransition()],
host: { '[@routerTransition]': '' }
})
Das funktioniert, aber die 100% Breite verzerrt meine Seite. Wenn ich die Breite entferne, funktioniert die Animation wie zuvor. Irgendeine Lösung dafür? – John
Auch kann ich die Seite nicht mehr scrollen. – John
Können Sie die Breite Ihrer Seite anpassen? –