add graph layout to fluid zoom
This commit is contained in:
parent
69efdd1709
commit
a090729f14
|
|
@ -69,9 +69,7 @@ export class FolkGraph extends FolkBaseSet implements AnimationFrameControllerHo
|
|||
const colaNodes = this.#createNodes();
|
||||
const colaLinks = this.#createLinks();
|
||||
|
||||
console.log(colaNodes, colaLinks);
|
||||
|
||||
this.#graphSim.nodes(colaNodes).links(colaLinks).linkDistance(250).avoidOverlaps(true).handleDisconnected(true);
|
||||
this.#graphSim.nodes(colaNodes).links(colaLinks).linkDistance(400).avoidOverlaps(true).handleDisconnected(true);
|
||||
}
|
||||
|
||||
#createNodes() {
|
||||
|
|
@ -93,7 +91,7 @@ export class FolkGraph extends FolkBaseSet implements AnimationFrameControllerHo
|
|||
|
||||
#createLinks() {
|
||||
return Array.from(this.sourceElements)
|
||||
.filter((element): element is FolkBaseConnection => element instanceof FolkBaseConnection)
|
||||
.filter((element) => element instanceof FolkBaseConnection)
|
||||
.map((arrow) => {
|
||||
this.#arrows.add(arrow);
|
||||
const source = this.#nodes.get(arrow.sourceElement as FolkShape);
|
||||
|
|
|
|||
|
|
@ -78,14 +78,15 @@
|
|||
<input type="range" min="0" max="1" value="1" step="0.01" />
|
||||
</label>
|
||||
|
||||
<folk-graph>
|
||||
<folk-shape id="box1" x="100" y="100">
|
||||
<h2>Lorem ispum</h2>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
||||
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
||||
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
||||
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
||||
laborum.
|
||||
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
|
||||
est laborum.
|
||||
</p>
|
||||
</folk-shape>
|
||||
|
||||
|
|
@ -109,10 +110,12 @@
|
|||
<folk-arrow source="#box1" target="#box2"></folk-arrow>
|
||||
<folk-arrow source="#box2" target="#box3"></folk-arrow>
|
||||
<folk-arrow source="#box1" target="#box3"></folk-arrow>
|
||||
</folk-graph>
|
||||
|
||||
<script type="module">
|
||||
import '@labs/standalone/folk-shape.ts';
|
||||
import '@labs/standalone/folk-arrow.ts';
|
||||
import '@labs/standalone/folk-graph.ts';
|
||||
|
||||
const range = document.querySelector('input');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue