Minor refactoring

This commit is contained in:
barsdeveloper
2025-01-25 01:41:32 +02:00
parent dfa402707c
commit 1d9a88125e
13 changed files with 176 additions and 104 deletions

View File

@@ -8,14 +8,15 @@ export default class KnotPinTemplate extends MinimalPinTemplate {
return this.element.isOutput() ? super.render() : html``
}
oppositePin() {
getoppositePin() {
const nodeTemplate = /** @type {KnotNodeTemplate} */(this.element.nodeElement.template)
return this.element.isOutput() ? nodeTemplate.inputPin : nodeTemplate.outputPin
}
/** Location on the grid of a link connecting to this pin */
getLinkLocation() {
if (this.element.isInput()) {
return this.oppositePin().getLinkLocation()
return this.getoppositePin().getLinkLocation()
}
return super.getLinkLocation()
}

View File

@@ -172,9 +172,12 @@ export default class PinTemplate extends ITemplate {
}
getLinkLocation() {
const rect = this.iconElement.getBoundingClientRect()
const rect = (this.#iconElement ?? this.element).getBoundingClientRect()
/** @type {[Number, Number]} */
const boundingLocation = [this.element.isInputVisually() ? rect.left : rect.right + 1, (rect.top + rect.bottom) / 2]
const boundingLocation = [
this.element.isInputVisually() ? rect.left : rect.right + 1,
(rect.top + rect.bottom) / 2
]
const location = Utility.convertLocation(boundingLocation, this.blueprint.template.gridElement)
return this.blueprint.compensateTranslation(location[0], location[1])
}