@yanqirenshi/d3.deployment 0.5.0 → 0.5.1

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/js/Rectum.js CHANGED
@@ -415,12 +415,19 @@ var Rectum = exports["default"] = /*#__PURE__*/function (_Colon) {
415
415
  key: "attachNodeDrag",
416
416
  value: function attachNodeDrag(place, data) {
417
417
  var self = this;
418
- var drag = d3.drag().on('start', function () {
419
- d3.select(this).style('cursor', 'grabbing');
418
+
419
+ // d3 コールバック内で `this`(= DOM 要素)に依存しない。
420
+ // Next.js(Webpack/SWC)のトランスパイルで `this` が書き換わり得るため、
421
+ // 掴んだ要素は sourceEvent から closest() で取り、クロージャで保持する。
422
+ var grabbed = null;
423
+ var drag = d3.drag().on('start', function (event) {
424
+ grabbed = event.sourceEvent.target.closest('g.node, g.component');
425
+ if (grabbed) grabbed.style.cursor = 'grabbing';
420
426
  }).on('drag', function (event, node) {
421
427
  self.moveSubtree(place, data, node, event.dx, event.dy);
422
428
  }).on('end', function () {
423
- d3.select(this).style('cursor', 'grab');
429
+ if (grabbed) grabbed.style.cursor = 'grab';
430
+ grabbed = null;
424
431
  });
425
432
  place.selectAll('g.node, g.component').style('cursor', 'grab').call(drag);
426
433
  }
@@ -31,8 +31,12 @@ var Edges = exports["default"] = /*#__PURE__*/function () {
31
31
  key: "redraw",
32
32
  value: function redraw(place, data) {
33
33
  var id = String(data._id);
34
- var path = place.selectAll('path.edge').filter(function () {
35
- return this.getAttribute('data-edge-id') === id;
34
+
35
+ // d3 コールバック内では `this`(= DOM 要素)に依存しない。
36
+ // Next.js(Webpack/SWC)などのトランスパイル環境で `this` が
37
+ // 書き換わり得るため、引数 (d, i, nodes) の nodes[i] で要素へアクセスする。
38
+ var path = place.selectAll('path.edge').filter(function (d, i, nodes) {
39
+ return nodes[i].getAttribute('data-edge-id') === id;
36
40
  });
37
41
  if (!path.empty()) this.applyGeometry(path, data);
38
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yanqirenshi/d3.deployment",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "See [Documents](https://yanqirenshi.github.io/D3.Deployment/)",
5
5
  "main": "dist/index.js",
6
6
  "directories": {