mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-09 09:35:02 +09:00
Link distance and node radius updates
This commit is contained in:
parent
351944e1bb
commit
d3dcc58ff7
1 changed files with 18 additions and 1 deletions
19
dist/workers/graph.js
vendored
19
dist/workers/graph.js
vendored
|
@ -82,6 +82,7 @@ let rootId = '';
|
|||
let root = null;
|
||||
let paused = false;
|
||||
let isOver = '';
|
||||
let maxEdges = 0;
|
||||
|
||||
addEventListener('message', ({ data }) => {
|
||||
if (this[data.id]) {
|
||||
|
@ -170,7 +171,8 @@ initForces = () => {
|
|||
|
||||
simulation.force('link')
|
||||
.links(edges)
|
||||
.distance(link.distance);
|
||||
.distance(link.distance)
|
||||
.strength(d => d.source.layout == d.target.layout ? 1 : 0.5);
|
||||
|
||||
simulation.force('forceX')
|
||||
.strength(d => d.isOrphan ? forceX.strength : 0)
|
||||
|
@ -788,6 +790,21 @@ const getRadius = (d) => {
|
|||
if (settings.icon && images[d.src] && (transform.k >= transformThresholdHalf)) {
|
||||
k = 2;
|
||||
};
|
||||
|
||||
let e = 0;
|
||||
if (settings.link) {
|
||||
e += d.linkCnt
|
||||
};
|
||||
if (settings.relation) {
|
||||
e += d.relationCnt;
|
||||
};
|
||||
|
||||
maxEdges = Math.max(maxEdges, e);
|
||||
|
||||
if (maxEdges > 0) {
|
||||
k += e / maxEdges;
|
||||
};
|
||||
|
||||
return d.radius / transform.k * k;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue