Files
appco_dist/.output/server/chunks/build/collapseMotion-cQ2SGjCA.mjs
T
2025-07-23 16:57:31 +03:30

96 lines
2.6 KiB
JavaScript

import { nextTick } from 'vue';
const genCollapseMotion = (token) => ({
[token.componentCls]: {
// For common/openAnimation
[`${token.antCls}-motion-collapse-legacy`]: {
overflow: "hidden",
"&-active": {
transition: `height ${token.motionDurationMid} ${token.motionEaseInOut},
opacity ${token.motionDurationMid} ${token.motionEaseInOut} !important`
}
},
[`${token.antCls}-motion-collapse`]: {
overflow: "hidden",
transition: `height ${token.motionDurationMid} ${token.motionEaseInOut},
opacity ${token.motionDurationMid} ${token.motionEaseInOut} !important`
}
}
});
function hasClass(node, className) {
if (node.classList) {
return node.classList.contains(className);
}
const originClass = node.className;
return ` ${originClass} `.indexOf(` ${className} `) > -1;
}
function addClass(node, className) {
if (node.classList) {
node.classList.add(className);
} else {
if (!hasClass(node, className)) {
node.className = `${node.className} ${className}`;
}
}
}
function removeClass(node, className) {
if (node.classList) {
node.classList.remove(className);
} else {
if (hasClass(node, className)) {
const originClass = node.className;
node.className = ` ${originClass} `.replace(` ${className} `, " ");
}
}
}
const collapseMotion = function() {
let name = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "ant-motion-collapse";
let appear = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
return {
name,
appear,
css: true,
onBeforeEnter: (node) => {
node.style.height = "0px";
node.style.opacity = "0";
addClass(node, name);
},
onEnter: (node) => {
nextTick(() => {
node.style.height = `${node.scrollHeight}px`;
node.style.opacity = "1";
});
},
onAfterEnter: (node) => {
if (node) {
removeClass(node, name);
node.style.height = null;
node.style.opacity = null;
}
},
onBeforeLeave: (node) => {
addClass(node, name);
node.style.height = `${node.offsetHeight}px`;
node.style.opacity = null;
},
onLeave: (node) => {
setTimeout(() => {
node.style.height = "0px";
node.style.opacity = "0";
});
},
onAfterLeave: (node) => {
if (node) {
removeClass(node, name);
if (node.style) {
node.style.height = null;
node.style.opacity = null;
}
}
}
};
};
export { collapseMotion as c, genCollapseMotion as g };
//# sourceMappingURL=collapseMotion-cQ2SGjCA.mjs.map