From d2f7de4f88dc20d5a0be7804dda39c152f720fa6 Mon Sep 17 00:00:00 2001 From: barsdeveloper Date: Sat, 19 Feb 2022 23:50:51 +0100 Subject: [PATCH] Simplify link path --- dist/ueblueprint.js | 13 ++++--------- js/template/LinkTemplate.js | 11 +++-------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/dist/ueblueprint.js b/dist/ueblueprint.js index d5d9167..d99523f 100755 --- a/dist/ueblueprint.js +++ b/dist/ueblueprint.js @@ -1586,13 +1586,10 @@ class LinkTemplate extends Template { link.style.setProperty("--ueb-to-y", sanitizeText(link.destinationLocation[1])); link.style.setProperty("margin-left", `-${start}px`); } - let c1 = 15; - if (!xInverted) { - c1 = start + c1 * fillRatio; - } else { - start = start + fillRatio * 100; - c1 = start + c1 * fillRatio; + if (xInverted) { + start = start + dx; } + const c1 = start + 15 * fillRatio; let c2 = Math.max(40 / aspectRatio, 30) + start; const c2Decreasing = -0.05; const getMaxC2 = (m, p) => { @@ -1601,9 +1598,7 @@ class LinkTemplate extends Template { return x => a / x + q }; 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); // TODO move to CSS when Firefox will support property d link.pathElement.setAttribute("d", d); diff --git a/js/template/LinkTemplate.js b/js/template/LinkTemplate.js index 7fa17eb..3bf23f3 100755 --- a/js/template/LinkTemplate.js +++ b/js/template/LinkTemplate.js @@ -73,13 +73,10 @@ export default class LinkTemplate extends Template { link.style.setProperty("--ueb-to-y", sanitizeText(link.destinationLocation[1])) link.style.setProperty("margin-left", `-${start}px`) } - let c1 = 15 - if (!xInverted) { - c1 = start + c1 * fillRatio - } else { + if (xInverted) { start = start + fillRatio * 100 - c1 = start + c1 * fillRatio } + const c1 = start + 15 * fillRatio let c2 = Math.max(40 / aspectRatio, 30) + start const c2Decreasing = -0.05 const getMaxC2 = (m, p) => { @@ -88,9 +85,7 @@ export default class LinkTemplate extends Template { return x => a / x + q } 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) // TODO move to CSS when Firefox will support property d link.pathElement.setAttribute("d", d)