mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-16 01:41:02 +08:00
c6244382a7
* chore: bump version * chore: update rest version * clean up rc-trigger ts define * clean up motion define
26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import { CSSMotionProps } from 'rc-motion';
|
|
import { MotionEventHandler, MotionEndEventHandler } from 'rc-motion/lib/CSSMotion';
|
|
|
|
// ================== Collapse Motion ==================
|
|
const getCollapsedHeight: MotionEventHandler = () => ({ height: 0, opacity: 0 });
|
|
const getRealHeight: MotionEventHandler = node => ({ height: node.scrollHeight, opacity: 1 });
|
|
const getCurrentHeight: MotionEventHandler = node => ({ height: node.offsetHeight });
|
|
const skipOpacityTransition: MotionEndEventHandler = (_, event) =>
|
|
(event as TransitionEvent).propertyName === 'height';
|
|
|
|
const collapseMotion: CSSMotionProps = {
|
|
motionName: 'ant-motion-collapse',
|
|
onAppearStart: getCollapsedHeight,
|
|
onEnterStart: getCollapsedHeight,
|
|
onAppearActive: getRealHeight,
|
|
onEnterActive: getRealHeight,
|
|
onLeaveStart: getCurrentHeight,
|
|
onLeaveActive: getCollapsedHeight,
|
|
onAppearEnd: skipOpacityTransition,
|
|
onEnterEnd: skipOpacityTransition,
|
|
onLeaveEnd: skipOpacityTransition,
|
|
motionDeadline: 500,
|
|
};
|
|
|
|
export default collapseMotion;
|