Fix node selection

This commit is contained in:
barsdeveloper
2022-12-12 21:57:50 +01:00
parent 16a00b409c
commit 88a1becb58
4 changed files with 14 additions and 14 deletions

14
dist/ueblueprint.js vendored
View File

@@ -5670,10 +5670,11 @@ class NodeElement extends ISelectableDraggableElement {
boundComments = [] boundComments = []
#commentDragged = false #commentDragged = false
#commentDragHandler = e => { #commentDragHandler = e => {
// If selected, it will already drag, also must check if under nested comments, it must drag just once
if (!this.selected && !this.#commentDragged) { if (!this.selected && !this.#commentDragged) {
this.addLocation(e.detail.value); // if selected it will already move
this.#commentDragged = true; this.#commentDragged = true;
this.addNextUpdatedCallbacks(() => this.#commentDragged = false); this.addNextUpdatedCallbacks(() => this.#commentDragged = false);
this.addLocation(e.detail.value);
} }
} }
@@ -6250,14 +6251,13 @@ class Blueprint extends IElement {
waitingExpandUpdate = false waitingExpandUpdate = false
/** @param {NodeElement} node */ /** @param {NodeElement} node */
nodeBoundariesSupplier = node => { nodeBoundariesSupplier = node => {
let gridRect = this.nodesContainerElement.getBoundingClientRect(); this.nodesContainerElement.getBoundingClientRect();
const scaleCorrection = 1 / this.getScale();
return /** @type {BoundariesInfo} */ { return /** @type {BoundariesInfo} */ {
primaryInf: (node.leftBoundary() - gridRect.left) * scaleCorrection, primaryInf: node.leftBoundary(),
primarySup: (node.rightBoundary() - gridRect.right) * scaleCorrection, primarySup: node.rightBoundary(),
// Counter intuitive here: the y (secondary axis is positive towards the bottom, therefore upper bound "sup" is bottom) // Counter intuitive here: the y (secondary axis is positive towards the bottom, therefore upper bound "sup" is bottom)
secondaryInf: (node.topBoundary() - gridRect.top) * scaleCorrection, secondaryInf: node.topBoundary(),
secondarySup: (node.bottomBoundary() - gridRect.bottom) * scaleCorrection secondarySup: node.bottomBoundary(),
} }
} }
/** @type {(node: NodeElement, selected: Boolean) => void}} */ /** @type {(node: NodeElement, selected: Boolean) => void}} */

File diff suppressed because one or more lines are too long

View File

@@ -101,13 +101,12 @@ export default class Blueprint extends IElement {
/** @param {NodeElement} node */ /** @param {NodeElement} node */
nodeBoundariesSupplier = node => { nodeBoundariesSupplier = node => {
let gridRect = this.nodesContainerElement.getBoundingClientRect() let gridRect = this.nodesContainerElement.getBoundingClientRect()
const scaleCorrection = 1 / this.getScale()
return /** @type {BoundariesInfo} */ { return /** @type {BoundariesInfo} */ {
primaryInf: (node.leftBoundary() - gridRect.left) * scaleCorrection, primaryInf: node.leftBoundary(),
primarySup: (node.rightBoundary() - gridRect.right) * scaleCorrection, primarySup: node.rightBoundary(),
// Counter intuitive here: the y (secondary axis is positive towards the bottom, therefore upper bound "sup" is bottom) // Counter intuitive here: the y (secondary axis is positive towards the bottom, therefore upper bound "sup" is bottom)
secondaryInf: (node.topBoundary() - gridRect.top) * scaleCorrection, secondaryInf: node.topBoundary(),
secondarySup: (node.bottomBoundary() - gridRect.bottom) * scaleCorrection secondarySup: node.bottomBoundary(),
} }
} }
/** @type {(node: NodeElement, selected: Boolean) => void}} */ /** @type {(node: NodeElement, selected: Boolean) => void}} */

View File

@@ -82,10 +82,11 @@ export default class NodeElement extends ISelectableDraggableElement {
boundComments = [] boundComments = []
#commentDragged = false #commentDragged = false
#commentDragHandler = e => { #commentDragHandler = e => {
// If selected, it will already drag, also must check if under nested comments, it must drag just once
if (!this.selected && !this.#commentDragged) { if (!this.selected && !this.#commentDragged) {
this.addLocation(e.detail.value) // if selected it will already move
this.#commentDragged = true this.#commentDragged = true
this.addNextUpdatedCallbacks(() => this.#commentDragged = false) this.addNextUpdatedCallbacks(() => this.#commentDragged = false)
this.addLocation(e.detail.value)
} }
} }