mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-14 18:38:11 +02:00
Fix graph crash on reload, even out depth sizes
This commit is contained in:
1 parent
0372a73dd2
commit
d616361c2f
3 files changed
+27
-13
No files matched your search
@@ -20,8 +20,11 @@ const LabelZoom = 0.7; // below this, only hovered labels are drawn
|
||||
const ClickSlop = 4; // pixels a click may wander and still count as a click
|
||||
// Directories by depth, like the headings: h1 Purple, h2 Blue, ...
|
||||
const DepthRoles = ["Purple", "Blue", "Green", "Yellow", "Orange", "Red"];
|
||||
const ShrinkPerDepth = 0.8; // with ShrinkByDepth, each level's directory dots are this much smaller
|
||||
const SmallestDirectory = 3; // ...but never smaller than a file's dot
|
||||
// With ShrinkByDepth, directory dots shrink in even steps from their usual
|
||||
// size to a file dot's size (a file with one link) at this depth (the red
|
||||
// ones), and stay that size below it.
|
||||
const ShrinkDepth = 5;
|
||||
const FileDotRadius = 3.8;
|
||||
|
||||
function ReadRole(Name) {
|
||||
return getComputedStyle(document.documentElement).getPropertyValue(`--${Name}`).trim();
|
||||
@@ -206,7 +209,8 @@ export default function GraphPane({
|
||||
}
|
||||
Node.Colour = ColourByDepth ? DepthColours[Depth % DepthColours.length] : Colours.Directory;
|
||||
if (ShrinkByDepth) {
|
||||
Node.Radius = Math.max(SmallestDirectory, Node.Radius * Math.pow(ShrinkPerDepth, Depth));
|
||||
const Step = Math.min(Depth, ShrinkDepth) / ShrinkDepth;
|
||||
Node.Radius += (FileDotRadius - Node.Radius) * Step;
|
||||
}
|
||||
}
|
||||
// Anything but "Left" (including an old "Middle") pans with Right.
|
||||
|
||||
Reference in new issue
Block a user