UNPKG

@ant-design/x

Version:

Craft AI-driven interfaces effortlessly

34 lines (33 loc) 976 B
import { defaultPrefixCls } from "../x-provider"; // ================== Collapse Motion ================== const getCollapsedHeight = () => ({ height: 0, opacity: 0 }); const getRealHeight = node => { const { scrollHeight } = node; return { height: scrollHeight, opacity: 1 }; }; const getCurrentHeight = node => ({ height: node ? node.offsetHeight : 0 }); const skipOpacityTransition = (_, event) => event?.deadline === true || event.propertyName === 'height'; const initCollapseMotion = (rootCls = defaultPrefixCls) => ({ motionName: `${rootCls}-motion-collapse`, onAppearStart: getCollapsedHeight, onEnterStart: getCollapsedHeight, onAppearActive: getRealHeight, onEnterActive: getRealHeight, onLeaveStart: getCurrentHeight, onLeaveActive: getCollapsedHeight, onAppearEnd: skipOpacityTransition, onEnterEnd: skipOpacityTransition, onLeaveEnd: skipOpacityTransition, motionDeadline: 500 }); export default initCollapseMotion;