mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 01:19:45 +08:00
0097d34d01
* chore: Update rc-motion deps * frame wheel not prevent scroll * update ts
25 lines
989 B
TypeScript
25 lines
989 B
TypeScript
import { CSSMotionProps, MotionEventHandler, MotionEndEventHandler } from 'rc-motion';
|
|
|
|
// ================== 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;
|