mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-23 23:18:36 +08:00
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import type { CSSInterpolation } from '@ant-design/cssinjs';
|
|
import { Keyframes } from '@ant-design/cssinjs';
|
|
|
|
import type { AliasToken, TokenWithCommonCls } from '../../theme/internal';
|
|
import { initMotion } from './motion';
|
|
|
|
export const fadeIn = new Keyframes('antFadeIn', {
|
|
'0%': {
|
|
opacity: 0,
|
|
},
|
|
'100%': {
|
|
opacity: 1,
|
|
},
|
|
});
|
|
|
|
export const fadeOut = new Keyframes('antFadeOut', {
|
|
'0%': {
|
|
opacity: 1,
|
|
},
|
|
'100%': {
|
|
opacity: 0,
|
|
},
|
|
});
|
|
|
|
export const initFadeMotion = (
|
|
token: TokenWithCommonCls<AliasToken>,
|
|
sameLevel = false,
|
|
): CSSInterpolation => {
|
|
const { antCls } = token;
|
|
const motionCls = `${antCls}-fade`;
|
|
const sameLevelPrefix = sameLevel ? '&' : '';
|
|
|
|
return [
|
|
initMotion(motionCls, fadeIn, fadeOut, token.motionDurationMid, sameLevel),
|
|
{
|
|
[`
|
|
${sameLevelPrefix}${motionCls}-enter,
|
|
${sameLevelPrefix}${motionCls}-appear
|
|
`]: {
|
|
opacity: 0,
|
|
animationTimingFunction: 'linear',
|
|
},
|
|
|
|
[`${sameLevelPrefix}${motionCls}-leave`]: {
|
|
animationTimingFunction: 'linear',
|
|
},
|
|
},
|
|
];
|
|
};
|