Skip to content

Commit

Permalink
fix:修复 v-drag 指令对 el-dialog 使用时会意外抖动的问题 close #IAA2YN
Browse files Browse the repository at this point in the history
  • Loading branch information
build-admin committed Jul 17, 2024
1 parent 3324795 commit 799706b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions web/src/utils/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,10 @@ function dragDirective(app: App) {
return false
}

dragHandle.onmouseover = () => (dragHandle.style.cursor = `move`)

function down(e: MouseEvent | TouchEvent, type: string): downReturn {
// 鼠标按下,计算当前元素距离可视区的距离
const disX =
type === 'pc' ? (e as MouseEvent).clientX - dragHandle.offsetLeft : (e as TouchEvent).touches[0].clientX - dragHandle.offsetLeft
const disY =
type === 'pc' ? (e as MouseEvent).clientY - dragHandle.offsetTop : (e as TouchEvent).touches[0].clientY - dragHandle.offsetTop
// 鼠标按下,记录鼠标位置
const disX = type === 'pc' ? (e as MouseEvent).clientX : (e as TouchEvent).touches[0].clientX
const disY = type === 'pc' ? (e as MouseEvent).clientY : (e as TouchEvent).touches[0].clientY

// body宽度
const screenWidth = document.body.clientWidth
Expand Down Expand Up @@ -202,6 +198,7 @@ function dragDirective(app: App) {
dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`
}

dragHandle.onmouseover = () => (dragHandle.style.cursor = `move`)
dragHandle.onmousedown = (e) => {
const obj = down(e, 'pc')
document.onmousemove = (e) => {
Expand Down

0 comments on commit 799706b

Please sign in to comment.