From 120735fb39074918abce07111fd3e8be9b08cfb3 Mon Sep 17 00:00:00 2001 From: eeezgame Date: Sat, 10 Apr 2021 17:53:25 +0800 Subject: [PATCH] fix[el-drag-dialog]: drag bug when screen size less than dom size #3178 --- src/directive/el-drag-dialog/drag.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/directive/el-drag-dialog/drag.js b/src/directive/el-drag-dialog/drag.js index 299e9854..6cb5f383 100644 --- a/src/directive/el-drag-dialog/drag.js +++ b/src/directive/el-drag-dialog/drag.js @@ -61,6 +61,16 @@ export default { top = maxDragDomTop } + // 当前元素宽度大于浏览器窗口宽度时,则将其向左偏移左侧可拖拽长度 + if (maxDragDomLeft < 0) { + left = -minDragDomLeft + } + + // 当前元素高度大于浏览器窗口高度时,则将其向上偏移顶侧可拖拽长度 + if (maxDragDomTop < 0) { + top = -minDragDomTop + } + // 移动当前元素 dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`