mirror of
https://github.com/zadam/trilium.git
synced 2025-10-06 21:47:31 +08:00
chore(react): reintroduce force configuration
This commit is contained in:
parent
656b234740
commit
5efe05490d
2 changed files with 9 additions and 8 deletions
|
@ -62,10 +62,6 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
|||
this.graph = new ForceGraph(this.$container[0])
|
||||
// Rendering code was here
|
||||
|
||||
const nodeLinkRatio = data.nodes.length / data.links.length;
|
||||
const magnifiedRatio = Math.pow(nodeLinkRatio, 1.5);
|
||||
const charge = -20 / magnifiedRatio;
|
||||
const boundedCharge = Math.min(-3, charge);
|
||||
let distancevalue = 40; // default value for the link force of the nodes
|
||||
|
||||
this.$widget.find(".fixnodes-type-switcher input").on("change", async (e) => {
|
||||
|
@ -75,10 +71,6 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
|||
this.renderData(data);
|
||||
});
|
||||
|
||||
this.graph.d3Force("center")?.strength(0.2);
|
||||
this.graph.d3Force("charge")?.strength(boundedCharge);
|
||||
this.graph.d3Force("charge")?.distanceMax(1000);
|
||||
|
||||
this.renderData(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -176,6 +176,15 @@ export function setupRendering(graph: ForceGraph, { note, noteId, themeStyle, wi
|
|||
.linkCanvasObjectMode(() => "after");
|
||||
}
|
||||
|
||||
// Forces
|
||||
const nodeLinkRatio = notesAndRelations.nodes.length / notesAndRelations.links.length;
|
||||
const magnifiedRatio = Math.pow(nodeLinkRatio, 1.5);
|
||||
const charge = -20 / magnifiedRatio;
|
||||
const boundedCharge = Math.min(-3, charge);
|
||||
graph.d3Force("center")?.strength(0.2);
|
||||
graph.d3Force("charge")?.strength(boundedCharge);
|
||||
graph.d3Force("charge")?.distanceMax(1000);
|
||||
|
||||
// Zoom to notes
|
||||
if (widgetMode === "ribbon" && note?.type !== "search") {
|
||||
setTimeout(() => {
|
||||
|
|
Loading…
Add table
Reference in a new issue