mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 12:35:07 +00:00
Fuck.n router animation..
This commit is contained in:
parent
b8d5c16237
commit
d70ad0d3c7
|
@ -1,4 +1,6 @@
|
||||||
import { trigger, state, transition, animate, style } from '@angular/animations';
|
import { sequence, trigger, stagger, animate, style, group, query as q, transition, keyframes, animateChild, state } from '@angular/animations';
|
||||||
|
|
||||||
|
const query = (s, a, o = {optional: true}) => q(s, a, o);
|
||||||
|
|
||||||
export class Animations
|
export class Animations
|
||||||
{
|
{
|
||||||
|
@ -55,10 +57,11 @@ export class Animations
|
||||||
]);
|
]);
|
||||||
|
|
||||||
public static slideInBottom = trigger('slideInBottom', [
|
public static slideInBottom = trigger('slideInBottom', [
|
||||||
state('void', style({
|
state('void',
|
||||||
transform: 'translateY(100%)',
|
style({
|
||||||
display : 'none'
|
transform: 'translateY(100%)',
|
||||||
})),
|
display : 'none'
|
||||||
|
})),
|
||||||
state('*', style({
|
state('*', style({
|
||||||
transform: 'translateY(0)',
|
transform: 'translateY(0)',
|
||||||
display : 'flex'
|
display : 'flex'
|
||||||
|
@ -66,4 +69,43 @@ export class Animations
|
||||||
transition('void => *', animate('300ms')),
|
transition('void => *', animate('300ms')),
|
||||||
transition('* => void', animate('300ms'))
|
transition('* => void', animate('300ms'))
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
public static routerTransition = trigger('routerTransition', [
|
||||||
|
|
||||||
|
transition('* => *', [
|
||||||
|
query(':enter, :leave', style({
|
||||||
|
position: 'absolute',
|
||||||
|
height : '100vh'
|
||||||
|
})),
|
||||||
|
query(':enter', style({
|
||||||
|
transform: 'translateY(100%)',
|
||||||
|
opacity : 0
|
||||||
|
})),
|
||||||
|
sequence([
|
||||||
|
group([
|
||||||
|
query(':leave', [
|
||||||
|
style({
|
||||||
|
transform: 'translateY(0)',
|
||||||
|
opacity : 1
|
||||||
|
}),
|
||||||
|
animate('400ms cubic-bezier(0.250, 0.460, 0.450, 0.940)',
|
||||||
|
style({
|
||||||
|
transform: 'translateY(-100%)',
|
||||||
|
opacity : 0
|
||||||
|
}))
|
||||||
|
]),
|
||||||
|
query(':enter', [
|
||||||
|
style({transform: 'translateY(100%)'}),
|
||||||
|
animate('400ms cubic-bezier(0.250, 0.460, 0.450, 0.940)',
|
||||||
|
style({
|
||||||
|
transform: 'translateY(0%)',
|
||||||
|
opacity : 1
|
||||||
|
}))
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
query(':leave', animateChild()),
|
||||||
|
query(':enter', animateChild())
|
||||||
|
])
|
||||||
|
])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,30 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, HostBinding, OnInit } from '@angular/core';
|
||||||
import { PerfectScrollbarDirective } from 'ngx-perfect-scrollbar';
|
import { PerfectScrollbarDirective } from 'ngx-perfect-scrollbar';
|
||||||
import { NavigationEnd, Router } from '@angular/router';
|
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
||||||
|
import { Animations } from '../../core/animations';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector : 'fuse-content',
|
selector : 'fuse-content',
|
||||||
templateUrl: './content.component.html',
|
templateUrl: './content.component.html',
|
||||||
styleUrls : ['./content.component.scss']
|
styleUrls : ['./content.component.scss'],
|
||||||
|
animations : [Animations.routerTransition]
|
||||||
})
|
})
|
||||||
export class FuseContentComponent implements OnInit
|
export class FuseContentComponent implements OnInit
|
||||||
{
|
{
|
||||||
|
@HostBinding('@routerTransition') routeAnimationState = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
|
private activatedRoute: ActivatedRoute,
|
||||||
private perfectScrollbarDirective: PerfectScrollbarDirective
|
private perfectScrollbarDirective: PerfectScrollbarDirective
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
this.router.events
|
||||||
|
.filter((event) => event instanceof NavigationEnd)
|
||||||
|
.map(() => this.activatedRoute)
|
||||||
|
.subscribe((event) => {
|
||||||
|
this.routeAnimationState = !this.routeAnimationState;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit()
|
ngOnInit()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user