jmgraph 3.2.11 → 3.2.13
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/dist/jmgraph.core.min.js +1 -1
- package/dist/jmgraph.core.min.js.map +1 -1
- package/dist/jmgraph.js +55 -12
- package/dist/jmgraph.min.js +1 -1
- package/package.json +1 -1
- package/src/core/jmControl.js +48 -11
- package/src/core/jmGraph.js +5 -1
package/package.json
CHANGED
package/src/core/jmControl.js
CHANGED
|
@@ -48,6 +48,8 @@ export default class jmControl extends jmProperty {
|
|
|
48
48
|
//this.position = params.position || {x:0,y:0};
|
|
49
49
|
this.width = params.width || 0;
|
|
50
50
|
this.height = params.height || 0;
|
|
51
|
+
this.hitArea = params.hitArea || null;
|
|
52
|
+
//this.lockSide = params.lockSide || null;
|
|
51
53
|
|
|
52
54
|
if(params.position) {
|
|
53
55
|
this.position = params.position;
|
|
@@ -149,6 +151,21 @@ export default class jmControl extends jmProperty {
|
|
|
149
151
|
set interactive(v) {
|
|
150
152
|
return this.property('interactive', v);
|
|
151
153
|
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 事件命中区域,如果不给定就会自动计算
|
|
157
|
+
* 这个区域是相对于当前控件本身的,也就是说从左上角开始 {x:0,y:0}
|
|
158
|
+
* @property hitArea
|
|
159
|
+
* @default bounds
|
|
160
|
+
* @type { x: number, y: number, width: number, height: number}
|
|
161
|
+
*/
|
|
162
|
+
get hitArea() {
|
|
163
|
+
const s = this.property('hitArea');
|
|
164
|
+
return s;
|
|
165
|
+
}
|
|
166
|
+
set hitArea(v) {
|
|
167
|
+
return this.property('hitArea', v);
|
|
168
|
+
}
|
|
152
169
|
|
|
153
170
|
/**
|
|
154
171
|
* 当前控件的子控件集合
|
|
@@ -1125,16 +1142,32 @@ export default class jmControl extends jmProperty {
|
|
|
1125
1142
|
// 由于高清屏会有放大坐标,所以这里用pagex就只能用真实的canvas大小
|
|
1126
1143
|
const right = position.left + this.width;
|
|
1127
1144
|
const bottom = position.top + this.height;
|
|
1128
|
-
if(p.
|
|
1145
|
+
if(p.x > right || p.x < position.left) {
|
|
1129
1146
|
return false;
|
|
1130
1147
|
}
|
|
1131
|
-
if(p.
|
|
1148
|
+
if(p.y > bottom || p.y < position.top) {
|
|
1132
1149
|
return false;
|
|
1133
1150
|
}
|
|
1134
1151
|
return true;
|
|
1135
1152
|
}
|
|
1136
1153
|
|
|
1137
1154
|
const bounds = this.getBounds();
|
|
1155
|
+
// 如果指定了合中区域,则以命中区域为准
|
|
1156
|
+
if(this.hitArea) {
|
|
1157
|
+
const hitArea = {
|
|
1158
|
+
left: this.hitArea.x + bounds.left,
|
|
1159
|
+
top: this.hitArea.y + bounds.top,
|
|
1160
|
+
right: this.hitArea.width + bounds.left,
|
|
1161
|
+
bottom: this.hitArea.height + bounds.top,
|
|
1162
|
+
};
|
|
1163
|
+
if(p.x > hitArea.right || p.x < hitArea.left) {
|
|
1164
|
+
return false;
|
|
1165
|
+
}
|
|
1166
|
+
if(p.y > hitArea.bottom || p.y < hitArea.top) {
|
|
1167
|
+
return false;
|
|
1168
|
+
}
|
|
1169
|
+
return true;
|
|
1170
|
+
}
|
|
1138
1171
|
|
|
1139
1172
|
let ps = this.points;
|
|
1140
1173
|
//如果不是路径组成,则采用边界做为顶点
|
|
@@ -1381,33 +1414,37 @@ export default class jmControl extends jmProperty {
|
|
|
1381
1414
|
|
|
1382
1415
|
if(_this.__mvMonitor.mouseDown) {
|
|
1383
1416
|
_this.parent.bounds = null;
|
|
1384
|
-
let parentbounds = _this.parent.getAbsoluteBounds();
|
|
1417
|
+
//let parentbounds = _this.parent.getAbsoluteBounds();
|
|
1385
1418
|
let offsetx = evt.position.offsetX - _this.__mvMonitor.curposition.x;
|
|
1386
1419
|
let offsety = evt.position.offsetY - _this.__mvMonitor.curposition.y;
|
|
1387
1420
|
//console.log(offsetx + ',' + offsety);
|
|
1388
1421
|
//如果锁定边界
|
|
1389
|
-
if(_this.lockSide) {
|
|
1422
|
+
if(_this.option.lockSide) {
|
|
1390
1423
|
let thisbounds = _this.bounds || _this.getAbsoluteBounds();
|
|
1391
1424
|
//检查边界出界
|
|
1392
|
-
let outside = jmUtils.checkOutSide(
|
|
1425
|
+
let outside = jmUtils.checkOutSide(_this.option.lockSide, thisbounds, { x: offsetx, y: offsety });
|
|
1393
1426
|
if(outside.left < 0) {
|
|
1394
|
-
|
|
1427
|
+
//offsetx -= outside.left;
|
|
1428
|
+
offsetx = 0;
|
|
1395
1429
|
}
|
|
1396
1430
|
else if(outside.right > 0) {
|
|
1397
|
-
|
|
1431
|
+
//offsetx -= outside.right;
|
|
1432
|
+
offsetx = 0;
|
|
1398
1433
|
}
|
|
1399
1434
|
if(outside.top < 0) {
|
|
1400
|
-
|
|
1435
|
+
//offsety -= outside.top;
|
|
1436
|
+
offsety = 0;
|
|
1401
1437
|
}
|
|
1402
1438
|
else if(outside.bottom > 0) {
|
|
1403
|
-
|
|
1439
|
+
//offsety -= outside.bottom;
|
|
1440
|
+
offsety = 0;
|
|
1404
1441
|
}
|
|
1405
1442
|
}
|
|
1406
1443
|
|
|
1407
1444
|
if(offsetx || offsety) {
|
|
1408
1445
|
_this.offset(offsetx, offsety, true, evt);
|
|
1409
|
-
_this.__mvMonitor.curposition.x = evt.position.offsetX;
|
|
1410
|
-
_this.__mvMonitor.curposition.y = evt.position.offsetY;
|
|
1446
|
+
if(offsetx) _this.__mvMonitor.curposition.x = evt.position.offsetX;
|
|
1447
|
+
if(offsety) _this.__mvMonitor.curposition.y = evt.position.offsetY;
|
|
1411
1448
|
//console.log(offsetx + '.' + offsety);
|
|
1412
1449
|
}
|
|
1413
1450
|
return false;
|
package/src/core/jmGraph.js
CHANGED
|
@@ -226,7 +226,11 @@ export default class jmGraph extends jmControl {
|
|
|
226
226
|
* @return {postion} 返回定位坐标
|
|
227
227
|
*/
|
|
228
228
|
getPosition() {
|
|
229
|
-
const p =
|
|
229
|
+
const p = this.isWXMiniApp? {
|
|
230
|
+
left: 0,
|
|
231
|
+
top: 0
|
|
232
|
+
} :jmUtils.getElementPosition(this.canvas.canvas || this.canvas);
|
|
233
|
+
|
|
230
234
|
p.width = this.width;
|
|
231
235
|
p.height = this.height;
|
|
232
236
|
p.right = p.left + p.width;
|