You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.4 KiB
53 lines
1.4 KiB
3 years ago
|
/* eslint-disable import/prefer-default-export */
|
||
3 years ago
|
import type { CSSObject, Keyframes } from '@ant-design/cssinjs';
|
||
3 years ago
|
|
||
|
const initMotionCommon = (duration: string): CSSObject => ({
|
||
|
animationDuration: duration,
|
||
|
animationFillMode: 'both',
|
||
|
});
|
||
|
|
||
|
// FIXME: origin less code seems same as initMotionCommon. Maybe we can safe remove
|
||
|
const initMotionCommonLeave = (duration: string): CSSObject => ({
|
||
|
animationDuration: duration,
|
||
|
animationFillMode: 'both',
|
||
|
});
|
||
|
|
||
|
export const initMotion = (
|
||
2 years ago
|
motionCls: string,
|
||
3 years ago
|
inKeyframes: Keyframes,
|
||
|
outKeyframes: Keyframes,
|
||
|
duration: string,
|
||
2 years ago
|
sameLevel = false,
|
||
|
): CSSObject => {
|
||
|
const sameLevelPrefix = sameLevel ? '&' : '';
|
||
3 years ago
|
|
||
2 years ago
|
return {
|
||
|
[`
|
||
|
${sameLevelPrefix}${motionCls}-enter,
|
||
|
${sameLevelPrefix}${motionCls}-appear
|
||
|
`]: {
|
||
|
...initMotionCommon(duration),
|
||
|
animationPlayState: 'paused',
|
||
|
},
|
||
3 years ago
|
|
||
2 years ago
|
[`${sameLevelPrefix}${motionCls}-leave`]: {
|
||
|
...initMotionCommonLeave(duration),
|
||
|
animationPlayState: 'paused',
|
||
|
},
|
||
3 years ago
|
|
||
2 years ago
|
[`
|
||
|
${sameLevelPrefix}${motionCls}-enter${motionCls}-enter-active,
|
||
|
${sameLevelPrefix}${motionCls}-appear${motionCls}-appear-active
|
||
|
`]: {
|
||
|
animationName: inKeyframes,
|
||
|
animationPlayState: 'running',
|
||
|
},
|
||
|
|
||
|
[`${sameLevelPrefix}${motionCls}-leave${motionCls}-leave-active`]: {
|
||
|
animationName: outKeyframes,
|
||
|
animationPlayState: 'running',
|
||
|
pointerEvents: 'none',
|
||
|
},
|
||
|
};
|
||
|
};
|