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.
|
// Update and restart the simulation.
|
||||||
const __this = this;
|
|
||||||
|
|
||||||
function started(node: Node) {
|
if (attachEvent) {
|
||||||
/** Preventing propagation of dragstart to parent elements */
|
const __this = this;
|
||||||
d3.event.sourceEvent.stopPropagation();
|
|
||||||
|
|
||||||
if (!d3.event.active) {
|
// function started(node: Node) {
|
||||||
__this.simulation.alphaTarget(0.3).restart();
|
// /** 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() {
|
// d3.event.on('drag', dragged).on('end', ended);
|
||||||
if (undefined === node) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
node.fx = d3.event.x;
|
// function dragged() {
|
||||||
node.fy = d3.event.y;
|
// if (undefined === node) {
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
function ended() {
|
// node.fx = d3.event.x;
|
||||||
if (!d3.event.active) {
|
// node.fy = d3.event.y;
|
||||||
__this.simulation.alphaTarget(0);
|
// }
|
||||||
}
|
|
||||||
|
// 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
|
this.simulation
|
||||||
.nodes(this.nodes)
|
.nodes(this.nodes)
|
||||||
.force('link', d3.forceLink(this.links).distance(150))
|
.force('link', d3.forceLink(this.links).distance(150))
|
||||||
|
@ -270,6 +289,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
||||||
public DiscoveryStop(stopDate: Date) {
|
public DiscoveryStop(stopDate: Date) {
|
||||||
console.log('DiscoveryStop', stopDate);
|
console.log('DiscoveryStop', stopDate);
|
||||||
this.discoveryConfigService.setStarted(false);
|
this.discoveryConfigService.setStarted(false);
|
||||||
|
this.simulationRestart(true);
|
||||||
// this.simulation.stop();
|
// this.simulation.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user