ing
This commit is contained in:
parent
57258305cb
commit
b9df48a54c
|
@ -178,43 +178,62 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
;
|
||||
}
|
||||
|
||||
simulationRestart() {
|
||||
simulationRestart(attachEvent: boolean = false) {
|
||||
// Update and restart the simulation.
|
||||
|
||||
if (attachEvent) {
|
||||
const __this = this;
|
||||
|
||||
function started(node: Node) {
|
||||
/** Preventing propagation of dragstart to parent elements */
|
||||
d3.event.sourceEvent.stopPropagation();
|
||||
// function started(node: Node) {
|
||||
// /** Preventing propagation of dragstart to parent elements */
|
||||
// d3.event.sourceEvent.stopPropagation();
|
||||
|
||||
if (!d3.event.active) {
|
||||
__this.simulation.alphaTarget(0.3).restart();
|
||||
}
|
||||
// if (!d3.event.active) {
|
||||
// __this.simulation.alphaTarget(0.3).restart();
|
||||
// }
|
||||
|
||||
d3.event.on('drag', dragged).on('end', ended);
|
||||
// d3.event.on('drag', dragged).on('end', ended);
|
||||
|
||||
function dragged() {
|
||||
if (undefined === node) {
|
||||
return;
|
||||
}
|
||||
// function dragged() {
|
||||
// if (undefined === node) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
node.fx = d3.event.x;
|
||||
node.fy = d3.event.y;
|
||||
}
|
||||
// node.fx = d3.event.x;
|
||||
// node.fy = d3.event.y;
|
||||
// }
|
||||
|
||||
function ended() {
|
||||
if (!d3.event.active) {
|
||||
__this.simulation.alphaTarget(0);
|
||||
}
|
||||
// function ended() {
|
||||
// if (!d3.event.active) {
|
||||
// __this.simulation.alphaTarget(0);
|
||||
// }
|
||||
|
||||
if (undefined === node) {
|
||||
return;
|
||||
}
|
||||
node.fx = null;
|
||||
node.fy = null;
|
||||
}
|
||||
}
|
||||
// if (undefined === node) {
|
||||
// return;
|
||||
// }
|
||||
// node.fx = null;
|
||||
// node.fy = null;
|
||||
// }
|
||||
// }
|
||||
|
||||
d3.select(this.discoveryTargetRef.nativeElement).selectAll('.node-container').call(d3.drag().on('start', started));
|
||||
// d3.select(this.discoveryTargetRef.nativeElement).selectAll('.node-container').call(d3.drag().on('start', started));
|
||||
|
||||
// d3.drag()
|
||||
// .on('dragstart', (node: Node, i: number) => {
|
||||
// __this.simulation.stop();
|
||||
// })
|
||||
// .on('drag', (node: Node, i: number) => {
|
||||
// node.fx += d3.event.dx;
|
||||
// node.fy += d3.event.dy;
|
||||
// node.x += d3.event.dx;
|
||||
// node.y += d3.event.dy;
|
||||
// })
|
||||
// .on('dragend', (node: Node, i: number) => {
|
||||
// __this.simulation.stop();
|
||||
// })
|
||||
// ;
|
||||
|
||||
}
|
||||
|
||||
this.simulation
|
||||
.nodes(this.nodes)
|
||||
|
@ -270,6 +289,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
public DiscoveryStop(stopDate: Date) {
|
||||
console.log('DiscoveryStop', stopDate);
|
||||
this.discoveryConfigService.setStarted(false);
|
||||
this.simulationRestart(true);
|
||||
// this.simulation.stop();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user