1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-10 01:51:10 +09:00

graph optimisations

This commit is contained in:
Andrew Simachev 2024-01-23 02:33:32 +01:00
parent f248e6a61c
commit 9f8b59d3d7
No known key found for this signature in database
GPG key ID: 49A163D0D14E6FD8

11
dist/workers/graph.js vendored
View file

@ -15,6 +15,7 @@ const util = new Util();
// CONSTANTS
const transformThreshold = 1.5;
const transformThresholdHalf = transformThreshold / 2;
const delayFocus = 1000;
const ObjectLayout = {
@ -406,7 +407,7 @@ drawEdge = (d, arrowWidth, arrowHeight, arrowStart, arrowEnd) => {
// Arrow heads
if ((arrowStart || arrowEnd) && (transform.k >= transformThreshold / 2)) {
if ((arrowStart || arrowEnd) && (transform.k >= transformThresholdHalf)) {
let move = arrowHeight;
if (showName) {
move = arrowHeight * 2 + tw / 2 + offset;
@ -472,7 +473,7 @@ drawNode = (d) => {
lineWidth = getLineWidth() * 3;
};
if (settings.icon && img) {
if (settings.icon && img && (transform.k >= transformThresholdHalf)) {
ctx.save();
if (lineWidth) {
@ -783,7 +784,11 @@ const getNodeByCoords = (x, y) => {
};
const getRadius = (d) => {
return d.radius / transform.k * (settings.icon && images[d.src] ? 2 : 1);
let k = 1;
if (settings.icon && images[d.src] && (transform.k >= transformThresholdHalf)) {
k = 2;
};
return d.radius / transform.k * k;
};
const getFont = () => {