mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-27 10:44:43 +08:00
Comment now drag nodes
This commit is contained in:
@@ -78,7 +78,16 @@ export default class NodeElement extends ISelectableDraggableElement {
|
||||
}
|
||||
|
||||
#pins
|
||||
#boundComments
|
||||
/** @type {NodeElement[]} */
|
||||
boundComments = []
|
||||
#commentDragged = false
|
||||
#commentDragHandler = e => {
|
||||
if (!this.selected && !this.#commentDragged) {
|
||||
this.addLocation(e.detail.value) // if selected it will already move
|
||||
this.#commentDragged = true
|
||||
this.addNextUpdatedCallbacks(() => this.#commentDragged = false)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ObjectEntity} entity
|
||||
@@ -122,6 +131,32 @@ export default class NodeElement extends ISelectableDraggableElement {
|
||||
return new NodeElement(entity)
|
||||
}
|
||||
|
||||
/** @param {NodeElement} commentNode */
|
||||
bindToComment(commentNode) {
|
||||
if (!this.boundComments.includes(commentNode)) {
|
||||
commentNode.addEventListener(Configuration.nodeDragEventName, this.#commentDragHandler)
|
||||
this.boundComments.push(commentNode)
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {NodeElement} commentNode */
|
||||
unbindFromComment(commentNode) {
|
||||
const commentIndex = this.boundComments.indexOf(commentNode)
|
||||
if (commentIndex >= 0) {
|
||||
commentNode.removeEventListener(Configuration.nodeDragEventName, this.#commentDragHandler)
|
||||
this.boundComments[commentIndex] = this.boundComments[this.boundComments.length - 1]
|
||||
this.boundComments.pop()
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {NodeElement} commentNode */
|
||||
isInsideComment(commentNode) {
|
||||
return this.topBoundary() >= commentNode.topBoundary()
|
||||
&& this.rightBoundary() <= commentNode.rightBoundary()
|
||||
&& this.bottomBoundary() <= commentNode.bottomBoundary()
|
||||
&& this.leftBoundary() >= commentNode.leftBoundary()
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
super.disconnectedCallback()
|
||||
this.acknowledgeDelete()
|
||||
|
||||
Reference in New Issue
Block a user