amis-rpc-design/node_modules/antd/es/_util/motion.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

2023-10-07 19:42:30 +08:00
// ================== 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 === null || event === void 0 ? void 0 : event.deadline) === true || event.propertyName === 'height';
const initCollapseMotion = function () {
let rootCls = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'ant';
return {
motionName: `${rootCls}-motion-collapse`,
onAppearStart: getCollapsedHeight,
onEnterStart: getCollapsedHeight,
onAppearActive: getRealHeight,
onEnterActive: getRealHeight,
onLeaveStart: getCurrentHeight,
onLeaveActive: getCollapsedHeight,
onAppearEnd: skipOpacityTransition,
onEnterEnd: skipOpacityTransition,
onLeaveEnd: skipOpacityTransition,
motionDeadline: 500
};
};
const SelectPlacements = ['bottomLeft', 'bottomRight', 'topLeft', 'topRight'];
const getTransitionName = (rootPrefixCls, motion, transitionName) => {
if (transitionName !== undefined) {
return transitionName;
}
return `${rootPrefixCls}-${motion}`;
};
export { getTransitionName };
export default initCollapseMotion;