Skip to content

Commit

Permalink
fix(grid): [grid] fix the initial position on the left when dragging …
Browse files Browse the repository at this point in the history
…the header to set width
  • Loading branch information
gimmyhehe committed Dec 30, 2024
1 parent 6909756 commit 94eb6ed
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/vue/src/grid/src/header/src/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import { isObject, isNull } from '@opentiny/vue-renderless/common/type'
import { removeClass, addClass } from '@opentiny/vue-renderless/common/deps/dom'
import { isBoolean, isFunction } from '@opentiny/vue-renderless/grid/static/'
import { updateCellTitle, getOffsetPos, emitEvent, getClass } from '@opentiny/vue-renderless/grid/utils'
import { updateCellTitle, emitEvent, getClass } from '@opentiny/vue-renderless/grid/utils'
import { h, $prefix, defineComponent } from '@opentiny/vue-common'
import { random } from '@opentiny/vue-renderless/common/string'

Expand Down Expand Up @@ -504,11 +504,12 @@ export default defineComponent({
let { dragLeft = 0, minInterval = 36, fixedOffsetWidth = 0 } = {}
let { resizeBar: resizeBarElem, tableBody } = $table.$refs
let { cell = dragBtnElem.parentNode, dragBtnWidth = dragBtnElem.clientWidth } = {}
let { pos = getOffsetPos(dragBtnElem, $el), tableBodyElem = tableBody.$el } = {}
let startColumnLeft = cell.offsetLeft
let dragBtnOffsetWidth = Math.floor(dragBtnWidth / 2)
let dragMinLeft = pos.left - cell.clientWidth + dragBtnWidth + minInterval
let dragPosLeft = pos.left + dragBtnOffsetWidth
const tableBodyElem = tableBody.$el
const btnLeft = dragBtnElem?.getBoundingClientRect().left - $el?.getBoundingClientRect().left
let dragMinLeft = btnLeft - cell.clientWidth + dragBtnWidth + minInterval
let dragPosLeft = btnLeft + dragBtnOffsetWidth
let { oldMousemove = document.onmousemove, oldMouseup = document.onmouseup } = {}

// 处理拖动事件
Expand All @@ -533,7 +534,7 @@ export default defineComponent({

let ret = computeDragLeft(args)
dragMinLeft = ret.dragMinLeft
dragLeft = ret.dragLeft - dragBtnOffsetWidth
dragLeft = ret.dragLeft

let currentLeft = ret.dragLeft - scrollLeft

Expand Down

0 comments on commit 94eb6ed

Please sign in to comment.