tav-ui
Version:
51 lines (46 loc) • 1.49 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var index = require('../../../../utils/event/index2.js');
function useHeight(wrapperRef, operationRef) {
const height = vue.ref("100%");
const getHeight = vue.computed(() => vue.unref(height));
const setHeight = () => {
if (vue.unref(wrapperRef) && vue.unref(operationRef)) {
const wrapperHeight = vue.unref(wrapperRef).offsetHeight;
const operationHeight = vue.unref(operationRef).offsetHeight;
height.value = `${wrapperHeight - operationHeight}px`;
}
};
return {
getHeight,
setHeight
};
}
function useFixHeight(tableRef, wrapperRef, setHeight, tableEmitter, tablePropsRef) {
const reCalculate = () => {
setHeight();
vue.nextTick(() => {
vue.unref(tableRef)?.recalculate(true);
});
};
if (vue.unref(tablePropsRef).showOperations) {
vue.onMounted(() => {
tableEmitter.on("table-pro:filter-form-rendered", () => {
const parentEl = vue.unref(wrapperRef)?.parentElement;
reCalculate();
index.addResizeListener(parentEl, reCalculate);
});
});
vue.onActivated(() => {
reCalculate();
});
vue.onBeforeUnmount(() => {
const parentEl = vue.unref(wrapperRef)?.parentElement;
index.removeResizeListener(parentEl, reCalculate);
});
}
}
exports.useFixHeight = useFixHeight;
exports.useHeight = useHeight;
//# sourceMappingURL=useHeight2.js.map