diff --git a/src/app/pages/home/home-page.component.html b/src/app/pages/home/home-page.component.html index 162446e..ee8734d 100644 --- a/src/app/pages/home/home-page.component.html +++ b/src/app/pages/home/home-page.component.html @@ -21,7 +21,8 @@ - + diff --git a/src/app/pages/home/home-page.component.ts b/src/app/pages/home/home-page.component.ts index efd82a1..5c5e937 100644 --- a/src/app/pages/home/home-page.component.ts +++ b/src/app/pages/home/home-page.component.ts @@ -240,6 +240,10 @@ export class HomePageComponent implements OnInit, OnDestroy { d3.select(this.discoveryTargetRef.nativeElement).selectAll('.node-container').call( d3.drag() .on('start', function () { + const container = d3.select(this); + const nodeId = container.attr('nodeId'); + const node = __this.getNode(nodeId); + d3.event.sourceEvent.stopPropagation(); if (!d3.event.active) { @@ -248,14 +252,18 @@ export class HomePageComponent implements OnInit, OnDestroy { d3.event.on('drag', dragged).on('end', ended); - function dragged() { - d3.select(this).attr('cx', d3.event.x).attr('cy', d3.event.y); + function dragged(d, i) { + node.fx = d3.event.x; + node.fy = d3.event.y; } function ended() { if (!d3.event.active) { __this.simulation.alphaTarget(0); } + + node.fx = null; + node.fy = null; } }) );