Skip to content

Commit

Permalink
fix: 表头高度重新设置
Browse files Browse the repository at this point in the history
  • Loading branch information
xpyjs committed Jun 11, 2024
1 parent 66025c4 commit cacf8a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/composables/useDrag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default () => {
onMounted(() => {
const rootRect = rootRef.value?.getBoundingClientRect();

const { getMaxHeaderHeight } = useElement();
const { updateHeaderHeight } = useElement();

(el.value as HTMLElement)?.addEventListener('pointerdown', e => {
moveLineLeft.value = e.clientX - (rootRect?.left ?? 0);
Expand All @@ -101,7 +101,7 @@ export default () => {

await nextTick();

$param.headerHeight = getMaxHeaderHeight();
updateHeaderHeight();
},

onFinally: () => {
Expand Down
10 changes: 10 additions & 0 deletions src/composables/useElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@ export default () => {
function updateHeaderHeight() {
if (!$param.headerHeight) return;

// 删除 ref 中 style 的 height 属性,以便获取真实高度
tableHeaderRef.value?.style.removeProperty('height');
ganttHeaderRef.value?.style.removeProperty('height');

const maxHeight = getMaxHeaderHeight();
if ($param.headerHeight !== maxHeight) {
$param.headerHeight = maxHeight;
}

// 重新设置高度
tableHeaderRef.value &&
(tableHeaderRef.value.style.height = `${maxHeight}px`);
ganttHeaderRef.value &&
(ganttHeaderRef.value.style.height = `${maxHeight}px`);
}

return {
Expand Down

0 comments on commit cacf8a0

Please sign in to comment.