xs-common-plugins 1.2.8 → 1.3.0

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/README.md CHANGED
@@ -313,3 +313,7 @@
313
313
  1.优化common.popup弹窗方法。
314
314
  2.优化common.clone方法
315
315
  ```
316
+ ```
317
+ 1.3.0
318
+ 1.调整fullScreenDirective.js
319
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xs-common-plugins",
3
- "version": "1.2.8",
3
+ "version": "1.3.0",
4
4
  "private": false,
5
5
  "description": "向上公共代码部分",
6
6
  "author": "祝玲云 <1902733517@qq.com>",
@@ -319,7 +319,7 @@ common.popup = (options) => {
319
319
  },
320
320
  template: `
321
321
  <div>
322
- <el-dialog :title="title" el-drag-dialog :visible.sync="visible" :width="width" :before-close="beforeClose" v-bind="dialogCfg" append-to-body>
322
+ <el-dialog :title="title" v-el-drag-dialog :visible.sync="visible" :width="width" :before-close="beforeClose" v-bind="dialogCfg" append-to-body>
323
323
  <child ref="child" :srcData="srcData" v-bind="props" @close="close" @cancel="cancel"/>
324
324
  <div v-if="showButton" style="text-align: right;">
325
325
  <el-button size="medium" type="primary" @click="confirm">确认</el-button>
@@ -17,13 +17,6 @@ export default {
17
17
  //弹窗
18
18
  const dragDom = el.querySelector('.el-dialog');
19
19
  dragDom.className += ' el-drag-dialog';
20
- //清除选择头部文字效果
21
- dialogHeaderEl.onselectstart = new Function("return false");
22
- //头部加上可拖动cursor
23
- dialogHeaderEl.style.cursor = 'move';
24
-
25
- // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
26
- const sty = dragDom.currentStyle || window.getComputedStyle(dragDom, null);
27
20
 
28
21
  //头部插入最大化最小化元素
29
22
  let maxMin = document.createElement("button");
@@ -33,42 +26,7 @@ export default {
33
26
  maxMin.title = el.fullscreen ? '还原' : '最大化';
34
27
  maxMin.innerHTML = '<i class=' + (el.fullscreen ? '"el-icon-crop"' : '"el-icon-full-screen"') + ' onMouseOver="this.style.color=\'#409EFF\'" onMouseOut="this.style.color=\'inherit\'"></i>';
35
28
  dialogHeaderEl.insertBefore(maxMin, dialogHeaderEl.childNodes[1]);
36
- let moveDown = (e) => {
37
- // 鼠标按下,计算当前元素距离可视区的距离
38
- const disX = e.clientX - dialogHeaderEl.offsetLeft;
39
- const disY = e.clientY - dialogHeaderEl.offsetTop;
40
-
41
- // 获取到的值带px 正则匹配替换
42
- let styL, styT;
43
-
44
- // 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
45
- if (sty.left.includes('%')) {
46
- styL = +document.body.clientWidth * (+sty.left.replace(/\%/g, '') / 100);
47
- styT = +document.body.clientHeight * (+sty.top.replace(/\%/g, '') / 100);
48
- } else {
49
- styL = +sty.left.replace(/\px/g, '');
50
- styT = +sty.top.replace(/\px/g, '');
51
- }
52
29
 
53
- document.onmousemove = function (e) {
54
- // 通过事件委托,计算移动的距离
55
- const l = e.clientX - disX;
56
- const t = e.clientY - disY;
57
-
58
- // 移动当前元素
59
- dragDom.style.left = `${l + styL}px`;
60
- dragDom.style.top = `${t + styT}px`;
61
-
62
- //将此时的位置传出去
63
- //binding.value({x:e.pageX,y:e.pageY})
64
- };
65
-
66
- document.onmouseup = function (e) {
67
- document.onmousemove = null;
68
- document.onmouseup = null;
69
- };
70
- }
71
- dialogHeaderEl.onmousedown = moveDown;
72
30
  let bodyHeight = 'auto';
73
31
 
74
32
  function setMaxMin() {
@@ -83,8 +41,6 @@ export default {
83
41
  dragDom.style.width = nowWidth + 'px';
84
42
  dragDom.style.marginTop = nowMarginTop;
85
43
  el.fullscreen = false;
86
- dialogHeaderEl.style.cursor = 'move';
87
- dialogHeaderEl.onmousedown = moveDown;
88
44
  dragDom.querySelector('.el-dialog__body').style.height = bodyHeight;
89
45
  hasSetBodyHight = false;
90
46
  } else {
@@ -98,8 +54,6 @@ export default {
98
54
  nowMarginTop = dragDom.style.marginTop;
99
55
  dragDom.style = 'width:100vw;height:100vh !important;'
100
56
  el.fullscreen = true;
101
- dialogHeaderEl.style.cursor = 'initial';
102
- dialogHeaderEl.onmousedown = null;
103
57
  if (!hasSetBodyHight) {
104
58
  let footerHeight = dragDom.querySelector('.el-dialog__footer') && dragDom.querySelector('.el-dialog__footer').offsetHeight;
105
59
  dragDom.querySelector('.el-dialog__body').style.height = 'calc(100% - ' + (dialogHeaderEl.offsetHeight + footerHeight) + 'px)';
@@ -111,47 +65,5 @@ export default {
111
65
 
112
66
  // 点击放大缩小效果
113
67
  maxMin.onclick = setMaxMin;
114
-
115
- //双击头部效果
116
- // dialogHeaderEl.ondblclick = setMaxMin;
117
-
118
- //拉伸
119
- let resizeEl = document.createElement("div");
120
- dragDom.appendChild(resizeEl);
121
- //在弹窗右下角加上一个10-10px的控制块
122
- resizeEl.style.cursor = 'se-resize';
123
- resizeEl.style.position = 'absolute';
124
- resizeEl.style.height = '10px';
125
- resizeEl.style.width = '10px';
126
- resizeEl.style.right = '0px';
127
- resizeEl.style.bottom = '0px';
128
- //鼠标拉伸弹窗
129
- resizeEl.onmousedown = (e) => {
130
- // 记录初始x位置
131
- const clientX = e.clientX;
132
- // 鼠标按下,计算当前元素距离可视区的距离
133
- const disX = e.clientX - resizeEl.offsetLeft;
134
- const disY = e.clientY - resizeEl.offsetTop;
135
- document.onmousemove = function (e) {
136
- e.preventDefault(); // 移动时禁用默认事件
137
- // 通过事件委托,计算移动的距离
138
- const x = e.clientX - disX + (e.clientX - clientX);//这里 由于elementUI的dialog控制居中的,所以水平拉伸效果是双倍
139
- const y = e.clientY - disY;
140
- //比较是否小于最小宽高
141
- dragDom.style.width = x > minWidth ? `${x}px` : minWidth + 'px';
142
- dragDom.style.height = y > minHeight ? `${y}px` : minHeight + 'px';
143
- if (!hasSetBodyHight) {
144
- let footerHeight = dragDom.querySelector('.el-dialog__footer') && dragDom.querySelector('.el-dialog__footer').offsetHeight;
145
- dragDom.querySelector('.el-dialog__body').style.height = 'calc(100% - ' + (dialogHeaderEl.offsetHeight + footerHeight) + 'px)';
146
- hasSetBodyHight = true;
147
- }
148
- };
149
- //拉伸结束
150
- document.onmouseup = function (e) {
151
- document.onmousemove = null;
152
- document.onmouseup = null;
153
- el.dispatchEvent(resizeEvent);
154
- };
155
- }
156
68
  }
157
69
  }