Mergin better performance branch

This commit is contained in:
barsdeveloper
2022-09-04 14:33:22 +02:00
parent 47c15fbf8d
commit 715dee6a5a
97 changed files with 2725 additions and 2833 deletions

View File

@@ -1,5 +1,4 @@
// @ts-check
import Configuration from "../../Configuration"
import IMouseClickDrag from "./IMouseClickDrag"
import Utility from "../../Utility"
@@ -15,7 +14,7 @@ export default class MouseMoveNodes extends IMouseClickDrag {
constructor(target, blueprint, options) {
super(target, blueprint, options)
this.stepSize = parseInt(options?.stepSize ?? this.blueprint.gridSize)
this.stepSize = parseInt(options?.stepSize ?? Configuration.gridSize)
this.mouseLocation = [0, 0]
}
@@ -30,9 +29,10 @@ export default class MouseMoveNodes extends IMouseClickDrag {
}
dragTo(location, movement) {
const initialTargetLocation = [this.target.locationX, this.target.locationY]
const [mouseLocation, targetLocation] = this.stepSize > 1
? [Utility.snapToGrid(location, this.stepSize), Utility.snapToGrid(this.target.location, this.stepSize)]
: [location, this.target.location]
? [Utility.snapToGrid(location, this.stepSize), Utility.snapToGrid(initialTargetLocation, this.stepSize)]
: [location, initialTargetLocation]
const d = [
mouseLocation[0] - this.mouseLocation[0],
mouseLocation[1] - this.mouseLocation[1]
@@ -43,8 +43,8 @@ export default class MouseMoveNodes extends IMouseClickDrag {
}
// Make sure it snaps on the grid
d[0] += targetLocation[0] - this.target.location[0]
d[1] += targetLocation[1] - this.target.location[1]
d[0] += targetLocation[0] - this.target.locationX
d[1] += targetLocation[1] - this.target.locationY
this.target.dispatchDragEvent(d)