mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-23 23:34:43 +08:00
Mergin better performance branch
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user