This commit is contained in:
crusader 2018-09-12 22:48:20 +09:00
parent 1b5fe6fdcd
commit e67fffa799
2 changed files with 12 additions and 3 deletions

View File

@ -21,7 +21,8 @@
<line class="link" [attr.x1]="link.source.x" [attr.y1]="link.source.y" [attr.x2]="link.target.x" [attr.y2]="link.target.y"></line> <line class="link" [attr.x1]="link.source.x" [attr.y1]="link.source.y" [attr.x2]="link.target.x" [attr.y2]="link.target.y"></line>
</g> </g>
<g *ngFor="let node of nodes"> <g *ngFor="let node of nodes">
<g class="node-container" [attr.transform]="'translate(' + node.x + ',' + node.y + ')'" (click)="onTargetClick(node)"> <g class="node-container" [attr.nodeId]="node.id" [attr.transform]="'translate(' + node.x + ',' + node.y + ')'"
(click)="onTargetClick(node)">
<g *ngIf="node.group === 'zone'"> <g *ngIf="node.group === 'zone'">
<image [attr.x]="-node.r" [attr.y]="-node.r" [attr.width]="node.r * 2" [attr.height]="node.r * 2" <image [attr.x]="-node.r" [attr.y]="-node.r" [attr.width]="node.r * 2" [attr.height]="node.r * 2"
xlink:href="../../assets/image/icon/icon_overflow.svg"></image> xlink:href="../../assets/image/icon/icon_overflow.svg"></image>

View File

@ -240,6 +240,10 @@ export class HomePageComponent implements OnInit, OnDestroy {
d3.select(this.discoveryTargetRef.nativeElement).selectAll('.node-container').call( d3.select(this.discoveryTargetRef.nativeElement).selectAll('.node-container').call(
d3.drag() d3.drag()
.on('start', function () { .on('start', function () {
const container = d3.select(this);
const nodeId = container.attr('nodeId');
const node = __this.getNode(nodeId);
d3.event.sourceEvent.stopPropagation(); d3.event.sourceEvent.stopPropagation();
if (!d3.event.active) { if (!d3.event.active) {
@ -248,14 +252,18 @@ export class HomePageComponent implements OnInit, OnDestroy {
d3.event.on('drag', dragged).on('end', ended); d3.event.on('drag', dragged).on('end', ended);
function dragged() { function dragged(d, i) {
d3.select(this).attr('cx', d3.event.x).attr('cy', d3.event.y); node.fx = d3.event.x;
node.fy = d3.event.y;
} }
function ended() { function ended() {
if (!d3.event.active) { if (!d3.event.active) {
__this.simulation.alphaTarget(0); __this.simulation.alphaTarget(0);
} }
node.fx = null;
node.fy = null;
} }
}) })
); );