Move style related actions to templates

This commit is contained in:
barsdeveloper
2021-12-10 21:05:44 +01:00
parent 7bc0f4e2f2
commit 6b02ab7e08
19 changed files with 2693 additions and 139 deletions

View File

@@ -8,6 +8,8 @@ export default class SelectableDraggable extends GraphElement {
this.dragObject = null
this.location = [0, 0]
this.selected = false
/** @type {import("../template/SelectableDraggableTemplate").default} */
this.template
let self = this
this.dragHandler = (e) => {
@@ -28,8 +30,7 @@ export default class SelectableDraggable extends GraphElement {
setLocation(value = [0, 0]) {
this.location = value
this.style.setProperty("--ueb-position-x", this.location[0])
this.style.setProperty("--ueb-position-y", this.location[1])
this.template.applyLocation(this)
}
addLocation(value) {
@@ -59,11 +60,10 @@ export default class SelectableDraggable extends GraphElement {
}
this.selected = value
if (this.selected) {
this.classList.add("ueb-selected")
this.blueprint.addEventListener("uDragSelected", this.dragHandler)
} else {
this.classList.remove("ueb-selected")
this.blueprint.removeEventListener("uDragSelected", this.dragHandler)
}
this.template.applySelected(this)
}
}