Simplify link path

This commit is contained in:
barsdeveloper
2022-02-19 23:50:51 +01:00
parent 55b12bac0c
commit d2f7de4f88
2 changed files with 7 additions and 17 deletions

13
dist/ueblueprint.js vendored
View File

@@ -1586,13 +1586,10 @@ class LinkTemplate extends Template {
link.style.setProperty("--ueb-to-y", sanitizeText(link.destinationLocation[1])); link.style.setProperty("--ueb-to-y", sanitizeText(link.destinationLocation[1]));
link.style.setProperty("margin-left", `-${start}px`); link.style.setProperty("margin-left", `-${start}px`);
} }
let c1 = 15; if (xInverted) {
if (!xInverted) { start = start + dx;
c1 = start + c1 * fillRatio;
} else {
start = start + fillRatio * 100;
c1 = start + c1 * fillRatio;
} }
const c1 = start + 15 * fillRatio;
let c2 = Math.max(40 / aspectRatio, 30) + start; let c2 = Math.max(40 / aspectRatio, 30) + start;
const c2Decreasing = -0.05; const c2Decreasing = -0.05;
const getMaxC2 = (m, p) => { const getMaxC2 = (m, p) => {
@@ -1601,9 +1598,7 @@ class LinkTemplate extends Template {
return x => a / x + q return x => a / x + q
}; };
const controlPoint = [500, 140]; const controlPoint = [500, 140];
if (xInverted) { c2 = Math.min(c2, getMaxC2(c2Decreasing, controlPoint)(width));
c2 = Math.min(c2, getMaxC2(c2Decreasing, controlPoint)(width));
}
const d = Configuration.linkRightSVGPath(start, c1, c2); const d = Configuration.linkRightSVGPath(start, c1, c2);
// TODO move to CSS when Firefox will support property d // TODO move to CSS when Firefox will support property d
link.pathElement.setAttribute("d", d); link.pathElement.setAttribute("d", d);

View File

@@ -73,13 +73,10 @@ export default class LinkTemplate extends Template {
link.style.setProperty("--ueb-to-y", sanitizeText(link.destinationLocation[1])) link.style.setProperty("--ueb-to-y", sanitizeText(link.destinationLocation[1]))
link.style.setProperty("margin-left", `-${start}px`) link.style.setProperty("margin-left", `-${start}px`)
} }
let c1 = 15 if (xInverted) {
if (!xInverted) {
c1 = start + c1 * fillRatio
} else {
start = start + fillRatio * 100 start = start + fillRatio * 100
c1 = start + c1 * fillRatio
} }
const c1 = start + 15 * fillRatio
let c2 = Math.max(40 / aspectRatio, 30) + start let c2 = Math.max(40 / aspectRatio, 30) + start
const c2Decreasing = -0.05 const c2Decreasing = -0.05
const getMaxC2 = (m, p) => { const getMaxC2 = (m, p) => {
@@ -88,9 +85,7 @@ export default class LinkTemplate extends Template {
return x => a / x + q return x => a / x + q
} }
const controlPoint = [500, 140] const controlPoint = [500, 140]
if (xInverted) { c2 = Math.min(c2, getMaxC2(c2Decreasing, controlPoint)(width))
c2 = Math.min(c2, getMaxC2(c2Decreasing, controlPoint)(width))
}
const d = Configuration.linkRightSVGPath(start, c1, c2) const d = Configuration.linkRightSVGPath(start, c1, c2)
// TODO move to CSS when Firefox will support property d // TODO move to CSS when Firefox will support property d
link.pathElement.setAttribute("d", d) link.pathElement.setAttribute("d", d)