@progress/kendo-angular-dialog
Version:
Dialog Package for Angular
74 lines (73 loc) • 2.77 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { animate, keyframes, style } from '@angular/animations';
/**
* @hidden
*/
export function animations(duration, direction, animationType) {
switch (animationType) {
case 'slide': {
const translate = direction === 'left' || direction === 'right' ? 'translateX' : 'translateY';
const start = direction === 'right' || direction === 'down' ? -100 : 100;
const end = 0;
return [
style({ transform: `${translate}(${start}%)` }),
animate(`${duration}ms ease-in`, style({ transform: `${translate}(${end}%)` }))
];
}
case 'expand': {
const scale = direction === 'up' || direction === 'down' ? 'scaleY' : 'scaleX';
const startScale = 0;
const endScale = 1;
let origin;
if (direction === 'down') {
origin = 'top';
}
else if (direction === 'left') {
origin = 'right';
}
else if (direction === 'right') {
origin = 'left';
}
else {
origin = 'bottom';
}
return [
style({ transform: `${scale}(${startScale})`, transformOrigin: origin }),
animate(`${duration}ms ease-in`, style({ transform: `${scale}(${endScale})` }))
];
}
case 'zoom': {
const startZoom = 0;
const endZoom = 1;
return [
animate(duration, keyframes([
style({ transform: `scale(${startZoom})` }),
style({ transform: `scale(${endZoom})` })
]))
];
}
case 'fade': {
const startFade = 0;
const endFade = 1;
return [
animate(duration, keyframes([
style({ opacity: `${startFade}` }),
style({ opacity: `${endFade}` })
]))
];
}
case 'translate':
return [
style({ transform: 'translate(0, -10%)' }),
animate(`${duration}ms cubic-bezier(.2, 1, .2, 1)`)
];
default:
return [
style({ transform: 'translate(0, -10%)' }),
animate(`${duration}ms cubic-bezier(.2, 1, .2, 1)`)
];
}
}