Fix linking

This commit is contained in:
barsdeveloper
2022-02-19 23:01:52 +01:00
parent 45918eebaa
commit 55b12bac0c
5 changed files with 131 additions and 63 deletions

View File

@@ -117,14 +117,14 @@ export default class GraphLink extends GraphElement {
if (this.#source) {
const nodeElement = this.#source.getGraphNode()
nodeElement.removeEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler)
nodeElement.removeEventListener(Configuration.nodeDragEventName, this.#nodeDragSourceHandler)
nodeElement.removeEventListener(Configuration.nodeDragLocalEventName, this.#nodeDragSourceHandler)
}
this.#source = graphPin
if (this.#source) {
const nodeElement = this.#source.getGraphNode()
this.originatesFromInput = graphPin.isInput()
nodeElement.addEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler)
nodeElement.addEventListener(Configuration.nodeDragEventName, this.#nodeDragSourceHandler)
nodeElement.addEventListener(Configuration.nodeDragLocalEventName, this.#nodeDragSourceHandler)
this.setSourceLocation()
}
}
@@ -144,14 +144,14 @@ export default class GraphLink extends GraphElement {
setDestinationPin(graphPin) {
if (this.#destination) {
const nodeElement = this.#source.getGraphNode()
nodeElement.removeEventListener(Configuration.nodeDragEventName, this.#nodeDeleteHandler)
nodeElement.removeEventListener(Configuration.nodeDragEventName, this.#nodeDragDestinatonHandler)
nodeElement.removeEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler)
nodeElement.removeEventListener(Configuration.nodeDragLocalEventName, this.#nodeDragDestinatonHandler)
}
this.#destination = graphPin
if (this.#destination) {
const nodeElement = this.#source.getGraphNode()
nodeElement.addEventListener(Configuration.nodeDragEventName, this.#nodeDeleteHandler)
nodeElement.addEventListener(Configuration.nodeDragEventName, this.#nodeDragDestinatonHandler)
nodeElement.addEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler)
nodeElement.addEventListener(Configuration.nodeDragLocalEventName, this.#nodeDragDestinatonHandler)
}
}
}

View File

@@ -27,8 +27,17 @@ export default class SelectableDraggable extends GraphElement {
}
setLocation(value = [0, 0]) {
const d = [value[0] - this.location[0], value[1] - this.location[1]]
const dragLocalEvent = new CustomEvent(Configuration.nodeDragLocalEventName, {
detail: {
value: d
},
bubbles: false,
cancelable: true
})
this.location = value
this.template.applyLocation(this)
this.dispatchEvent(dragLocalEvent)
}
addLocation(value) {