@yanqirenshi/d3.deployment 0.6.0 → 0.7.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.
Files changed (2) hide show
  1. package/dist/js/Rectum.js +33 -3
  2. package/package.json +1 -1
package/dist/js/Rectum.js CHANGED
@@ -52,13 +52,28 @@ var Rectum = exports["default"] = /*#__PURE__*/function (_Colon) {
52
52
  EDGE: new _Edges["default"](),
53
53
  PORT: new _Ports["default"]()
54
54
  };
55
+
56
+ // コールバック(任意)。描画は行わず通知のみ
57
+ // (インスペクタ等の外部ツールはこの通知に接続する)
58
+ _this._callbacks = _this.initCallbacks(params);
55
59
  return _this;
56
60
  }
57
- /* ******** */
58
- /* Getter */
59
- /* ******** */
60
61
  _inherits(Rectum, _Colon);
61
62
  return _createClass(Rectum, [{
63
+ key: "initCallbacks",
64
+ value: function initCallbacks(params) {
65
+ var callbacks = params && params.callbacks || {};
66
+ var node = callbacks.node || {};
67
+ return {
68
+ node: {
69
+ click: node.click || null
70
+ }
71
+ };
72
+ }
73
+ /* ******** */
74
+ /* Getter */
75
+ /* ******** */
76
+ }, {
62
77
  key: "node",
63
78
  value: function node() {
64
79
  return this._node;
@@ -403,6 +418,21 @@ var Rectum = exports["default"] = /*#__PURE__*/function (_Colon) {
403
418
  _iterator8.f();
404
419
  }
405
420
  this.attachNodeDrag(place, data);
421
+ this.attachNodeClick(place);
422
+ }
423
+ /**
424
+ * ノードのクリック通知(callbacks.node.click)。
425
+ * d3.drag は移動を伴ったクリックを抑止するため、静止クリックだけが届く。
426
+ */
427
+ }, {
428
+ key: "attachNodeClick",
429
+ value: function attachNodeClick(place) {
430
+ var callback = this._callbacks.node.click;
431
+ if (!callback) return;
432
+ place.selectAll('g.node, g.component').on('click', function (event, d) {
433
+ event.stopPropagation();
434
+ callback(d);
435
+ });
406
436
  }
407
437
  ///// ////////////////////////////////////////////////////////////////
408
438
  ///// Drag (grab + drag でノードを移動)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yanqirenshi/d3.deployment",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "See [Documents](https://yanqirenshi.github.io/D3.Deployment/)",
5
5
  "main": "dist/index.js",
6
6
  "directories": {