Start implementing link dragging

This commit is contained in:
barsdeveloper
2021-11-16 22:12:41 +01:00
parent 7ec75e1ce8
commit ffe50c2be5
8 changed files with 92 additions and 32 deletions

View File

@@ -2,6 +2,7 @@ import NodeTemplate from "../template/NodeTemplate"
import ObjectEntity from "../entity/ObjectEntity"
import SelectableDraggable from "./SelectableDraggable"
import SerializerFactory from "../serialization/SerializerFactory"
import DragLink from "../input/DragLink"
export default class GraphNode extends SelectableDraggable {
@@ -16,21 +17,30 @@ export default class GraphNode extends SelectableDraggable {
*/
constructor(entity) {
super(entity, new NodeTemplate())
this.graphNodeName = 'n/a'
this.inputs = []
this.outputs = []
this.graphNodeName = "n/a"
this.dragLinkObjects = Array()
super.setLocation([this.entity.NodePosX, this.entity.NodePosY])
}
connectedCallback() {
const type = this.getAttribute('type')?.trim()
const type = this.getAttribute("type")?.trim()
super.connectedCallback()
this.classList.add('ueb-node')
this.classList.add("ueb-node")
if (this.selected) {
this.classList.add('ueb-selected')
this.classList.add("ueb-selected")
}
this.style.setProperty('--ueb-position-x', this.location[0])
this.style.setProperty('--ueb-position-y', this.location[1])
this.style.setProperty("--ueb-position-x", this.location[0])
this.style.setProperty("--ueb-position-y", this.location[1])
this.querySelectorAll(".ueb-node-input, .ueb-node-output").forEach(element => {
this.dragLinkObjects.push(
new DragLink(element, this.blueprint, {
clickButton: 0,
moveEverywhere: true,
exitAnyButton: true,
looseTarget: true
})
)
})
}
setLocation(value = [0, 0]) {