jmgraph 3.2.12 → 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "family": "jmgraph",
3
3
  "name": "jmgraph",
4
- "version": "3.2.12",
4
+ "version": "3.2.13",
5
5
  "description": "一个简单的canvas画图库",
6
6
  "homepage": "http://graph.jm47.com/",
7
7
  "keywords": [
@@ -48,6 +48,7 @@ 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;
51
52
  //this.lockSide = params.lockSide || null;
52
53
 
53
54
  if(params.position) {
@@ -150,6 +151,21 @@ export default class jmControl extends jmProperty {
150
151
  set interactive(v) {
151
152
  return this.property('interactive', v);
152
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
+ }
153
169
 
154
170
  /**
155
171
  * 当前控件的子控件集合
@@ -1136,6 +1152,22 @@ export default class jmControl extends jmProperty {
1136
1152
  }
1137
1153
 
1138
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
+ }
1139
1171
 
1140
1172
  let ps = this.points;
1141
1173
  //如果不是路径组成,则采用边界做为顶点
@@ -1383,8 +1415,8 @@ export default class jmControl extends jmProperty {
1383
1415
  if(_this.__mvMonitor.mouseDown) {
1384
1416
  _this.parent.bounds = null;
1385
1417
  //let parentbounds = _this.parent.getAbsoluteBounds();
1386
- const offsetx = evt.position.offsetX - _this.__mvMonitor.curposition.x;
1387
- const offsety = evt.position.offsetY - _this.__mvMonitor.curposition.y;
1418
+ let offsetx = evt.position.offsetX - _this.__mvMonitor.curposition.x;
1419
+ let offsety = evt.position.offsetY - _this.__mvMonitor.curposition.y;
1388
1420
  //console.log(offsetx + ',' + offsety);
1389
1421
  //如果锁定边界
1390
1422
  if(_this.option.lockSide) {