Skip to content

Commit

Permalink
fix: 修正表头事件被阻的问题
Browse files Browse the repository at this point in the history
fix #100
  • Loading branch information
xpyjs committed Jun 14, 2024
1 parent 0d6b89c commit afde2a7
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/components/container/TableHeaderTh.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
<template>
<th
ref="headerRef"
:class="[
'xg-table-header-cell',
{
'xg-table-header-cell-resizable': !column.isLast
}
]"
class="xg-table-header-cell"
:style="{ 'border-color': $styleBox.borderColor }"
:colspan="column.colSpan"
:rowspan="column.rowSpan"
Expand All @@ -17,6 +12,12 @@
:__render-title-label="column.label"
:__render-title-props="titleProps"
/>

<div
v-if="!column.isLast"
ref="resizeLineRef"
class="xg-table-header-cell-resizable"
></div>
</th>
</template>

Expand Down Expand Up @@ -48,17 +49,21 @@ while (curColumn.value.children?.length > 0) {
const index = curColumn.value.node.props.__index;
const headerRef = ref(null) as Ref<HTMLElement | null>;
onResizeTableColumn(headerRef, {
const resizeLineRef = ref(null) as Ref<HTMLElement | null>;
onResizeTableColumn(resizeLineRef, {
onEnd: x => {
const headerLeft = headerRef.value?.offsetLeft ?? 0;
$slotsBox.tableHeaders.leafs[index].width = Math.max(
$slotsBox.tableHeaders.leafs[index].width + x,
$slotsBox.tableHeaders.leafs[index].width + x - headerLeft,
Variables.size.minTableColumnWidth
);
},
preMove: x => {
const headerLeft = headerRef.value?.offsetLeft ?? 0;
if (
$slotsBox.tableHeaders.leafs[index].width + x <
$slotsBox.tableHeaders.leafs[index].width + x - headerLeft <
Variables.size.minTableColumnWidth
)
return false;
Expand Down Expand Up @@ -90,7 +95,6 @@ const titleProps = props.column.isLeaf
border-right: 1px solid #e5e5e5;
padding: 0 12px;
font-size: 14px;
pointer-events: none;
}
.xg-table-header-cell-resizable {
Expand All @@ -102,7 +106,6 @@ const titleProps = props.column.isLeaf
bottom: 0;
width: 10px;
cursor: col-resize;
pointer-events: auto;
}
}
</style>

0 comments on commit afde2a7

Please sign in to comment.