2018-08-29 13:21:25 +02:00
|
|
|
import { trigger, animate, transition, style, query, stagger, group } from '@angular/animations';
|
2018-07-31 15:46:55 +02:00
|
|
|
|
2018-10-05 16:34:08 +02:00
|
|
|
const fadeVanish = [
|
|
|
|
style({ transform: 'translateY(0%)', opacity: 1 }),
|
|
|
|
animate(
|
2019-06-14 15:19:52 +02:00
|
|
|
'150ms ease-in-out',
|
2018-10-05 16:34:08 +02:00
|
|
|
style({
|
|
|
|
transform: 'translateY(0%)',
|
|
|
|
opacity: 0
|
|
|
|
})
|
|
|
|
)
|
|
|
|
];
|
|
|
|
|
2019-06-14 15:19:52 +02:00
|
|
|
// Requires more generic way to trigger parallel animations
|
|
|
|
// const fadeAppear = [
|
|
|
|
// style({ transform: 'translateY(0%)', opacity: 0 }),
|
|
|
|
// animate('200ms ease-in-out', style({ transform: 'translateY(0%)', opacity: 1 }))
|
|
|
|
// ];
|
2018-10-05 16:34:08 +02:00
|
|
|
|
|
|
|
const justEnterDom = [style({ opacity: 0 })];
|
|
|
|
|
|
|
|
const fadeMoveIn = [
|
|
|
|
style({ transform: 'translateY(30px)' }),
|
2019-06-14 15:19:52 +02:00
|
|
|
animate('150ms ease-in-out', style({ transform: 'translateY(0px)', opacity: 1 }))
|
2018-10-05 16:34:08 +02:00
|
|
|
];
|
|
|
|
|
2018-07-31 15:46:55 +02:00
|
|
|
export const pageTransition = trigger('pageTransition', [
|
|
|
|
transition('* => *', [
|
2018-09-04 11:35:50 +02:00
|
|
|
/** this will avoid the dom-copy-effect */
|
|
|
|
query(':enter, :leave', style({ position: 'absolute', width: '100%' }), { optional: true }),
|
2018-10-05 16:34:08 +02:00
|
|
|
|
2018-07-31 15:46:55 +02:00
|
|
|
/** keep the dom clean - let all items "just" enter */
|
2018-10-05 16:34:08 +02:00
|
|
|
query(':enter mat-card', justEnterDom, { optional: true }),
|
|
|
|
query(':enter mat-row', justEnterDom, { optional: true }),
|
2018-07-31 15:46:55 +02:00
|
|
|
|
|
|
|
/** parallel vanishing */
|
|
|
|
group([
|
2018-10-05 16:34:08 +02:00
|
|
|
query(':leave mat-card', fadeVanish, { optional: true }),
|
2019-06-14 15:19:52 +02:00
|
|
|
query(':leave mat-row', fadeVanish, { optional: true })
|
2018-07-31 15:46:55 +02:00
|
|
|
]),
|
|
|
|
|
|
|
|
/** parallel appearing */
|
|
|
|
group([
|
2018-10-05 16:34:08 +02:00
|
|
|
/** Staggered appearing = "one after another" */
|
|
|
|
query(':enter mat-card', stagger(50, fadeMoveIn), { optional: true }),
|
|
|
|
query(':enter mat-row', stagger(30, fadeMoveIn), { optional: true })
|
2018-07-31 15:46:55 +02:00
|
|
|
])
|
|
|
|
])
|
|
|
|
]);
|
|
|
|
|
2018-10-05 16:34:08 +02:00
|
|
|
const slideIn = [style({ transform: 'translateX(-85%)' }), animate('600ms ease')];
|
|
|
|
const slideOut = [
|
|
|
|
style({ transform: 'translateX(0)' }),
|
|
|
|
animate(
|
|
|
|
'600ms ease',
|
|
|
|
style({
|
|
|
|
transform: 'translateX(-85%)'
|
|
|
|
})
|
|
|
|
)
|
|
|
|
];
|
|
|
|
|
|
|
|
export const navItemAnim = trigger('navItemAnim', [transition(':enter', slideIn), transition(':leave', slideOut)]);
|