@ajaxjs/ui 1.1.6 → 1.1.7

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.
@@ -1,152 +1,152 @@
1
- export default {
2
- data() {
3
- return {
4
- styleWidth: 0,// 样式参数值
5
- styleHeight: 0,
6
- styleLeft: 0,
7
- styleTop: 0,
8
- sideLeft: 0, // 四条边定位坐标
9
- sideRight: 0,
10
- sideUp: 0,
11
- sideDown: 0,
12
- fixLeft: 0, // top 和 left 定位参数
13
- fixTop: 0,
14
- fn: null,
15
-
16
- LockX: false,// 是否锁定水平方向拖放
17
- LockY: false,// 是否锁定垂直方向拖放
18
- Lock: false,// 是否锁定
19
-
20
- scale: { // 按比例缩放
21
- enable: true, // 是否按比例缩放
22
- ratio: 0, // 设置比例(宽/高)
23
- left: 0,
24
- top: 0,
25
- },
26
-
27
- min: { // 最小控制
28
- enable: false,
29
- height: 100,
30
- width: 200,
31
- },
32
- max: { // 最大控制
33
- enable: false,
34
- height: 300,
35
- width: 500,
36
- }
37
-
38
- };
39
- },
40
- methods: {
41
- /**
42
- * 准备拖动
43
- */
44
- start(e: MouseEvent, fn: Function): void {
45
- this.styleWidth = this.$el.clientWidth;
46
- this.styleHeight = this.$el.clientHeight;
47
- this.styleLeft = this.$el.offsetLeft; // 记录鼠标相对拖放对象的位置
48
- this.styleTop = this.$el.offsetTop;
49
-
50
- this.sideLeft = e.clientX - this.styleWidth;
51
- this.sideRight = e.clientX + this.styleWidth;
52
- this.sideUp = e.clientY - this.styleHeight;
53
- this.sideDown = e.clientY + this.styleHeight;
54
-
55
- this.fixLeft = this.styleWidth + this.styleLeft;
56
- this.fixTop = this.styleHeight + this.styleTop;
57
- this.fn = fn;
58
-
59
- if (this.scale.enable) {
60
- this.scale.ratio = Math.max(this.scale.ratio, 0) || this.styleWidth / this.styleHeight; //设置比例
61
- this.scale.left = this.styleLeft + this.styleWidth / 2;// left 和 top 的定位坐标
62
- this.scale.top = this.styleTop + this.styleHeight / 2;
63
- }
64
-
65
- document.addEventListener("mousemove", this.resize);// mousemove 时移动 mouseup 时停止
66
- document.addEventListener("mouseup", this.stop);
67
- },
68
-
69
- // 缩放
70
- resize(e: MouseEvent): void {
71
- window.getSelection().removeAllRanges(); // 清除选择
72
- this.fn(e);
73
-
74
- if (this.min.enable) {
75
- if (this.styleHeight <= this.min.height)
76
- return;
77
- if (this.styleWidth <= this.min.width)
78
- return;
79
- }
80
- if (this.max.enable) {
81
- if (this.styleHeight >= this.max.height)
82
- return;
83
- if (this.styleWidth >= this.max.width)
84
- return;
85
- }
86
-
87
- let s = this.$el.style;
88
- s.width = this.styleWidth + "px";
89
- s.height = this.styleHeight + "px";
90
- s.top = this.styleTop + "px";
91
- s.left = this.styleLeft + "px";
92
- },
93
-
94
- // 停止缩放
95
- stop(): void {
96
- document.removeEventListener("mousemove", this.resize);
97
- document.removeEventListener("mouseup", this.stop);
98
- },
99
-
100
- //缩放程序
101
-
102
- //上
103
- up(e: MouseEvent): void {
104
- this.styleHeight = Math.max(this.sideDown - e.clientY, 0);
105
- this.styleTop = this.fixTop - this.styleHeight;
106
- this.styleLeft = this.scale.left - this.styleWidth / 2;
107
- console.log(this.styleLeft)
108
- },
109
-
110
- //下
111
- down(e: MouseEvent): void {
112
- this.styleHeight = Math.max(e.clientY - this.sideUp, 0);
113
- this.styleLeft = this.scale.left - this.styleWidth / 2;
114
-
115
- },
116
-
117
- //右
118
- right(e: MouseEvent): void {
119
- this.styleWidth = Math.max(e.clientX - this.sideLeft, 0);
120
- },
121
-
122
- //左
123
- left(e: MouseEvent): void {
124
- this.styleWidth = Math.max(this.sideRight - e.clientX, 0);
125
- this.styleLeft = this.fixLeft - this.styleWidth;
126
- },
127
-
128
- //右下
129
- rightDown(e: MouseEvent): void {
130
- this.right(e);
131
- this.down(e);
132
- },
133
-
134
- //右上
135
- rightUp(e: MouseEvent): void {
136
- this.right(e);
137
- this.up(e);
138
- },
139
-
140
- //左下
141
- leftDown(e: MouseEvent): void {
142
- this.left(e);
143
- this.down(e);
144
- },
145
-
146
- //左上
147
- leftUp(e: MouseEvent): void {
148
- this.left(e);
149
- this.up(e);
150
- },
151
- },
1
+ export default {
2
+ data() {
3
+ return {
4
+ styleWidth: 0,// 样式参数值
5
+ styleHeight: 0,
6
+ styleLeft: 0,
7
+ styleTop: 0,
8
+ sideLeft: 0, // 四条边定位坐标
9
+ sideRight: 0,
10
+ sideUp: 0,
11
+ sideDown: 0,
12
+ fixLeft: 0, // top 和 left 定位参数
13
+ fixTop: 0,
14
+ fn: null,
15
+
16
+ LockX: false,// 是否锁定水平方向拖放
17
+ LockY: false,// 是否锁定垂直方向拖放
18
+ Lock: false,// 是否锁定
19
+
20
+ scale: { // 按比例缩放
21
+ enable: true, // 是否按比例缩放
22
+ ratio: 0, // 设置比例(宽/高)
23
+ left: 0,
24
+ top: 0,
25
+ },
26
+
27
+ min: { // 最小控制
28
+ enable: false,
29
+ height: 100,
30
+ width: 200,
31
+ },
32
+ max: { // 最大控制
33
+ enable: false,
34
+ height: 300,
35
+ width: 500,
36
+ }
37
+
38
+ };
39
+ },
40
+ methods: {
41
+ /**
42
+ * 准备拖动
43
+ */
44
+ start(e: MouseEvent, fn: Function): void {
45
+ this.styleWidth = this.$el.clientWidth;
46
+ this.styleHeight = this.$el.clientHeight;
47
+ this.styleLeft = this.$el.offsetLeft; // 记录鼠标相对拖放对象的位置
48
+ this.styleTop = this.$el.offsetTop;
49
+
50
+ this.sideLeft = e.clientX - this.styleWidth;
51
+ this.sideRight = e.clientX + this.styleWidth;
52
+ this.sideUp = e.clientY - this.styleHeight;
53
+ this.sideDown = e.clientY + this.styleHeight;
54
+
55
+ this.fixLeft = this.styleWidth + this.styleLeft;
56
+ this.fixTop = this.styleHeight + this.styleTop;
57
+ this.fn = fn;
58
+
59
+ if (this.scale.enable) {
60
+ this.scale.ratio = Math.max(this.scale.ratio, 0) || this.styleWidth / this.styleHeight; //设置比例
61
+ this.scale.left = this.styleLeft + this.styleWidth / 2;// left 和 top 的定位坐标
62
+ this.scale.top = this.styleTop + this.styleHeight / 2;
63
+ }
64
+
65
+ document.addEventListener("mousemove", this.resize);// mousemove 时移动 mouseup 时停止
66
+ document.addEventListener("mouseup", this.stop);
67
+ },
68
+
69
+ // 缩放
70
+ resize(e: MouseEvent): void {
71
+ window.getSelection().removeAllRanges(); // 清除选择
72
+ this.fn(e);
73
+
74
+ if (this.min.enable) {
75
+ if (this.styleHeight <= this.min.height)
76
+ return;
77
+ if (this.styleWidth <= this.min.width)
78
+ return;
79
+ }
80
+ if (this.max.enable) {
81
+ if (this.styleHeight >= this.max.height)
82
+ return;
83
+ if (this.styleWidth >= this.max.width)
84
+ return;
85
+ }
86
+
87
+ let s = this.$el.style;
88
+ s.width = this.styleWidth + "px";
89
+ s.height = this.styleHeight + "px";
90
+ s.top = this.styleTop + "px";
91
+ s.left = this.styleLeft + "px";
92
+ },
93
+
94
+ // 停止缩放
95
+ stop(): void {
96
+ document.removeEventListener("mousemove", this.resize);
97
+ document.removeEventListener("mouseup", this.stop);
98
+ },
99
+
100
+ //缩放程序
101
+
102
+ //上
103
+ up(e: MouseEvent): void {
104
+ this.styleHeight = Math.max(this.sideDown - e.clientY, 0);
105
+ this.styleTop = this.fixTop - this.styleHeight;
106
+ this.styleLeft = this.scale.left - this.styleWidth / 2;
107
+ console.log(this.styleLeft)
108
+ },
109
+
110
+ //下
111
+ down(e: MouseEvent): void {
112
+ this.styleHeight = Math.max(e.clientY - this.sideUp, 0);
113
+ this.styleLeft = this.scale.left - this.styleWidth / 2;
114
+
115
+ },
116
+
117
+ //右
118
+ right(e: MouseEvent): void {
119
+ this.styleWidth = Math.max(e.clientX - this.sideLeft, 0);
120
+ },
121
+
122
+ //左
123
+ left(e: MouseEvent): void {
124
+ this.styleWidth = Math.max(this.sideRight - e.clientX, 0);
125
+ this.styleLeft = this.fixLeft - this.styleWidth;
126
+ },
127
+
128
+ //右下
129
+ rightDown(e: MouseEvent): void {
130
+ this.right(e);
131
+ this.down(e);
132
+ },
133
+
134
+ //右上
135
+ rightUp(e: MouseEvent): void {
136
+ this.right(e);
137
+ this.up(e);
138
+ },
139
+
140
+ //左下
141
+ leftDown(e: MouseEvent): void {
142
+ this.left(e);
143
+ this.down(e);
144
+ },
145
+
146
+ //左上
147
+ leftUp(e: MouseEvent): void {
148
+ this.left(e);
149
+ this.up(e);
150
+ },
151
+ },
152
152
  };
@@ -1,104 +1,104 @@
1
- <template>
2
- <!-- 拖拉缩放效果 -->
3
- <div class="resize-box">
4
- <div class="rRightDown" @mousedown="start($event, rightDown)"> </div>
5
- <div class="rLeftDown" @mousedown="start($event, leftDown)"> </div>
6
- <div class="rRightUp" @mousedown="start($event, rightUp)"> </div>
7
- <div class="rLeftUp" @mousedown="start($event, leftUp)"> </div>
8
- <div class="rRight" @mousedown="start($event, right)"> </div>
9
- <div class="rLeft" @mousedown="start($event, left)"> </div>
10
- <div class="rDown" @mousedown="start($event, down)"></div>
11
- <div class="rUp" @mousedown="start($event, up)"> </div>
12
- </div>
13
- </template>
14
-
15
- <script lang="ts" src="./Resize.ts"></script>
16
-
17
- <style lang="less" scoped>
18
- .rRightDown,
19
- .rLeftDown,
20
- .rLeftUp,
21
- .rRightUp,
22
- .rRight,
23
- .rLeft,
24
- .rUp,
25
- .rDown {
26
- position: absolute;
27
- background: #c00;
28
- width: 7px;
29
- height: 7px;
30
- z-index: 5;
31
- font-size: 0;
32
- }
33
-
34
- .rLeftDown, .rRightUp {
35
- cursor: ne-resize;
36
- }
37
-
38
- .rRightDown, .rLeftUp {
39
- cursor: nw-resize;
40
- }
41
-
42
- .rRight, .rLeft {
43
- cursor: e-resize;
44
- }
45
-
46
- .rUp, .rDown {
47
- cursor: n-resize;
48
- }
49
-
50
- .rLeftDown {
51
- left: -4px;
52
- bottom: -4px;
53
- }
54
-
55
- .rRightUp {
56
- right: -4px;
57
- top: -4px;
58
- }
59
-
60
- .rRightDown {
61
- right: -4px;
62
- bottom: -4px;
63
- background-color: 0f;
64
- }
65
-
66
- .rLeftUp {
67
- left: -4px;
68
- top: -4px;
69
- }
70
-
71
- .rRight {
72
- right: -4px;
73
- top: 50%;
74
- margin-top: -4px;
75
- }
76
-
77
- .rLeft {
78
- left: -4px;
79
- top: 50%;
80
- margin-top: -4px;
81
- }
82
-
83
- .rUp {
84
- top: -4px;
85
- left: 50%;
86
- margin-left: -4px;
87
- }
88
-
89
- .rDown {
90
- bottom: -4px;
91
- left: 50%;
92
- margin-left: -4px;
93
- }
94
-
95
- .resize-box {
96
- border: 1px solid gray;
97
- width: 100px;
98
- height: 60px;
99
- top: 150px;
100
- left: 550px;
101
- background: #fff;
102
- position: absolute;
103
- }
1
+ <template>
2
+ <!-- 拖拉缩放效果 -->
3
+ <div class="resize-box">
4
+ <div class="rRightDown" @mousedown="start($event, rightDown)"> </div>
5
+ <div class="rLeftDown" @mousedown="start($event, leftDown)"> </div>
6
+ <div class="rRightUp" @mousedown="start($event, rightUp)"> </div>
7
+ <div class="rLeftUp" @mousedown="start($event, leftUp)"> </div>
8
+ <div class="rRight" @mousedown="start($event, right)"> </div>
9
+ <div class="rLeft" @mousedown="start($event, left)"> </div>
10
+ <div class="rDown" @mousedown="start($event, down)"></div>
11
+ <div class="rUp" @mousedown="start($event, up)"> </div>
12
+ </div>
13
+ </template>
14
+
15
+ <script lang="ts" src="./Resize.ts"></script>
16
+
17
+ <style lang="less" scoped>
18
+ .rRightDown,
19
+ .rLeftDown,
20
+ .rLeftUp,
21
+ .rRightUp,
22
+ .rRight,
23
+ .rLeft,
24
+ .rUp,
25
+ .rDown {
26
+ position: absolute;
27
+ background: #c00;
28
+ width: 7px;
29
+ height: 7px;
30
+ z-index: 5;
31
+ font-size: 0;
32
+ }
33
+
34
+ .rLeftDown, .rRightUp {
35
+ cursor: ne-resize;
36
+ }
37
+
38
+ .rRightDown, .rLeftUp {
39
+ cursor: nw-resize;
40
+ }
41
+
42
+ .rRight, .rLeft {
43
+ cursor: e-resize;
44
+ }
45
+
46
+ .rUp, .rDown {
47
+ cursor: n-resize;
48
+ }
49
+
50
+ .rLeftDown {
51
+ left: -4px;
52
+ bottom: -4px;
53
+ }
54
+
55
+ .rRightUp {
56
+ right: -4px;
57
+ top: -4px;
58
+ }
59
+
60
+ .rRightDown {
61
+ right: -4px;
62
+ bottom: -4px;
63
+ background-color: 0f;
64
+ }
65
+
66
+ .rLeftUp {
67
+ left: -4px;
68
+ top: -4px;
69
+ }
70
+
71
+ .rRight {
72
+ right: -4px;
73
+ top: 50%;
74
+ margin-top: -4px;
75
+ }
76
+
77
+ .rLeft {
78
+ left: -4px;
79
+ top: 50%;
80
+ margin-top: -4px;
81
+ }
82
+
83
+ .rUp {
84
+ top: -4px;
85
+ left: 50%;
86
+ margin-left: -4px;
87
+ }
88
+
89
+ .rDown {
90
+ bottom: -4px;
91
+ left: 50%;
92
+ margin-left: -4px;
93
+ }
94
+
95
+ .resize-box {
96
+ border: 1px solid gray;
97
+ width: 100px;
98
+ height: 60px;
99
+ top: 150px;
100
+ left: 550px;
101
+ background: #fff;
102
+ position: absolute;
103
+ }
104
104
  </style>
@@ -1,4 +1,4 @@
1
- <!-- 下拉分类 -->
2
- <template>
3
-
1
+ <!-- 下拉分类 -->
2
+ <template>
3
+
4
4
  </template>