UNPKG

tav-ui

Version:
46 lines (43 loc) 1.41 kB
import { ref, computed, unref, nextTick, onMounted, onActivated, onBeforeUnmount } from 'vue'; import { addResizeListener, removeResizeListener } from '../../../../utils/event/index2.mjs'; function useHeight(wrapperRef, operationRef) { const height = ref("100%"); const getHeight = computed(() => unref(height)); const setHeight = () => { if (unref(wrapperRef) && unref(operationRef)) { const wrapperHeight = unref(wrapperRef).offsetHeight; const operationHeight = unref(operationRef).offsetHeight; height.value = `${wrapperHeight - operationHeight}px`; } }; return { getHeight, setHeight }; } function useFixHeight(tableRef, wrapperRef, setHeight, tableEmitter, tablePropsRef) { const reCalculate = () => { setHeight(); nextTick(() => { unref(tableRef)?.recalculate(true); }); }; if (unref(tablePropsRef).showOperations) { onMounted(() => { tableEmitter.on("table-pro:filter-form-rendered", () => { const parentEl = unref(wrapperRef)?.parentElement; reCalculate(); addResizeListener(parentEl, reCalculate); }); }); onActivated(() => { reCalculate(); }); onBeforeUnmount(() => { const parentEl = unref(wrapperRef)?.parentElement; removeResizeListener(parentEl, reCalculate); }); } } export { useFixHeight, useHeight }; //# sourceMappingURL=useHeight2.mjs.map