From e67fffa799a1847c87c3e5f8712d571ab830f2a0 Mon Sep 17 00:00:00 2001 From: crusader Date: Wed, 12 Sep 2018 22:48:20 +0900 Subject: [PATCH] ing --- src/app/pages/home/home-page.component.html | 3 ++- src/app/pages/home/home-page.component.ts | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) 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; } }) );