mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-02 21:17:32 +08:00
Simplify positioned style computation
This commit is contained in:
@@ -14,19 +14,19 @@ export default class IFromToPositionedElement extends IElement {
|
||||
|
||||
static properties = {
|
||||
...super.properties,
|
||||
initialPositionX: {
|
||||
fromX: {
|
||||
type: Number,
|
||||
attribute: false,
|
||||
},
|
||||
initialPositionY: {
|
||||
fromY: {
|
||||
type: Number,
|
||||
attribute: false,
|
||||
},
|
||||
finaPositionX: {
|
||||
toX: {
|
||||
type: Number,
|
||||
attribute: false,
|
||||
},
|
||||
finaPositionY: {
|
||||
toY: {
|
||||
type: Number,
|
||||
attribute: false,
|
||||
},
|
||||
@@ -35,29 +35,29 @@ export default class IFromToPositionedElement extends IElement {
|
||||
constructor(...args) {
|
||||
// @ts-expect-error
|
||||
super(...args)
|
||||
this.initialPositionX = 0
|
||||
this.initialPositionY = 0
|
||||
this.finaPositionX = 0
|
||||
this.finaPositionY = 0
|
||||
this.fromX = 0
|
||||
this.fromY = 0
|
||||
this.toX = 0
|
||||
this.toY = 0
|
||||
}
|
||||
|
||||
/** @param {Number[]} param0 */
|
||||
setBothLocations([x, y]) {
|
||||
this.initialPositionX = x
|
||||
this.initialPositionY = y
|
||||
this.finaPositionX = x
|
||||
this.finaPositionY = y
|
||||
this.fromX = x
|
||||
this.fromY = y
|
||||
this.toX = x
|
||||
this.toY = y
|
||||
}
|
||||
|
||||
/** @param {Number[]} offset */
|
||||
addSourceLocation([offsetX, offsetY]) {
|
||||
this.initialPositionX += offsetX
|
||||
this.initialPositionY += offsetY
|
||||
this.fromX += offsetX
|
||||
this.fromY += offsetY
|
||||
}
|
||||
|
||||
/** @param {Number[]} offset */
|
||||
addDestinationLocation([offsetX, offsetY]) {
|
||||
this.finaPositionX += offsetX
|
||||
this.finaPositionY += offsetY
|
||||
this.toX += offsetX
|
||||
this.toY += offsetY
|
||||
}
|
||||
}
|
||||
@@ -92,15 +92,15 @@ export default class LinkElement extends IFromToPositionedElement {
|
||||
if (source) {
|
||||
this.sourcePin = source
|
||||
if (!destination) {
|
||||
this.finaPositionX = this.initialPositionX
|
||||
this.finaPositionY = this.initialPositionY
|
||||
this.toX = this.fromX
|
||||
this.toY = this.fromY
|
||||
}
|
||||
}
|
||||
if (destination) {
|
||||
this.destinationPin = destination
|
||||
if (!source) {
|
||||
this.initialPositionX = this.finaPositionX
|
||||
this.initialPositionY = this.finaPositionY
|
||||
this.fromX = this.toX
|
||||
this.fromY = this.toY
|
||||
}
|
||||
}
|
||||
this.#linkPins()
|
||||
@@ -181,8 +181,8 @@ export default class LinkElement extends IFromToPositionedElement {
|
||||
location = this.sourcePin.template.getLinkLocation()
|
||||
}
|
||||
const [x, y] = location
|
||||
this.initialPositionX = x
|
||||
this.initialPositionY = y
|
||||
this.fromX = x
|
||||
this.fromY = y
|
||||
}
|
||||
|
||||
/** @param {Number[]?} location */
|
||||
@@ -195,8 +195,8 @@ export default class LinkElement extends IFromToPositionedElement {
|
||||
}
|
||||
location = this.destinationPin.template.getLinkLocation()
|
||||
}
|
||||
this.finaPositionX = location[0]
|
||||
this.finaPositionY = location[1]
|
||||
this.toX = location[0]
|
||||
this.toY = location[1]
|
||||
}
|
||||
|
||||
startDragging() {
|
||||
|
||||
@@ -26,17 +26,17 @@ export default class SelectorElement extends IFromToPositionedElement {
|
||||
selectTo(finalPosition) {
|
||||
/** @type {FastSelectionModel} */ (this.selectionModel)
|
||||
.selectTo(finalPosition)
|
||||
this.finaPositionX = finalPosition[0]
|
||||
this.finaPositionY = finalPosition[1]
|
||||
this.toX = finalPosition[0]
|
||||
this.toY = finalPosition[1]
|
||||
}
|
||||
|
||||
endSelect() {
|
||||
this.blueprint.selecting = false
|
||||
this.selectionModel = null
|
||||
this.initialPositionX = 0
|
||||
this.initialPositionY = 0
|
||||
this.finaPositionX = 0
|
||||
this.finaPositionY = 0
|
||||
this.fromX = 0
|
||||
this.fromY = 0
|
||||
this.toX = 0
|
||||
this.toY = 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user