2022-08-08 17:01:25 +08:00
|
|
|
import type { CSSMotionProps } from 'rc-motion';
|
|
|
|
import type { AnimatedConfig } from 'rc-tabs/lib/interface';
|
2024-04-08 14:04:08 +08:00
|
|
|
|
2022-08-08 17:01:25 +08:00
|
|
|
import type { TabsProps } from '..';
|
|
|
|
import { getTransitionName } from '../../_util/motion';
|
|
|
|
|
|
|
|
const motion: CSSMotionProps = {
|
|
|
|
motionAppear: false,
|
|
|
|
motionEnter: true,
|
|
|
|
motionLeave: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function useAnimateConfig(
|
|
|
|
prefixCls: string,
|
|
|
|
animated: TabsProps['animated'] = {
|
|
|
|
inkBar: true,
|
|
|
|
tabPane: false,
|
|
|
|
},
|
|
|
|
): AnimatedConfig {
|
|
|
|
let mergedAnimated: AnimatedConfig;
|
|
|
|
|
|
|
|
if (animated === false) {
|
|
|
|
mergedAnimated = {
|
|
|
|
inkBar: false,
|
|
|
|
tabPane: false,
|
|
|
|
};
|
|
|
|
} else if (animated === true) {
|
|
|
|
mergedAnimated = {
|
|
|
|
inkBar: true,
|
2022-09-19 23:37:12 +08:00
|
|
|
tabPane: true,
|
2022-08-08 17:01:25 +08:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
mergedAnimated = {
|
|
|
|
inkBar: true,
|
|
|
|
...(typeof animated === 'object' ? animated : {}),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mergedAnimated.tabPane) {
|
|
|
|
mergedAnimated.tabPaneMotion = {
|
|
|
|
...motion,
|
|
|
|
motionName: getTransitionName(prefixCls, 'switch'),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return mergedAnimated;
|
|
|
|
}
|