Various fixes to links

This commit is contained in:
barsdeveloper
2022-03-02 22:55:05 +01:00
parent 525b4188dc
commit 2d2af6f097
11 changed files with 115 additions and 35 deletions

View File

@@ -26,11 +26,16 @@ export default class LinkMessageTemplate extends ITemplate {
*/
apply(linkMessage) {
super.apply(linkMessage)
linkMessage.linkElement = linkMessage.closest(LinkElement.tagName)
linkMessage.querySelector(".ueb-link-message").innerText = linkMessage.message(
const linkMessageSetup = _ => linkMessage.querySelector(".ueb-link-message").innerText = linkMessage.message(
linkMessage.linkElement.getSourcePin(),
linkMessage.linkElement.getDestinationPin()
)
linkMessage.linkElement = linkMessage.closest(LinkElement.tagName)
if (linkMessage.linkElement) {
linkMessageSetup()
} else {
window.customElements.whenDefined(linkMessage.constructor.tagName).then(linkMessage)
}
}
}

View File

@@ -9,10 +9,10 @@ import sanitizeText from "./sanitizeText"
*/
export default class LinkTemplate extends ITemplate {
static c1DecreasingSpeed = -0.15
static c1DecreasingSpeed = -0.1
static c1ControlPoint = [100, 15]
static c2DecreasingSpeed = -0.06
static c2ControlPoint = [500, 140]
static c2DecreasingSpeed = -0.07
static c2ControlPoint = [500, 130]
/**
* Returns the value of inverse multiplication function y = a / x + q. The value of a and q are calculated using
@@ -51,10 +51,10 @@ export default class LinkTemplate extends ITemplate {
* @param {LinkElement} link Element of the graph
*/
apply(link) {
super.apply(link)
if (link.linkMessageElement) {
link.appendChild(link.linkMessageElement)
}
super.apply(link)
link.classList.add("ueb-positioned")
link.pathElement = link.querySelector("path")
}
@@ -128,13 +128,13 @@ export default class LinkTemplate extends ITemplate {
: 15
)
* fillRatio
let c2 = Math.max(40 / aspectRatio, 30) + start
let c2 = Math.max(25 / aspectRatio, 30) + start
c2 = Math.min(
c2,
LinkTemplate.decreasingValue(
LinkTemplate.c2DecreasingSpeed,
LinkTemplate.c2ControlPoint
)(width)
)(dx)
)
const d = Configuration.linkRightSVGPath(start, c1, c2)
// TODO move to CSS when Firefox will support property d