Simplify positioned style computation

This commit is contained in:
barsdeveloper
2022-10-18 20:25:42 +02:00
parent e8a35c81d0
commit 14d376d447
13 changed files with 127 additions and 133 deletions

View File

@@ -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
}
}