ing
This commit is contained in:
parent
57258305cb
commit
b9df48a54c
|
@ -178,44 +178,63 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
;
|
||||
}
|
||||
|
||||
simulationRestart() {
|
||||
simulationRestart(attachEvent: boolean = false) {
|
||||
// Update and restart the simulation.
|
||||
const __this = this;
|
||||
|
||||
function started(node: Node) {
|
||||
/** Preventing propagation of dragstart to parent elements */
|
||||
d3.event.sourceEvent.stopPropagation();
|
||||
if (attachEvent) {
|
||||
const __this = this;
|
||||
|
||||
if (!d3.event.active) {
|
||||
__this.simulation.alphaTarget(0.3).restart();
|
||||
}
|
||||
// function started(node: Node) {
|
||||
// /** Preventing propagation of dragstart to parent elements */
|
||||
// d3.event.sourceEvent.stopPropagation();
|
||||
|
||||
d3.event.on('drag', dragged).on('end', ended);
|
||||
// if (!d3.event.active) {
|
||||
// __this.simulation.alphaTarget(0.3).restart();
|
||||
// }
|
||||
|
||||
function dragged() {
|
||||
if (undefined === node) {
|
||||
return;
|
||||
}
|
||||
// d3.event.on('drag', dragged).on('end', ended);
|
||||
|
||||
node.fx = d3.event.x;
|
||||
node.fy = d3.event.y;
|
||||
}
|
||||
// function dragged() {
|
||||
// if (undefined === node) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
function ended() {
|
||||
if (!d3.event.active) {
|
||||
__this.simulation.alphaTarget(0);
|
||||
}
|
||||
// node.fx = d3.event.x;
|
||||
// node.fy = d3.event.y;
|
||||
// }
|
||||
|
||||
// function ended() {
|
||||
// if (!d3.event.active) {
|
||||
// __this.simulation.alphaTarget(0);
|
||||
// }
|
||||
|
||||
// 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.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();
|
||||
// })
|
||||
// ;
|
||||
|
||||
if (undefined === node) {
|
||||
return;
|
||||
}
|
||||
node.fx = null;
|
||||
node.fy = null;
|
||||
}
|
||||
}
|
||||
|
||||
d3.select(this.discoveryTargetRef.nativeElement).selectAll('.node-container').call(d3.drag().on('start', started));
|
||||
|
||||
this.simulation
|
||||
.nodes(this.nodes)
|
||||
.force('link', d3.forceLink(this.links).distance(150))
|
||||
|
@ -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