ant-design-x-vue
Version:
Craft AI-driven interfaces effortlessly
50 lines (49 loc) • 2.21 kB
JavaScript
import { defineComponent as n, useSlots as i, computed as r, createVNode as p, Transition as g } from "vue";
const l = /* @__PURE__ */ n({
name: "AXTransitionCollapse",
__name: "TransitionCollapse",
props: {
prefixCls: {
default: "ax"
}
},
setup(e) {
const d = e, a = i(), s = r(() => d.prefixCls + "-transition-collapse"), o = {
beforeEnter(t) {
t.dataset || (t.dataset = {}), t.dataset.oldPaddingTop = t.style.paddingTop, t.dataset.oldPaddingBottom = t.style.paddingBottom, t.style.maxHeight = "0", t.style.paddingTop = "0", t.style.paddingBottom = "0";
},
enter(t) {
t.dataset.oldOverflow = t.style.overflow, t.scrollHeight !== 0 ? (t.style.maxHeight = `${t.scrollHeight}px`, t.style.paddingTop = t.dataset.oldPaddingTop, t.style.paddingBottom = t.dataset.oldPaddingBottom) : (t.style.maxHeight = `${t.dataset.oldMaxHeight || "999"}px`, t.style.paddingTop = t.dataset.oldPaddingTop, t.style.paddingBottom = t.dataset.oldPaddingBottom), t.style.overflow = "hidden";
},
afterEnter(t) {
t.style.maxHeight = "", t.style.overflow = t.dataset.oldOverflow;
},
beforeLeave(t) {
t.dataset || (t.dataset = {}), t.dataset.oldMaxHeight = t.scrollHeight, t.dataset.oldPaddingTop = t.style.paddingTop, t.dataset.oldPaddingBottom = t.style.paddingBottom, t.dataset.oldOverflow = t.style.overflow, t.style.overflow = "hidden", t.style.maxHeight = `${t.scrollHeight}px`;
},
leave(t) {
t.scrollHeight !== 0 && (t.style.maxHeight = "0", t.style.paddingTop = "0", t.style.paddingBottom = "0");
},
afterLeave(t) {
t.style.maxHeight = "", t.style.overflow = t.dataset.oldOverflow, t.style.paddingTop = t.dataset.oldPaddingTop, t.style.paddingBottom = t.dataset.oldPaddingBottom;
}
};
return () => p(g, {
name: s.value,
onBeforeEnter: o.beforeEnter,
onEnter: o.enter,
onAfterEnter: o.afterEnter,
onBeforeLeave: o.beforeLeave,
onLeave: o.leave,
onAfterLeave: o.afterLeave
}, {
default: () => {
var t;
return [(t = a.default) == null ? void 0 : t.call(a)];
}
});
}
});
export {
l as default
};