fuse-angular/src/app/core/animations.ts

309 lines
11 KiB
TypeScript
Raw Normal View History

2017-09-20 07:06:28 +00:00
import { sequence, trigger, animate, style, group, query, transition, animateChild, state } from '@angular/animations';
export class Animations
{
public static fadeInOut = trigger('fadeInOut', [
state('0', style({
display: 'none',
opacity: 0
})),
state('1', style({
display: 'block',
opacity: 1
})),
transition('1 => 0', animate('300ms ease-out')),
transition('0 => 1', animate('300ms ease-in'))
]);
public static slideInOut = trigger('slideInOut', [
2017-08-02 16:51:02 +00:00
state('0', style({
height : '0px',
display: 'none'
})),
state('1', style({
height : '*',
display: 'block'
})),
transition('1 => 0', animate('300ms ease-out')),
transition('0 => 1', animate('300ms ease-in'))
]);
2017-08-02 16:51:02 +00:00
public static slideInLeft = trigger('slideInLeft', [
2017-08-02 16:51:02 +00:00
state('void', style({
transform: 'translateX(-100%)',
display : 'none'
})),
state('*', style({
transform: 'translateX(0)',
display : 'flex'
})),
transition('void => *', animate('300ms')),
transition('* => void', animate('300ms'))
]);
2017-08-02 16:51:02 +00:00
public static slideInRight = trigger('slideInRight', [
2017-08-02 16:51:02 +00:00
state('void', style({
transform: 'translateX(100%)',
display : 'none'
})),
state('*', style({
transform: 'translateX(0)',
display : 'flex'
})),
transition('void => *', animate('300ms')),
transition('* => void', animate('300ms'))
]);
public static slideInTop = trigger('slideInTop', [
state('void', style({
transform: 'translateY(-100%)',
display : 'none'
})),
state('*', style({
transform: 'translateY(0)',
display : 'flex'
})),
transition('void => *', animate('300ms')),
transition('* => void', animate('300ms'))
]);
public static slideInBottom = trigger('slideInBottom', [
2017-08-19 13:20:09 +00:00
state('void',
style({
transform: 'translateY(100%)',
display : 'none'
})),
2017-08-02 16:51:02 +00:00
state('*', style({
transform: 'translateY(0)',
display : 'flex'
})),
transition('void => *', animate('300ms')),
transition('* => void', animate('300ms'))
]);
2017-08-19 13:20:09 +00:00
public static routerTransitionLeft = trigger('routerTransitionLeft', [
2017-08-19 13:20:09 +00:00
transition('* => *', [
query('fuse-content > :enter, fuse-content > :leave', [
style({
position: 'absolute',
top : 0,
bottom : 0,
left : 0,
right : 0
})
], {optional: true}),
query('fuse-content > :enter', [
style({
transform: 'translateX(100%)',
opacity : 0
})
], {optional: true}),
2017-08-19 13:20:09 +00:00
sequence([
group([
query('fuse-content > :leave', [
style({
transform: 'translateX(0)',
opacity : 1
}),
animate('400ms cubic-bezier(0.250, 0.460, 0.450, 0.940)',
style({
transform: 'translateX(-100%)',
opacity : 0
}))
], {optional: true}),
query('fuse-content > :enter', [
style({transform: 'translateX(100%)'}),
animate('400ms cubic-bezier(0.250, 0.460, 0.450, 0.940)',
style({
transform: 'translateX(0%)',
opacity : 1
}))
], {optional: true})
]),
query('fuse-content > :leave', animateChild(), {optional: true}),
query('fuse-content > :enter', animateChild(), {optional: true})
])
])
]);
public static routerTransitionRight = trigger('routerTransitionRight', [
transition('* => *', [
query('fuse-content > :enter, fuse-content > :leave', [
style({
position: 'absolute',
top : 0,
bottom : 0,
left : 0,
right : 0
})
], {optional: true}),
query('fuse-content > :enter', [
style({
transform: 'translateX(-100%)',
opacity : 0
})
], {optional: true}),
sequence([
group([
query('fuse-content > :leave', [
style({
transform: 'translateX(0)',
opacity : 1
}),
animate('400ms cubic-bezier(0.250, 0.460, 0.450, 0.940)',
style({
transform: 'translateX(100%)',
opacity : 0
}))
], {optional: true}),
query('fuse-content > :enter', [
style({transform: 'translateX(-100%)'}),
animate('400ms cubic-bezier(0.250, 0.460, 0.450, 0.940)',
style({
transform: 'translateX(0%)',
opacity : 1
}))
], {optional: true})
]),
query('fuse-content > :leave', animateChild(), {optional: true}),
query('fuse-content > :enter', animateChild(), {optional: true})
])
])
]);
public static routerTransitionUp = trigger('routerTransitionUp', [
transition('* => *', [
query('fuse-content > :enter, fuse-content > :leave', [
style({
position: 'absolute',
top : 0,
bottom : 0,
left : 0,
right : 0
})
], {optional: true}),
query('fuse-content > :enter', [
style({
transform: 'translateY(100%)',
opacity : 0
})
], {optional: true}),
sequence([
group([
query('fuse-content > :leave', [
2017-08-19 13:20:09 +00:00
style({
transform: 'translateY(0)',
opacity : 1
}),
animate('400ms cubic-bezier(0.250, 0.460, 0.450, 0.940)',
style({
transform: 'translateY(-100%)',
opacity : 0
}))
], {optional: true}),
query('fuse-content > :enter', [
2017-08-19 13:20:09 +00:00
style({transform: 'translateY(100%)'}),
animate('400ms cubic-bezier(0.250, 0.460, 0.450, 0.940)',
style({
transform: 'translateY(0%)',
opacity : 1
}))
], {optional: true})
2017-08-19 13:20:09 +00:00
]),
query('fuse-content > :leave', animateChild(), {optional: true}),
query('fuse-content > :enter', animateChild(), {optional: true})
])
])
]);
public static routerTransitionDown = trigger('routerTransitionDown', [
transition('* => *', [
query('fuse-content > :enter, fuse-content > :leave', [
style({
position: 'absolute',
top : 0,
bottom : 0,
left : 0,
right : 0
})
], {optional: true}),
query('fuse-content > :enter', [
style({
transform: 'translateY(-100%)',
opacity : 0
})
], {optional: true}),
sequence([
group([
query('fuse-content > :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
}))
], {optional: true}),
query('fuse-content > :enter', [
style({transform: 'translateY(-100%)'}),
animate('400ms cubic-bezier(0.250, 0.460, 0.450, 0.940)',
style({
transform: 'translateY(0%)',
opacity : 1
}))
], {optional: true})
]),
query('fuse-content > :leave', animateChild(), {optional: true}),
query('fuse-content > :enter', animateChild(), {optional: true})
2017-08-19 13:20:09 +00:00
])
])
]);
public static routerTransitionFade = trigger('routerTransitionFade', [
transition('* => *', group([
query('fuse-content > :enter, fuse-content > :leave ', [
style({
position: 'absolute',
top : 0,
bottom : 0,
left : 0,
right : 0
})
], {optional: true}),
query('fuse-content > :enter', [
style({
opacity: 0
})
], {optional: true}),
query('fuse-content > :leave', [
style({
opacity: 1
}),
animate('300ms cubic-bezier(0.250, 0.460, 0.450, 0.940)',
style({
opacity: 0
}))
], {optional: true}),
query('fuse-content > :enter', [
style({
opacity: 0
}),
animate('300ms cubic-bezier(0.250, 0.460, 0.450, 0.940)',
style({
opacity: 1
}))
], {optional: true}),
query('fuse-content > :enter', animateChild(), {optional: true}),
query('fuse-content > :leave', animateChild(), {optional: true})
]))
]);
}