zydx-plus 1.35.635 → 1.35.636
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -101,12 +101,12 @@ export default {
|
|
|
101
101
|
// 获取Dom节点
|
|
102
102
|
const boxDom = this.$refs.boxRef,
|
|
103
103
|
leftDom = this.$refs.leftRef,
|
|
104
|
-
resizeDom = this.$refs.resizeRef
|
|
105
|
-
rightDom = this.$refs.rightRef;
|
|
104
|
+
resizeDom = this.$refs.resizeRef;
|
|
106
105
|
if (resizeDom) {
|
|
107
106
|
// 使用 .resize div 的实际宽度(10px)而非 img 宽度(30px),避免拖动位置偏左
|
|
108
107
|
const resizeWidth = resizeDom.parentElement.offsetWidth
|
|
109
|
-
const
|
|
108
|
+
const containerWidth = boxDom.clientWidth
|
|
109
|
+
const maxWidth = containerWidth - resizeWidth; // 左右两边区域的总宽度 = 外层容器宽度 - 中间区域拖拉框的宽度
|
|
110
110
|
resizeDom.onmousedown = e => {
|
|
111
111
|
const startX = e.clientX; // 记录坐标起始位置
|
|
112
112
|
const startLeft = leftDom.offsetWidth; // 左边元素起始宽度
|
|
@@ -121,9 +121,10 @@ export default {
|
|
|
121
121
|
if (moveLen > maxWidth - this.rightMinWidth) {
|
|
122
122
|
moveLen = maxWidth - this.rightMinWidth;
|
|
123
123
|
}
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
this.
|
|
124
|
+
// 百分比基准用完整容器宽,右侧再减去 resize 宽度,
|
|
125
|
+
// 保证 left% + right% + resize(10px) = 100%,避免拖拽后总宽多出 10px
|
|
126
|
+
this.leftWidth = (moveLen / containerWidth) * 100 + "%"; // 设置左边区域的宽度,通过换算为百分比的形式,实现窗体放大缩小自适应
|
|
127
|
+
this.rightWidth = ((containerWidth - moveLen - resizeWidth) / containerWidth) * 100 + "%"; // 右边区域 = 容器 - 左边宽度 - 拖动条宽度
|
|
127
128
|
};
|
|
128
129
|
document.onmouseup = () => {
|
|
129
130
|
document.onmousemove = null;
|