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.js CHANGED
@@ -275,6 +275,9 @@ var jmControl = exports.jmControl = exports["default"] = /*#__PURE__*/function (
275
275
  //this.position = params.position || {x:0,y:0};
276
276
  _this2.width = params.width || 0;
277
277
  _this2.height = params.height || 0;
278
+ _this2.hitArea = params.hitArea || null;
279
+ //this.lockSide = params.lockSide || null;
280
+
278
281
  if (params.position) {
279
282
  _this2.position = params.position;
280
283
  }
@@ -383,6 +386,23 @@ var jmControl = exports.jmControl = exports["default"] = /*#__PURE__*/function (
383
386
  return this.property('interactive', v);
384
387
  }
385
388
 
389
+ /**
390
+ * 事件命中区域,如果不给定就会自动计算
391
+ * 这个区域是相对于当前控件本身的,也就是说从左上角开始 {x:0,y:0}
392
+ * @property hitArea
393
+ * @default bounds
394
+ * @type { x: number, y: number, width: number, height: number}
395
+ */
396
+ }, {
397
+ key: "hitArea",
398
+ get: function get() {
399
+ var s = this.property('hitArea');
400
+ return s;
401
+ },
402
+ set: function set(v) {
403
+ return this.property('hitArea', v);
404
+ }
405
+
386
406
  /**
387
407
  * 当前控件的子控件集合
388
408
  * @property children
@@ -1406,15 +1426,31 @@ var jmControl = exports.jmControl = exports["default"] = /*#__PURE__*/function (
1406
1426
  // 由于高清屏会有放大坐标,所以这里用pagex就只能用真实的canvas大小
1407
1427
  var right = position.left + this.width;
1408
1428
  var bottom = position.top + this.height;
1409
- if (p.pageX > right || p.pageX < position.left) {
1429
+ if (p.x > right || p.x < position.left) {
1410
1430
  return false;
1411
1431
  }
1412
- if (p.pageY > bottom || p.pageY < position.top) {
1432
+ if (p.y > bottom || p.y < position.top) {
1413
1433
  return false;
1414
1434
  }
1415
1435
  return true;
1416
1436
  }
1417
1437
  var bounds = this.getBounds();
1438
+ // 如果指定了合中区域,则以命中区域为准
1439
+ if (this.hitArea) {
1440
+ var hitArea = {
1441
+ left: this.hitArea.x + bounds.left,
1442
+ top: this.hitArea.y + bounds.top,
1443
+ right: this.hitArea.width + bounds.left,
1444
+ bottom: this.hitArea.height + bounds.top
1445
+ };
1446
+ if (p.x > hitArea.right || p.x < hitArea.left) {
1447
+ return false;
1448
+ }
1449
+ if (p.y > hitArea.bottom || p.y < hitArea.top) {
1450
+ return false;
1451
+ }
1452
+ return true;
1453
+ }
1418
1454
  var ps = this.points;
1419
1455
  //如果不是路径组成,则采用边界做为顶点
1420
1456
  if (!ps || !ps.length) {
@@ -1672,33 +1708,37 @@ var jmControl = exports.jmControl = exports["default"] = /*#__PURE__*/function (
1672
1708
 
1673
1709
  if (_this.__mvMonitor.mouseDown) {
1674
1710
  _this.parent.bounds = null;
1675
- var parentbounds = _this.parent.getAbsoluteBounds();
1711
+ //let parentbounds = _this.parent.getAbsoluteBounds();
1676
1712
  var offsetx = evt.position.offsetX - _this.__mvMonitor.curposition.x;
1677
1713
  var offsety = evt.position.offsetY - _this.__mvMonitor.curposition.y;
1678
1714
  //console.log(offsetx + ',' + offsety);
1679
1715
  //如果锁定边界
1680
- if (_this.lockSide) {
1716
+ if (_this.option.lockSide) {
1681
1717
  var thisbounds = _this.bounds || _this.getAbsoluteBounds();
1682
1718
  //检查边界出界
1683
- var outside = _jmUtils.jmUtils.checkOutSide(parentbounds, thisbounds, {
1719
+ var outside = _jmUtils.jmUtils.checkOutSide(_this.option.lockSide, thisbounds, {
1684
1720
  x: offsetx,
1685
1721
  y: offsety
1686
1722
  });
1687
1723
  if (outside.left < 0) {
1688
- if (_this.lockSide.left) offsetx -= outside.left;
1724
+ //offsetx -= outside.left;
1725
+ offsetx = 0;
1689
1726
  } else if (outside.right > 0) {
1690
- if (_this.lockSide.right) offsetx -= outside.right;
1727
+ //offsetx -= outside.right;
1728
+ offsetx = 0;
1691
1729
  }
1692
1730
  if (outside.top < 0) {
1693
- if (_this.lockSide.top) offsety -= outside.top;
1731
+ //offsety -= outside.top;
1732
+ offsety = 0;
1694
1733
  } else if (outside.bottom > 0) {
1695
- if (_this.lockSide.bottom) offsety -= outside.bottom;
1734
+ //offsety -= outside.bottom;
1735
+ offsety = 0;
1696
1736
  }
1697
1737
  }
1698
1738
  if (offsetx || offsety) {
1699
1739
  _this.offset(offsetx, offsety, true, evt);
1700
- _this.__mvMonitor.curposition.x = evt.position.offsetX;
1701
- _this.__mvMonitor.curposition.y = evt.position.offsetY;
1740
+ if (offsetx) _this.__mvMonitor.curposition.x = evt.position.offsetX;
1741
+ if (offsety) _this.__mvMonitor.curposition.y = evt.position.offsetY;
1702
1742
  //console.log(offsetx + '.' + offsety);
1703
1743
  }
1704
1744
  return false;
@@ -2610,7 +2650,10 @@ var jmGraph = exports.jmGraph = exports["default"] = /*#__PURE__*/function (_jmC
2610
2650
  * @return {postion} 返回定位坐标
2611
2651
  */
2612
2652
  function getPosition() {
2613
- var p = _jmUtils.jmUtils.getElementPosition(this.canvas.canvas || this.canvas);
2653
+ var p = this.isWXMiniApp ? {
2654
+ left: 0,
2655
+ top: 0
2656
+ } : _jmUtils.jmUtils.getElementPosition(this.canvas.canvas || this.canvas);
2614
2657
  p.width = this.width;
2615
2658
  p.height = this.height;
2616
2659
  p.right = p.left + p.width;