linkmore-design
Version:
π πlmη»δ»ΆεΊγπ
55 lines (54 loc) β’ 1.67 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getTransitionName = exports.getTransitionDirection = exports.default = void 0;
var _type = require("./type");
// ================== 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 collapseMotion = {
motionName: 'ant-motion-collapse',
onAppearStart: getCollapsedHeight,
onEnterStart: getCollapsedHeight,
onAppearActive: getRealHeight,
onEnterActive: getRealHeight,
onLeaveStart: getCurrentHeight,
onLeaveActive: getCollapsedHeight,
onAppearEnd: skipOpacityTransition,
onEnterEnd: skipOpacityTransition,
onLeaveEnd: skipOpacityTransition,
motionDeadline: 500
};
const SelectPlacements = (0, _type.tuple)('bottomLeft', 'bottomRight', 'topLeft', 'topRight');
const getTransitionDirection = placement => {
if (placement !== undefined && (placement === 'topLeft' || placement === 'topRight')) {
return `slide-down`;
}
return `slide-up`;
};
exports.getTransitionDirection = getTransitionDirection;
const getTransitionName = (rootPrefixCls, motion, transitionName) => {
if (transitionName !== undefined) {
return transitionName;
}
return `${rootPrefixCls}-${motion}`;
};
exports.getTransitionName = getTransitionName;
var _default = collapseMotion;
exports.default = _default;
;